Skip to content

Commit 54d34b6

Browse files
committed
Merge #1300: Avoid normalize conditional on VERIFY
97c63b9 Avoid normalize conditional on VERIFY (Pieter Wuille) Pull request description: In the old code, `secp256k1_gej_rescale` requires a normalized input in VERIFY mode, but not otherwise. Its requirements shouldn't depend on this mode being enabled or not. ACKs for top commit: real-or-random: utACK 97c63b9 I've also verified that the loop in secp256k1_ecmult_strauss_wnaf holds up the invariant that the magnitude of Z is 1, even with the normalization removed jonasnick: ACK 97c63b9 Tree-SHA512: 9598c133c6f4e488c74512089dabe0508529f20ca782be1c8fbeae9d7f132da9d570a061053acd3d245a9a187abf1f2581207441ce6aac8d0f8972cf357a349f
2 parents c63ec88 + 97c63b9 commit 54d34b6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

src/ecmult_impl.h

-3
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,6 @@ static void secp256k1_ecmult_strauss_wnaf(const struct secp256k1_strauss_state *
279279
*/
280280
tmp = a[np];
281281
if (no) {
282-
#ifdef VERIFY
283-
secp256k1_fe_normalize_var(&Z);
284-
#endif
285282
secp256k1_gej_rescale(&tmp, &Z);
286283
}
287284
secp256k1_ecmult_odd_multiples_table(ECMULT_TABLE_SIZE(WINDOW_A), state->pre_a + no * ECMULT_TABLE_SIZE(WINDOW_A), state->aux + no * ECMULT_TABLE_SIZE(WINDOW_A), &Z, &tmp);

src/group_impl.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,9 @@ static void secp256k1_gej_rescale(secp256k1_gej *r, const secp256k1_fe *s) {
748748
secp256k1_fe zz;
749749
secp256k1_gej_verify(r);
750750
secp256k1_fe_verify(s);
751-
VERIFY_CHECK(!secp256k1_fe_is_zero(s));
751+
#ifdef VERIFY
752+
VERIFY_CHECK(!secp256k1_fe_normalizes_to_zero_var(s));
753+
#endif
752754
secp256k1_fe_sqr(&zz, s);
753755
secp256k1_fe_mul(&r->x, &r->x, &zz); /* r->x *= s^2 */
754756
secp256k1_fe_mul(&r->y, &r->y, &zz);

0 commit comments

Comments
 (0)