[][src]Function solovay_strassen::is_witness

pub fn is_witness<T: ToBigUint>(a: &T, n: &T) -> Option<bool>

Test whether an integer a is a witness for the compositeness of n.

NOTE: This function fails if a < 2 or n < 3.

Examples

extern crate rand;
use rand::distributions::{Distribution, Uniform};
use solovay_strassen::is_witness;

let n: u64 = 27;
let dist = Uniform::new(2, n);
let mut rng = rand::thread_rng();
// A random integer in [2..n]
let a: u64 = dist.sample(&mut rng);
assert!(is_witness(&a, &n).unwrap());