aboutsummaryrefslogtreecommitdiffstats
path: root/src/math/numbertheory/make_prm.cpp
diff options
context:
space:
mode:
authorlloyd <[email protected]>2009-07-10 00:58:04 +0000
committerlloyd <[email protected]>2009-07-10 00:58:04 +0000
commit0b68ccf2bae10f41cee506fb2eb64d608d694043 (patch)
tree7cc3a2a04220bc651e089b98a99f6bb44236be21 /src/math/numbertheory/make_prm.cpp
parent1a0b389ab37050c1dc4033c9933849e1725f761f (diff)
Devai Tamas pointed out on the mailing list that random_prime with bits
set to 2, 3, or 4 was not returning a random prime due to reducing the rng output modulo 1 instead of mod 2 in choosing which prime of that size to return. Oops.
Diffstat (limited to 'src/math/numbertheory/make_prm.cpp')
-rw-r--r--src/math/numbertheory/make_prm.cpp6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/math/numbertheory/make_prm.cpp b/src/math/numbertheory/make_prm.cpp
index 226f0c38f..b136b6d25 100644
--- a/src/math/numbertheory/make_prm.cpp
+++ b/src/math/numbertheory/make_prm.cpp
@@ -22,11 +22,11 @@ BigInt random_prime(RandomNumberGenerator& rng,
throw Invalid_Argument("random_prime: Can't make a prime of " +
to_string(bits) + " bits");
else if(bits == 2)
- return ((rng.next_byte() % 1) ? 2 : 3);
+ return ((rng.next_byte() % 2) ? 2 : 3);
else if(bits == 3)
- return ((rng.next_byte() % 1) ? 5 : 7);
+ return ((rng.next_byte() % 2) ? 5 : 7);
else if(bits == 4)
- return ((rng.next_byte() % 1) ? 11 : 13);
+ return ((rng.next_byte() % 2) ? 11 : 13);
if(coprime <= 0)
throw Invalid_Argument("random_prime: coprime must be > 0");