Skip to content

Commit 10c46ec

Browse files
committed
musig: Invalidate secnonce in partial_sign
Replace memset which can be optimized out.
1 parent f36afb8 commit 10c46ec

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/modules/musig/session_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -677,9 +677,9 @@ int secp256k1_musig_partial_sign(const secp256k1_context* ctx, secp256k1_musig_p
677677
ARG_CHECK(secnonce != NULL);
678678
/* Fails if the magic doesn't match */
679679
ret = secp256k1_musig_secnonce_load(ctx, k, &pk, secnonce);
680-
/* Set nonce to zero to avoid nonce reuse. This will cause subsequent calls
681-
* of this function to fail */
682-
memset(secnonce, 0, sizeof(*secnonce));
680+
/* Clear and invalidate nonce to avoid nonce reuse. This will cause subsequent
681+
* calls of this function to fail */
682+
secp256k1_musig_secnonce_invalidate(ctx, secnonce, 1);
683683
if (!ret) {
684684
secp256k1_musig_partial_sign_clear(&sk, k);
685685
return 0;

0 commit comments

Comments
 (0)