bigint::monty: simplify modpow zero test
This commit is contained in:
parent
96c4a26624
commit
b380880ed3
|
@ -1,5 +1,5 @@
|
||||||
use integer::Integer;
|
use integer::Integer;
|
||||||
use traits::{Zero, One};
|
use traits::Zero;
|
||||||
|
|
||||||
use biguint::BigUint;
|
use biguint::BigUint;
|
||||||
|
|
||||||
|
@ -116,8 +116,7 @@ pub fn monty_modpow(a: &BigUint, exp: &BigUint, modulus: &BigUint) -> BigUint{
|
||||||
// Binary exponentiation
|
// Binary exponentiation
|
||||||
let mut ans = &r % mr.p;
|
let mut ans = &r % mr.p;
|
||||||
let mut e = exp.clone();
|
let mut e = exp.clone();
|
||||||
let zero = Zero::zero();
|
while !e.is_zero() {
|
||||||
while e > zero {
|
|
||||||
if e.is_odd() {
|
if e.is_odd() {
|
||||||
ans = monty_mult(ans, &apri, &mr);
|
ans = monty_mult(ans, &apri, &mr);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue