bigint::monty: simplify redc return value

This commit is contained in:
Josh Stone 2017-10-22 15:36:33 -07:00
parent 5708db0f67
commit 7fa27b6007
1 changed files with 2 additions and 3 deletions

View File

@ -81,14 +81,13 @@ fn monty_redc(a: BigUint, mr: &MontyReducer) -> BigUint {
// 4: R <- C * β^(-n)
// This is an n-word bitshift, equivalent to skipping n words.
let r : Vec<u32> = c.iter().skip(n_size).cloned().collect();
let ret = BigUint::new(r);
let ret = BigUint::new(c[n_size..].to_vec());
// 5: if R >= β^n then return R-N else return R.
if &ret < mr.p {
ret
} else {
&ret-mr.p
ret - mr.p
}
}