We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5a0de14 commit 5708db0Copy full SHA for 5708db0
bigint/src/monty.rs
@@ -67,17 +67,16 @@ fn monty_redc(a: BigUint, mr: &MontyReducer) -> BigUint {
67
68
// β is the size of a word, in this case 32 bits. So "a mod β" is
69
// equivalent to masking a to 32 bits.
70
- let beta_mask = u32::max_value() as u64;
71
// mu <- -N^(-1) mod β
72
- let mu = (beta_mask-mr.n0inv as u64)+1;
+ let mu = 0u32.wrapping_sub(mr.n0inv);
73
74
// 1: for i = 0 to (n-1)
75
for i in 0..n_size {
76
// 2: q_i <- mu*c_i mod β
77
- let q_i = ((c[i] as u64) * mu) & beta_mask;
+ let q_i = c[i].wrapping_mul(mu);
78
79
// 3: C <- C + q_i * N * β^i
80
- super::algorithms::mac_digit(&mut c[i..], n, q_i as u32);
+ super::algorithms::mac_digit(&mut c[i..], n, q_i);
81
}
82
83
// 4: R <- C * β^(-n)
0 commit comments