From e491d06b98c9caa5eab74e38ba8419b9fb3b5015 Mon Sep 17 00:00:00 2001 From: Tim Ruffing Date: Thu, 28 Jan 2021 16:57:17 +0100 Subject: [PATCH] Use bit ops instead of int mult for constant-time logic in gej_add_ge --- src/group_impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/group_impl.h b/src/group_impl.h index 79177d7..b7094c5 100644 --- a/src/group_impl.h +++ b/src/group_impl.h @@ -591,7 +591,7 @@ static void secp256k1_gej_add_ge(secp256k1_gej *r, const secp256k1_gej *a, const secp256k1_fe_cmov(&n, &m, degenerate); /* n = M^3 * Malt (2) */ secp256k1_fe_sqr(&t, &rr_alt); /* t = Ralt^2 (1) */ secp256k1_fe_mul(&r->z, &a->z, &m_alt); /* r->z = Malt*Z (1) */ - infinity = secp256k1_fe_normalizes_to_zero(&r->z) * (1 - a->infinity); + infinity = secp256k1_fe_normalizes_to_zero(&r->z) & ~a->infinity; secp256k1_fe_mul_int(&r->z, 2); /* r->z = Z3 = 2*Malt*Z (2) */ secp256k1_fe_negate(&q, &q, 1); /* q = -Q (2) */ secp256k1_fe_add(&t, &q); /* t = Ralt^2-Q (3) */