Trait modulo_n_tools::montgomery::MontgomeryOperation[][src]

pub trait MontgomeryOperation<T, U> {
    fn calc_n_prime(n: &T, s: u32) -> T;
fn new(n: T) -> Self;
fn reduction(&self, x: U) -> T;
fn convert(&self, x: T) -> T; fn powmod<V>(&self, a: T, p: V) -> T
    where
        T: From<u8>,
        U: Clone + for<'x> Mul<&'x U, Output = U> + From<T>,
        V: Clone + Ord + ShrAssign<u32> + From<u8> + for<'x> BitAnd<&'x V, Output = V>
, { ... } }
Expand description

Montgomery modular multiplication

use modulo_n_tools::montgomery::{MontgomeryOperation, Montgomery64};
let m = Montgomery64::new(97);
let a = m.powmod(2, 77);
assert_eq!(a, 65);

Required methods

$NN' \equiv -1 \pmod R$

Constructor for ${}\bmod N$

Montgomery Reduction

$x \mapsto xR \bmod N$

Provided methods

calcutate $a^p \bmod N$

Implementors