pub fn modulo_power<T, U>(a: T, p: U, m: &T) -> T where
    T: Sized + One + for<'x> MulAssign<&'x T> + for<'x> From<<&'x T as Mul>::Output> + for<'x> From<<&'x T as Rem>::Output>,
    for<'x> &'x T: Mul + Rem,
    U: Sized + Zero + One + Eq + for<'x> ShrAssign<usize> + for<'x> From<<&'x U as BitAnd>::Output>,
    for<'x> &'x U: BitAnd
Expand description

calcurate $a^p \pmod{m}$

use ring_algorithm::modulo_power;
let a = 314i32;
let p = 271i32;
let m = 42;
assert_eq!(modulo_power(a, p, &m), 20);