-
Notifications
You must be signed in to change notification settings - Fork 14
Open
Labels
enhancementNew feature or requestNew feature or requestmathsNeeds help of a mathematicianNeeds help of a mathematician
Description
Currently random prime generation starts from a random number and runs a sieve until a prime is found. This can introduce bias, selecting primes with large leads more often. Some assorted considerations:
- How dangerous is it, actually? Any sources?
- GMP re-samples the start position every 0x10000 samples, quoting "deep science" (with no further explanations). OpenSSL doesn't re-sample.
- Just sampling random numbers each time and running BPSW on them makes the generation several times slower.
- To avoid touching the RNG many times, we can start with a random
a < 2^(k-1), and generate candidates as2^(k-1) + (a + i * b mod 2^(k-1))wherebis a random odd number. This will uniformly cover all the range[2^(k-1), 2^k)(right?) May be a little faster but not too much. - See https://eprint.iacr.org/2011/481.pdf ("Close to Uniform Prime Number Generation With Fewer Random Bits") for a more advanced algorithm.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestmathsNeeds help of a mathematicianNeeds help of a mathematician