Expand description
§Prime number tools for crypto-bigint
This library implements prime number generation and primality checking for crypto-bigint integers.
In particular:
- Generating random primes and safe primes of given bit size;
- Sieving iterator;
- Miller-Rabin test;
- Strong and extra strong Lucas tests, and Lucas-V test.
See the documentation for the specific tests for more information and references.
Modules§
- hazmat
- Components to build your own primality test. Handle with care.
Traits§
- Random
Prime With Rng - Provides a generic way to access methods for random prime number generation
and primality checking, wrapping the standalone functions (
is_prime_with_rngetc).
Functions§
- generate_
prime default-rng - Returns a random prime of size
bit_lengthusingOsRngas the RNG. Ifbit_lengthisNone, the full size ofUint<L>is used. - generate_
prime_ with_ rng - Returns a random prime of size
bit_lengthusing the provided RNG. Ifbit_lengthisNone, the full size ofUint<L>is used. - generate_
safe_ prime default-rng - Returns a random safe prime (that is, such that
(n - 1) / 2is also prime) of sizebit_lengthusingOsRngas the RNG. Ifbit_lengthisNone, the full size ofUint<L>is used. - generate_
safe_ prime_ with_ rng - Returns a random safe prime (that is, such that
(n - 1) / 2is also prime) of sizebit_lengthusing the provided RNG. Ifbit_lengthisNone, the full size ofUint<L>is used. - is_
prime default-rng - Checks probabilistically if the given number is prime using
OsRngas the RNG. - is_
prime_ with_ rng - Checks probabilistically if the given number is prime using the provided RNG.
- is_
safe_ prime default-rng - Checks probabilistically if the given number is a safe prime
(that is, such that
(n - 1) / 2is also prime) usingOsRngas the RNG. - is_
safe_ prime_ with_ rng - Checks probabilistically if the given number is a safe prime using the provided RNG.