pub use crate::common::{
gen_prime as from_rng, is_prime as check_with, is_prime_baillie_psw as strong_check_with,
};
#[cfg(feature = "getrandom")]
use crate::error::Result;
#[cfg(feature = "getrandom")]
pub fn new(bit_length: usize) -> Result {
from_rng(bit_length, &mut rand_core::OsRng)
}
#[cfg(feature = "getrandom")]
pub fn check(candidate: &num_bigint::BigUint) -> bool {
check_with(candidate, &mut rand_core::OsRng)
}
#[cfg(feature = "getrandom")]
pub fn strong_check(candidate: &num_bigint::BigUint) -> bool {
strong_check_with(candidate, &mut rand_core::OsRng)
}
#[cfg(test)]
mod tests {
use super::{check, new, strong_check};
#[test]
fn tests() {
for bits in &[128, 256, 512, 1024] {
let n = new(*bits).unwrap();
assert!(check(&n));
assert!(strong_check(&n));
}
}
}