Trait crypto_primes::RandomPrimeWithRng
source · pub trait RandomPrimeWithRng {
// Required methods
fn generate_prime_with_rng(
rng: &mut impl CryptoRngCore,
bit_length: Option<usize>
) -> Self;
fn generate_safe_prime_with_rng(
rng: &mut impl CryptoRngCore,
bit_length: Option<usize>
) -> Self;
fn is_prime_with_rng(&self, rng: &mut impl CryptoRngCore) -> bool;
fn is_safe_prime_with_rng(&self, rng: &mut impl CryptoRngCore) -> bool;
}Expand description
Provides a generic way to access methods for random prime number generation
and primality checking, wrapping the standalone functions (is_prime_with_rng etc).
Required Methods§
sourcefn generate_prime_with_rng(
rng: &mut impl CryptoRngCore,
bit_length: Option<usize>
) -> Self
fn generate_prime_with_rng( rng: &mut impl CryptoRngCore, bit_length: Option<usize> ) -> Self
Returns a random prime of size bit_length using the provided RNG.
If bit_length is None, the full size of Uint<L> is used.
Panics if bit_length is less than 2, or greater than the bit size of the target Uint.
See is_prime_with_rng for details about the performed checks.
sourcefn generate_safe_prime_with_rng(
rng: &mut impl CryptoRngCore,
bit_length: Option<usize>
) -> Self
fn generate_safe_prime_with_rng( rng: &mut impl CryptoRngCore, bit_length: Option<usize> ) -> Self
Returns a random safe prime (that is, such that (n - 1) / 2 is also prime)
of size bit_length using the provided RNG.
If bit_length is None, the full size of Uint<L> is used.
Panics if bit_length is less than 3, or greater than the bit size of the target Uint.
See is_prime_with_rng for details about the performed checks.
sourcefn is_prime_with_rng(&self, rng: &mut impl CryptoRngCore) -> bool
fn is_prime_with_rng(&self, rng: &mut impl CryptoRngCore) -> bool
Checks probabilistically if the given number is prime using the provided RNG.
See is_prime_with_rng for details about the performed checks.
sourcefn is_safe_prime_with_rng(&self, rng: &mut impl CryptoRngCore) -> bool
fn is_safe_prime_with_rng(&self, rng: &mut impl CryptoRngCore) -> bool
Checks probabilistically if the given number is a safe prime using the provided RNG.
See is_prime_with_rng for details about the performed checks.