pub trait RandomPrimeWithRng {
// Required methods
fn generate_prime_with_rng(
rng: &mut (impl CryptoRngCore + ?Sized),
bit_length: u32,
) -> Self;
fn generate_safe_prime_with_rng(
rng: &mut (impl CryptoRngCore + ?Sized),
bit_length: u32,
) -> Self;
fn is_prime_with_rng(&self, rng: &mut (impl CryptoRngCore + ?Sized)) -> bool;
fn is_safe_prime_with_rng(
&self,
rng: &mut (impl CryptoRngCore + ?Sized),
) -> 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 + ?Sized),
bit_length: u32,
) -> Self
fn generate_prime_with_rng( rng: &mut (impl CryptoRngCore + ?Sized), bit_length: u32, ) -> 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 generate_safe_prime_with_rng(
rng: &mut (impl CryptoRngCore + ?Sized),
bit_length: u32,
) -> Self
fn generate_safe_prime_with_rng( rng: &mut (impl CryptoRngCore + ?Sized), bit_length: u32, ) -> 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 + ?Sized)) -> bool
fn is_prime_with_rng(&self, rng: &mut (impl CryptoRngCore + ?Sized)) -> bool
Probabilistically checks 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 + ?Sized),
) -> bool
fn is_safe_prime_with_rng( &self, rng: &mut (impl CryptoRngCore + ?Sized), ) -> bool
Probabilistically checks if the given number is a safe prime using the provided RNG.
See is_prime_with_rng for details about the performed checks.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.