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 {
4141}
4242
4343/// Performs modular exponentiation using Montgomery's ladder.
44- /// `exponent_bits` represents the number of bits to take into account for the exponent.
4544///
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.
4748fn pow_montgomery_form (
4849 x : & BoxedUint ,
4950 exponent : & BoxedUint ,
@@ -110,9 +111,12 @@ fn pow_montgomery_form(
110111 }
111112 }
112113
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`
114115 // See RustCrypto/crypto-bigint#441
115116 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
116120 z. conditional_sbb_assign ( modulus, !z. ct_lt ( modulus) ) ;
117121 debug_assert ! ( & z < modulus) ;
118122
You can’t perform that action at this time.
0 commit comments