diff options
author | Jack Lloyd <[email protected]> | 2019-01-17 09:16:50 -0500 |
---|---|---|
committer | Jack Lloyd <[email protected]> | 2019-01-17 09:16:50 -0500 |
commit | 377ed5445083af5703fe8b0411ad162af1766012 (patch) | |
tree | 77936fb806a62f37508803651b7d73bb8af3b11c /src/lib/math/numbertheory/make_prm.cpp | |
parent | 4c3016578da7b9840bb77563f4257df11c9f1de9 (diff) |
Fix some warnings from PVS-Studio
No real bugs, but pointed out some odd constructs and duplicated logic
Diffstat (limited to 'src/lib/math/numbertheory/make_prm.cpp')
-rw-r--r-- | src/lib/math/numbertheory/make_prm.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/lib/math/numbertheory/make_prm.cpp b/src/lib/math/numbertheory/make_prm.cpp index d18c82c0b..7455a0049 100644 --- a/src/lib/math/numbertheory/make_prm.cpp +++ b/src/lib/math/numbertheory/make_prm.cpp @@ -112,8 +112,11 @@ BigInt random_prime(RandomNumberGenerator& rng, { for(;;) { - size_t idx = make_uint16(rng.next_byte(), rng.next_byte()) % PRIME_TABLE_SIZE; - uint16_t small_prime = PRIMES[idx]; + // This is slightly biased, but for small primes it does not seem to matter + const uint8_t b0 = rng.next_byte(); + const uint8_t b1 = rng.next_byte(); + const size_t idx = make_uint16(b0, b1) % PRIME_TABLE_SIZE; + const uint16_t small_prime = PRIMES[idx]; if(high_bit(small_prime) == bits) return small_prime; |