Skip to content

Commit 491414b

Browse files
real-or-randomnymius
authored andcommitted
musig: Use _ge_set_all_gej for own public nonces
1 parent 97c2d10 commit 491414b

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

src/modules/musig/session_impl.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,7 @@ static void secp256k1_nonce_function_musig(secp256k1_scalar *k, const unsigned c
395395
static int secp256k1_musig_nonce_gen_internal(const secp256k1_context* ctx, secp256k1_musig_secnonce *secnonce, secp256k1_musig_pubnonce *pubnonce, const unsigned char *input_nonce, const unsigned char *seckey, const secp256k1_pubkey *pubkey, const unsigned char *msg32, const secp256k1_musig_keyagg_cache *keyagg_cache, const unsigned char *extra_input32) {
396396
secp256k1_scalar k[2];
397397
secp256k1_ge nonce_pts[2];
398+
secp256k1_gej nonce_ptj[2];
398399
int i;
399400
unsigned char pk_ser[33];
400401
size_t pk_ser_len = sizeof(pk_ser);
@@ -445,13 +446,14 @@ static int secp256k1_musig_nonce_gen_internal(const secp256k1_context* ctx, secp
445446
secp256k1_musig_secnonce_invalidate(ctx, secnonce, !ret);
446447

447448
for (i = 0; i < 2; i++) {
448-
secp256k1_gej nonce_ptj;
449-
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &nonce_ptj, &k[i]);
450-
secp256k1_ge_set_gej(&nonce_pts[i], &nonce_ptj);
451-
secp256k1_declassify(ctx, &nonce_pts[i], sizeof(nonce_pts[i]));
449+
secp256k1_ecmult_gen(&ctx->ecmult_gen_ctx, &nonce_ptj[i], &k[i]);
452450
secp256k1_scalar_clear(&k[i]);
453451
secp256k1_gej_clear(&nonce_ptj);
454452
}
453+
secp256k1_ge_set_all_gej(nonce_pts, nonce_ptj, 2);
454+
for (i = 0; i < 2; i++) {
455+
secp256k1_declassify(ctx, &nonce_pts[i], sizeof(nonce_pts[i]));
456+
}
455457
/* None of the nonce_pts will be infinity because k != 0 with overwhelming
456458
* probability */
457459
secp256k1_musig_pubnonce_save(pubnonce, nonce_pts);

0 commit comments

Comments
 (0)