crttest.c

来自「这是一个同样来自贝尔实验室的和UNIX有着渊源的操作系统, 其简洁的设计和实现易」· C语言 代码 · 共 55 行

C
55
字号
#include "os.h"#include <mp.h>#include <libsec.h>voidtestcrt(mpint **p){	CRTpre *crt;	CRTres *res;	mpint *m, *x, *y;	int i;	fmtinstall('B', mpconv);	// get a modulus and a test number	m = mpnew(1024+160);	mpmul(p[0], p[1], m);	x = mpnew(1024+160);	mpadd(m, mpone, x);	// do the precomputation for crt conversion	crt = crtpre(2, p);	// convert x to residues	res = crtin(crt, x);	// convert back	y = mpnew(1024+160);	crtout(crt, res, y);	print("x %B\ny %B\n", x, y);	mpfree(m);	mpfree(x);	mpfree(y);}voidmain(void){	int i;	mpint *p[2];	long start;	start = time(0);	for(i = 0; i < 10; i++){		p[0] = mpnew(1024);		p[1] = mpnew(1024);		DSAprimes(p[0], p[1], nil);		testcrt(p);		mpfree(p[0]);		mpfree(p[1]);	}	print("%d secs with more\n", time(0)-start);	exits(0);}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?