RandPrime

Trait RandPrime 

Source
pub trait RandPrime<T> {
    // Required methods
    fn gen_prime(
        &mut self,
        bit_size: usize,
        config: Option<PrimalityTestConfig>,
    ) -> T;
    fn gen_prime_exact(
        &mut self,
        bit_size: usize,
        config: Option<PrimalityTestConfig>,
    ) -> T;
    fn gen_safe_prime(&mut self, bit_size: usize) -> T;
    fn gen_safe_prime_exact(&mut self, bit_size: usize) -> T;
}
Expand description

Supports random generation of primes

Required Methods§

Source

fn gen_prime( &mut self, bit_size: usize, config: Option<PrimalityTestConfig>, ) -> T

Generate a random prime within the given bit size limit

§Panics

if the bit_size is 0 or it’s larger than the bit width of the integer

Source

fn gen_prime_exact( &mut self, bit_size: usize, config: Option<PrimalityTestConfig>, ) -> T

Generate a random prime with exact the given bit size

§Panics

if the bit_size is 0 or it’s larger than the bit width of the integer

Source

fn gen_safe_prime(&mut self, bit_size: usize) -> T

Generate a random (Sophie German) safe prime within the given bit size limit. The generated prime is guaranteed to pass the is_safe_prime test

§Panics

if the bit_size is 0 or it’s larger than the bit width of the integer

Source

fn gen_safe_prime_exact(&mut self, bit_size: usize) -> T

Generate a random (Sophie German) safe prime with the exact given bit size. The generated prime is guaranteed to pass the is_safe_prime test

§Panics

if the bit_size is 0 or it’s larger than the bit width of the integer

Implementors§

Source§

impl<R: Rng> RandPrime<u8> for R

Source§

impl<R: Rng> RandPrime<u16> for R

Source§

impl<R: Rng> RandPrime<u32> for R

Source§

impl<R: Rng> RandPrime<u64> for R

Source§

impl<R: Rng> RandPrime<u128> for R

Source§

impl<R: Rng> RandPrime<BigUint> for R

Available on crate feature num-bigint only.