generate_probable_prime(**kwargs)
|
|
Generate a random probable prime.
The prime will not have any specific properties
(e.g. it will not be a strong prime).
Random numbers are evaluated for primality until one
passes all tests, consisting of a certain number of
Miller-Rabin tests with random bases followed by
a single Lucas test.
The number of Miller-Rabin iterations is chosen such that
the probability that the output number is a non-prime is
less than 1E-30 (roughly 2^{-100}).
This approach is compliant to FIPS PUB 186-4.
- Parameters:
exact_bits (integer) - The desired size in bits of the probable prime.
It must be at least 160.
randfunc (callable) - An RNG function where candidate primes are taken from.
prime_filter (callable) - A function that takes an Integer as parameter and returns
True if the number can be passed to further primality tests,
False if it should be immediately discarded.
- Returns:
- A probable prime in the range 2^exact_bits > p > 2^(exact_bits-1).
|