aboutsummaryrefslogtreecommitdiff
path: root/primes.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'primes.cpp')
-rw-r--r--primes.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/primes.cpp b/primes.cpp
index 934d886..ddb559c 100644
--- a/primes.cpp
+++ b/primes.cpp
@@ -31,7 +31,7 @@ void fillsmallprimes(){
//cerr<<endl;
}
-pair<Bigint,Bigint> genprimepair(int nbits){
+pair<Bigint,Bigint> genprimepair(Rng &rng,int nbits){
// for x = nbits/2:
// (2^x)^2 = 2^(2x)
// (2^x + 2^(x-2))^2 = 2^(2x) + 2^(2x-1) + 2^(2x-4)
@@ -41,11 +41,11 @@ pair<Bigint,Bigint> genprimepair(int nbits){
int x1=nbits/2-2,x2=(nbits+1)/2+2;
assert(x1+x2==nbits);
return make_pair(
- randprime(Bigint::one<<x1,(Bigint::one<<x1)+(Bigint::one<<(x1-2))),
- randprime(Bigint::one<<x2,(Bigint::one<<x2)+(Bigint::one<<(x2-2))));
+ randprime(rng,Bigint::one<<x1,(Bigint::one<<x1)+(Bigint::one<<(x1-2))),
+ randprime(rng,Bigint::one<<x2,(Bigint::one<<x2)+(Bigint::one<<(x2-2))));
}
-Bigint randprime(const Bigint &biglow,const Bigint &bighigh){
+Bigint randprime(Rng &rng,const Bigint &biglow,const Bigint &bighigh){
//https://en.wikipedia.org/wiki/Generating_primes#Large_primes
if(!smallprimes_inited)fillsmallprimes();
@@ -58,7 +58,7 @@ Bigint randprime(const Bigint &biglow,const Bigint &bighigh){
high=bighigh;
// cerr<<"low=biglow="<<low<<" high=bighigh="<<high<<endl;
} else {
- high=low=cryptrandom_big(diff-maxrangesize);
+ high=low=bigrandom(rng,diff-maxrangesize);
high+=maxrangesize;
// cerr<<"low="<<low<<" high="<<high<<endl;
}
@@ -102,7 +102,7 @@ Bigint randprime(const Bigint &biglow,const Bigint &bighigh){
// cerr<<endl;
while(maybeprimes.size()){
- int idx=arc4random_uniform(maybeprimes.size());
+ int idx=rng.get_uniform(maybeprimes.size());
int i=maybeprimes[idx];
Bigint bi(low+2*i);
if(bailliePSW(bi))return bi;