Skip to content

Commit e3ca4b7

Browse files
committed
fixup! check that secnonces are nonzero during load
1 parent 506fe81 commit e3ca4b7

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/modules/musig/session_impl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,15 @@ static void secp256k1_musig_secnonce_save(secp256k1_musig_secnonce *secnonce, se
2929
}
3030

3131
static int secp256k1_musig_secnonce_load(const secp256k1_context* ctx, secp256k1_scalar *k, secp256k1_musig_secnonce *secnonce) {
32+
int is_zero;
3233
ARG_CHECK(secp256k1_memcmp_var(&secnonce->data[0], secp256k1_musig_secnonce_magic, 4) == 0);
3334
secp256k1_scalar_set_b32(&k[0], &secnonce->data[4], NULL);
3435
secp256k1_scalar_set_b32(&k[1], &secnonce->data[36], NULL);
36+
/* We make very sure that the nonce isn't invalidated by checking the values
37+
* in addition to the magic. */
38+
is_zero = secp256k1_scalar_is_zero(&k[0]) & secp256k1_scalar_is_zero(&k[1]);
39+
secp256k1_declassify(ctx, &is_zero, sizeof(is_zero));
40+
ARG_CHECK(!is_zero);
3541
return 1;
3642
}
3743

0 commit comments

Comments
 (0)