Function bulk_gcd::compute

source ·
pub fn compute(
    moduli: Vec<Integer>
) -> Result<Vec<Option<Integer>>, ComputeError>
Expand description

Bulk-compute GCD of each modulo in moduli vec with the product of all other moduli in the same list.

This is an implementation of algorithm by D. Bernstein.

See: this paper for more details.

Usage example:

extern crate bulk_gcd;
extern crate rug;

use rug::Integer;

let moduli = vec![
    Integer::from(15),
    Integer::from(35),
    Integer::from(23),
];

let result = bulk_gcd::compute(moduli).unwrap();

assert_eq!(result, vec![
    Some(Integer::from(5)),
    Some(Integer::from(5)),
    None,
]);