Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C语言中大整数的Miller-Rabin算法_C - Fatal编程技术网

C语言中大整数的Miller-Rabin算法

C语言中大整数的Miller-Rabin算法,c,C,Miller-Rabin试验可用伪代码描述如下: Let int n be a possible prime . Let int t be a security parameter . Write n-1 = 2^{s} * r for odd r . For i = 1 to t do Generate a random a in [2; n-2]. Let b=a^{r} mod n . If b!=1 and b!=-1 do

Miller-Rabin试验可用伪代码描述如下:

Let int n be a possible prime . Let int t be a security parameter .   
Write n-1 = 2^{s} * r for odd r .
    For i = 1 to t do
       Generate a random a in [2; n-2]. Let b=a^{r} mod n .
       If b!=1 and b!=-1 do
          j=1
          While j<=s-1 and b!=-1 do
             Let b=b^{2} mod n
             If b=1 return "composite"
             j=j+1
          If b!=-1 return "composite"
    Return "prime"
设int n为可能的素数。设int t为安全参数。
为奇数r写入n-1=2^{s}*r。
对于i=1,不需要
在[2;n-2]中生成随机a。设b=a^{r}mod n。
如果b=1和b=-我做
j=1

通常情况下,根据您的目的,组装将用于mod exp步骤,最佳优化可能是使用一个小的
t
:。如果您试图检查随机生成的512位奇数
t=2
就足够了。