bigint::monty: simplify modpow parameter init

This commit is contained in:
Josh Stone 2017-10-22 15:37:48 -07:00
parent 7fa27b6007
commit 96c4a26624
1 changed files with 3 additions and 4 deletions

View File

@ -106,10 +106,9 @@ pub fn monty_modpow(a: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint{
let mr = MontyReducer::new(modulus);
// Calculate the Montgomery parameter
let mut r : BigUint = One::one();
while &r < mr.p {
r = r << 32;
}
let mut v = vec![0; mr.p.data.len()];
v.push(1);
let r = BigUint::new(v);
// Map the base to the Montgomery domain
let mut apri = a * &r % mr.p;