Crate crypto_primes
source ·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
- Components to build your own primality test. Handle with care.
Traits
- 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-rngReturns a random prime of sizebit_lengthusingOsRngas the RNG. Ifbit_lengthisNone, the full size ofUint<L>is used. - Returns a random prime of size
bit_lengthusing the provided RNG. Ifbit_lengthisNone, the full size ofUint<L>is used. - generate_safe_prime
default-rngReturns 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. - 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-rngChecks probabilistically if the given number is prime usingOsRngas the RNG. - Checks probabilistically if the given number is prime using the provided RNG.
- is_safe_prime
default-rngChecks probabilistically if the given number is a safe prime (that is, such that(n - 1) / 2is also prime) usingOsRngas the RNG. - Checks probabilistically if the given number is a safe prime using the provided RNG.