Function montgomery

Source
fn montgomery(
    x: &BigUint,
    y: &BigUint,
    m: &BigUint,
    k: u64,
    n: usize,
) -> BigUint
Expand description

Computes z mod m = x * y * 2 ** (-n*_W) mod m assuming k = -1/m mod 2**_W See Gueron, “Efficient Software Implementations of Modular Exponentiation”. https://eprint.iacr.org/2011/239.pdf In the terminology of that paper, this is an “Almost Montgomery Multiplication”: x and y are required to satisfy 0 <= z < 2**(n*_W) and then the result z is guaranteed to satisfy 0 <= z < 2**(n*_W), but it may not be < m.