File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed
src/modular/boxed_monty_form Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -41,9 +41,10 @@ impl PowBoundedExp<BoxedUint> for BoxedMontyForm {
41
41
}
42
42
43
43
/// Performs modular exponentiation using Montgomery's ladder.
44
- /// `exponent_bits` represents the number of bits to take into account for the exponent.
45
44
///
46
- /// NOTE: this value is leaked in the time pattern.
45
+ /// `exponent_bits` represents the length of the exponent in bits.
46
+ ///
47
+ /// NOTE: `exponent_bits` is leaked in the time pattern.
47
48
fn pow_montgomery_form (
48
49
x : & BoxedUint ,
49
50
exponent : & BoxedUint ,
@@ -110,9 +111,12 @@ fn pow_montgomery_form(
110
111
}
111
112
}
112
113
113
- // Ensure output is fully reduced ( AMM only reduces to the bit length of the modulus)
114
+ // Ensure output is properly reduced: AMM only reduces to the bit length of ` modulus`
114
115
// See RustCrypto/crypto-bigint#441
115
116
z. conditional_sbb_assign ( modulus, !z. ct_lt ( modulus) ) ;
117
+
118
+ // Subtract again to ensure output is fully reduced
119
+ // See RustCrypto/crypto-bigint#455 and golang.org/issue/13907
116
120
z. conditional_sbb_assign ( modulus, !z. ct_lt ( modulus) ) ;
117
121
debug_assert ! ( & z < modulus) ;
118
122
You can’t perform that action at this time.
0 commit comments