Skip to content

Commit 6078d4b

Browse files
committed
Declassify non-secrets to fix constant time tests
1 parent 443f88d commit 6078d4b

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/modules/frost/keygen_impl.h

+5
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ static void secp256k1_frost_share_save(secp256k1_frost_share* share, secp256k1_s
6363
static int secp256k1_frost_share_load(const secp256k1_context* ctx, secp256k1_scalar *s, const secp256k1_frost_share* share) {
6464
int overflow;
6565

66+
/* The magic is non-secret so it can be declassified to allow branching. */
67+
secp256k1_declassify(ctx, &share->data[0], 4);
6668
ARG_CHECK(secp256k1_memcmp_var(&share->data[0], secp256k1_frost_share_magic, 4) == 0);
6769
secp256k1_scalar_set_b32(s, &share->data[4], &overflow);
6870
/* Parsed shares cannot overflow */
@@ -152,6 +154,9 @@ int secp256k1_frost_shares_trusted_gen(const secp256k1_context *ctx, secp256k1_f
152154
/* Compute commitment to constant term */
153155
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &rj, &coeff_i);
154156
secp256k1_ge_set_gej(&rp, &rj);
157+
/* The commitment is non-secret so it can be declassified to
158+
* allow branching. */
159+
secp256k1_declassify(ctx, &rp, sizeof(rp));
155160
secp256k1_fe_normalize_var(&rp.y);
156161
pk_parity = secp256k1_extrakeys_ge_even_y(&rp);
157162
secp256k1_xonly_pubkey_save(pk, &rp);

0 commit comments

Comments
 (0)