Trait crypto_primes::RandomPrimeWithRng
source · pub trait RandomPrimeWithRng {
// Required methods
fn prime_with_rng(rng: &mut impl CryptoRngCore, bit_length: usize) -> Self;
fn safe_prime_with_rng(
rng: &mut impl CryptoRngCore,
bit_length: 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 prime_with_rng(rng: &mut impl CryptoRngCore, bit_length: usize) -> Self
fn prime_with_rng(rng: &mut impl CryptoRngCore, bit_length: usize) -> Self
Returns a random prime of size bit_length using the provided RNG.
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 safe_prime_with_rng(rng: &mut impl CryptoRngCore, bit_length: usize) -> Self
fn safe_prime_with_rng(rng: &mut impl CryptoRngCore, bit_length: 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.
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.