Skip to content

Commit 36621d1

Browse files
committed
musig: update to BIP v1.0.0-rc.2 "Add ''pk'' arg to ''NonceGen''"
1 parent d717a49 commit 36621d1

File tree

5 files changed

+85
-65
lines changed

5 files changed

+85
-65
lines changed

examples/musig.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ int sign(const secp256k1_context* ctx, struct signer_secrets *signer_secrets, st
112112
}
113113
/* Initialize session and create secret nonce for signing and public
114114
* nonce to send to the other signers. */
115-
if (!secp256k1_musig_nonce_gen(ctx, &signer_secrets[i].secnonce, &signer[i].pubnonce, session_id, seckey, msg32, NULL, NULL)) {
115+
if (!secp256k1_musig_nonce_gen(ctx, &signer_secrets[i].secnonce, &signer[i].pubnonce, session_id, seckey, &signer[i].pubkey, msg32, NULL, NULL)) {
116116
return 0;
117117
}
118118
pubnonces[i] = &signer[i].pubnonce;

include/secp256k1_musig.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -357,6 +357,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_musig_pubkey_xonly_twea
357357
* unless you really know what you are doing.
358358
* seckey: the 32-byte secret key that will later be used for signing, if
359359
* already known (can be NULL)
360+
* pubkey: public key of the signer creating the nonce
360361
* msg32: the 32-byte message that will later be signed, if already known
361362
* (can be NULL)
362363
* keyagg_cache: pointer to the keyagg_cache that was used to create the aggregate
@@ -371,10 +372,11 @@ SECP256K1_API int secp256k1_musig_nonce_gen(
371372
secp256k1_musig_pubnonce *pubnonce,
372373
const unsigned char *session_id32,
373374
const unsigned char *seckey,
375+
const secp256k1_pubkey *pubkey,
374376
const unsigned char *msg32,
375377
const secp256k1_musig_keyagg_cache *keyagg_cache,
376378
const unsigned char *extra_input32
377-
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);
379+
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4) SECP256K1_ARG_NONNULL(6);
378380

379381
/** Aggregates the nonces of all signers into a single nonce
380382
*

src/modules/musig/session_impl.h

+27-19
Original file line numberDiff line numberDiff line change
@@ -291,36 +291,35 @@ static int secp256k1_xonly_ge_serialize(unsigned char *output32, secp256k1_ge *g
291291
}
292292

293293
/* Write optional inputs into the hash */
294-
static void secp256k1_nonce_function_musig_helper(secp256k1_sha256 *sha, unsigned int prefix_size, const unsigned char *data32) {
294+
static void secp256k1_nonce_function_musig_helper(secp256k1_sha256 *sha, unsigned int prefix_size, const unsigned char *data, unsigned char len) {
295295
unsigned char zero[7] = { 0 };
296296
/* The spec requires length prefixes to be between 1 and 8 bytes
297297
* (inclusive) */
298298
VERIFY_CHECK(prefix_size <= 8);
299-
/* Since the length of all input data is <= 32, we can always pad the length
300-
* prefix with prefix_size - 1 zero bytes. */
299+
/* Since the length of all input data fits in a byte, we can always pad the
300+
* length prefix with prefix_size - 1 zero bytes. */
301301
secp256k1_sha256_write(sha, zero, prefix_size - 1);
302-
if (data32 != NULL) {
303-
unsigned char len = 32;
302+
if (data != NULL) {
304303
secp256k1_sha256_write(sha, &len, 1);
305-
secp256k1_sha256_write(sha, data32, 32);
304+
secp256k1_sha256_write(sha, data, len);
306305
} else {
307-
unsigned char len = 0;
306+
len = 0;
308307
secp256k1_sha256_write(sha, &len, 1);
309308
}
310309
}
311310

312-
static void secp256k1_nonce_function_musig(secp256k1_scalar *k, const unsigned char *session_id, const unsigned char *msg32, const unsigned char *key32, const unsigned char *agg_pk32, const unsigned char *extra_input32) {
311+
static void secp256k1_nonce_function_musig(secp256k1_scalar *k, const unsigned char *session_id, const unsigned char *msg32, const unsigned char *seckey32, const unsigned char *pk33, const unsigned char *agg_pk32, const unsigned char *extra_input32) {
313312
secp256k1_sha256 sha;
314313
unsigned char rand[32];
315314
unsigned char i;
316315
unsigned char msg_present;
317316

318-
if (key32 != NULL) {
317+
if (seckey32 != NULL) {
319318
secp256k1_sha256_initialize_tagged(&sha, (unsigned char*)"MuSig/aux", sizeof("MuSig/aux") - 1);
320319
secp256k1_sha256_write(&sha, session_id, 32);
321320
secp256k1_sha256_finalize(&sha, rand);
322321
for (i = 0; i < 32; i++) {
323-
rand[i] ^= key32[i];
322+
rand[i] ^= seckey32[i];
324323
}
325324
} else {
326325
memcpy(rand, session_id, sizeof(rand));
@@ -329,13 +328,14 @@ static void secp256k1_nonce_function_musig(secp256k1_scalar *k, const unsigned c
329328
/* Subtract one from `sizeof` to avoid hashing the implicit null byte */
330329
secp256k1_sha256_initialize_tagged(&sha, (unsigned char*)"MuSig/nonce", sizeof("MuSig/nonce") - 1);
331330
secp256k1_sha256_write(&sha, rand, sizeof(rand));
332-
secp256k1_nonce_function_musig_helper(&sha, 1, agg_pk32);
331+
secp256k1_nonce_function_musig_helper(&sha, 1, pk33, 33);
332+
secp256k1_nonce_function_musig_helper(&sha, 1, agg_pk32, 32);
333333
msg_present = msg32 != NULL;
334334
secp256k1_sha256_write(&sha, &msg_present, 1);
335335
if (msg_present) {
336-
secp256k1_nonce_function_musig_helper(&sha, 8, msg32);
336+
secp256k1_nonce_function_musig_helper(&sha, 8, msg32, 32);
337337
}
338-
secp256k1_nonce_function_musig_helper(&sha, 4, extra_input32);
338+
secp256k1_nonce_function_musig_helper(&sha, 4, extra_input32, 32);
339339

340340
for (i = 0; i < 2; i++) {
341341
unsigned char buf[32];
@@ -346,13 +346,15 @@ static void secp256k1_nonce_function_musig(secp256k1_scalar *k, const unsigned c
346346
}
347347
}
348348

349-
int secp256k1_musig_nonce_gen(const secp256k1_context* ctx, secp256k1_musig_secnonce *secnonce, secp256k1_musig_pubnonce *pubnonce, const unsigned char *session_id32, const unsigned char *seckey, const unsigned char *msg32, const secp256k1_musig_keyagg_cache *keyagg_cache, const unsigned char *extra_input32) {
349+
int secp256k1_musig_nonce_gen(const secp256k1_context* ctx, secp256k1_musig_secnonce *secnonce, secp256k1_musig_pubnonce *pubnonce, const unsigned char *session_id32, const unsigned char *seckey, const secp256k1_pubkey *pubkey, const unsigned char *msg32, const secp256k1_musig_keyagg_cache *keyagg_cache, const unsigned char *extra_input32) {
350350
secp256k1_keyagg_cache_internal cache_i;
351351
secp256k1_scalar k[2];
352352
secp256k1_ge nonce_pt[2];
353353
int i;
354-
unsigned char pk_ser[32];
355-
unsigned char *pk_ser_ptr = NULL;
354+
unsigned char pk_ser[33];
355+
size_t pk_ser_len = sizeof(pk_ser);
356+
unsigned char aggpk_ser[32];
357+
unsigned char *aggpk_ser_ptr = NULL;
356358
int ret = 1;
357359

358360
VERIFY_CHECK(ctx != NULL);
@@ -361,6 +363,7 @@ int secp256k1_musig_nonce_gen(const secp256k1_context* ctx, secp256k1_musig_secn
361363
ARG_CHECK(pubnonce != NULL);
362364
memset(pubnonce, 0, sizeof(*pubnonce));
363365
ARG_CHECK(session_id32 != NULL);
366+
ARG_CHECK(pubkey != NULL);
364367
ARG_CHECK(secp256k1_ecmult_gen_context_is_built(&ctx->ecmult_gen_ctx));
365368
if (seckey == NULL) {
366369
/* Check in constant time that the session_id is not 0 as a
@@ -385,12 +388,17 @@ int secp256k1_musig_nonce_gen(const secp256k1_context* ctx, secp256k1_musig_secn
385388
if (!secp256k1_keyagg_cache_load(ctx, &cache_i, keyagg_cache)) {
386389
return 0;
387390
}
388-
ret_tmp = secp256k1_xonly_ge_serialize(pk_ser, &cache_i.pk);
391+
ret_tmp = secp256k1_xonly_ge_serialize(aggpk_ser, &cache_i.pk);
389392
/* Serialization can not fail because the loaded point can not be infinity. */
390393
VERIFY_CHECK(ret_tmp);
391-
pk_ser_ptr = pk_ser;
394+
aggpk_ser_ptr = aggpk_ser;
395+
}
396+
if (!secp256k1_ec_pubkey_serialize(ctx, pk_ser, &pk_ser_len, pubkey, SECP256K1_EC_COMPRESSED)) {
397+
return 0;
392398
}
393-
secp256k1_nonce_function_musig(k, session_id32, msg32, seckey, pk_ser_ptr, extra_input32);
399+
VERIFY_CHECK(pk_ser_len == sizeof(pk_ser));
400+
401+
secp256k1_nonce_function_musig(k, session_id32, msg32, seckey, pk_ser, aggpk_ser_ptr, extra_input32);
394402
VERIFY_CHECK(!secp256k1_scalar_is_zero(&k[0]));
395403
VERIFY_CHECK(!secp256k1_scalar_is_zero(&k[1]));
396404
VERIFY_CHECK(!secp256k1_scalar_eq(&k[0], &k[1]));

src/modules/musig/tests_impl.h

+53-43
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ void musig_simple_test(secp256k1_scratch_space *scratch) {
6464
partial_sig_ptr[i] = &partial_sig[i];
6565

6666
CHECK(create_keypair_and_pk(&keypair[i], &pk[i], sk[i]));
67-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce[i], &pubnonce[i], session_id[i], sk[i], NULL, NULL, NULL) == 1);
67+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce[i], &pubnonce[i], session_id[i], sk[i], &pk[i], NULL, NULL, NULL) == 1);
6868
}
6969

7070
CHECK(secp256k1_musig_pubkey_agg(ctx, scratch, &agg_pk, &keyagg_cache, pk_ptr, 2) == 1);
@@ -294,44 +294,48 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
294294

295295
/** Session creation **/
296296
ecount = 0;
297-
CHECK(secp256k1_musig_nonce_gen(none, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, &keyagg_cache, max64) == 1);
298-
CHECK(secp256k1_musig_nonce_gen(vrfy, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, &keyagg_cache, max64) == 1);
299-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, &keyagg_cache, max64) == 1);
297+
CHECK(secp256k1_musig_nonce_gen(none, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &keyagg_cache, max64) == 1);
298+
CHECK(secp256k1_musig_nonce_gen(vrfy, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &keyagg_cache, max64) == 1);
299+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &keyagg_cache, max64) == 1);
300300
CHECK(ecount == 0);
301-
CHECK(secp256k1_musig_nonce_gen(sttc, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, &keyagg_cache, max64) == 0);
301+
CHECK(secp256k1_musig_nonce_gen(sttc, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &keyagg_cache, max64) == 0);
302302
CHECK(ecount == 1);
303-
CHECK(secp256k1_musig_nonce_gen(sign, NULL, &pubnonce[0], session_id[0], sk[0], msg, &keyagg_cache, max64) == 0);
303+
CHECK(secp256k1_musig_nonce_gen(sign, NULL, &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &keyagg_cache, max64) == 0);
304304
CHECK(ecount == 2);
305-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], NULL, session_id[0], sk[0], msg, &keyagg_cache, max64) == 0);
305+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], NULL, session_id[0], sk[0], &pk[0], msg, &keyagg_cache, max64) == 0);
306306
CHECK(ecount == 3);
307-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], NULL, sk[0], msg, &keyagg_cache, max64) == 0);
307+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], NULL, sk[0], &pk[0], msg, &keyagg_cache, max64) == 0);
308308
CHECK(ecount == 4);
309309
CHECK(memcmp_and_randomize(secnonce[0].data, zeros68, sizeof(secnonce[0].data)) == 0);
310310
/* no seckey and session_id is 0 */
311-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], zeros68, NULL, msg, &keyagg_cache, max64) == 0);
311+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], zeros68, NULL, &pk[0], msg, &keyagg_cache, max64) == 0);
312312
CHECK(ecount == 4);
313313
CHECK(memcmp_and_randomize(secnonce[0].data, zeros68, sizeof(secnonce[0].data)) == 0);
314314
/* session_id 0 is fine when a seckey is provided */
315-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], zeros68, sk[0], msg, &keyagg_cache, max64) == 1);
316-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], NULL, msg, &keyagg_cache, max64) == 1);
315+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], zeros68, sk[0], &pk[0], msg, &keyagg_cache, max64) == 1);
316+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], NULL, &pk[0], msg, &keyagg_cache, max64) == 1);
317317
CHECK(ecount == 4);
318318
/* invalid seckey */
319-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], max64, msg, &keyagg_cache, max64) == 0);
319+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], max64, &pk[0], msg, &keyagg_cache, max64) == 0);
320320
CHECK(memcmp_and_randomize(secnonce[0].data, zeros68, sizeof(secnonce[0].data)) == 0);
321321
CHECK(ecount == 4);
322-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], NULL, &keyagg_cache, max64) == 1);
323-
CHECK(ecount == 4);
324-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, NULL, max64) == 1);
325-
CHECK(ecount == 4);
326-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, &invalid_keyagg_cache, max64) == 0);
322+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], NULL, msg, &keyagg_cache, max64) == 0);
327323
CHECK(ecount == 5);
324+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &invalid_pk, msg, &keyagg_cache, max64) == 0);
325+
CHECK(ecount == 6);
326+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], NULL, &keyagg_cache, max64) == 1);
327+
CHECK(ecount == 6);
328+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, NULL, max64) == 1);
329+
CHECK(ecount == 6);
330+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &invalid_keyagg_cache, max64) == 0);
331+
CHECK(ecount == 7);
328332
CHECK(memcmp_and_randomize(secnonce[0].data, zeros68, sizeof(secnonce[0].data)) == 0);
329-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], msg, &keyagg_cache, NULL) == 1);
330-
CHECK(ecount == 5);
333+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], sk[0], &pk[0], msg, &keyagg_cache, NULL) == 1);
334+
CHECK(ecount == 7);
331335

332-
/* Every in-argument except session_id can be NULL */
333-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], NULL, NULL, NULL, NULL) == 1);
334-
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[1], &pubnonce[1], session_id[1], sk[1], NULL, NULL, NULL) == 1);
336+
/* Every in-argument except session_id and pubkey can be NULL */
337+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[0], &pubnonce[0], session_id[0], NULL, &pk[0], NULL, NULL, NULL) == 1);
338+
CHECK(secp256k1_musig_nonce_gen(sign, &secnonce[1], &pubnonce[1], session_id[1], sk[1], &pk[1], NULL, NULL, NULL) == 1);
335339

336340
/** Serialize and parse public nonces **/
337341
ecount = 0;
@@ -608,25 +612,27 @@ void musig_api_tests(secp256k1_scratch_space *scratch) {
608612
void musig_nonce_bitflip(unsigned char **args, size_t n_flip, size_t n_bytes) {
609613
secp256k1_scalar k1[2], k2[2];
610614

611-
secp256k1_nonce_function_musig(k1, args[0], args[1], args[2], args[3], args[4]);
615+
secp256k1_nonce_function_musig(k1, args[0], args[1], args[2], args[3], args[4], args[5]);
612616
secp256k1_testrand_flip(args[n_flip], n_bytes);
613-
secp256k1_nonce_function_musig(k2, args[0], args[1], args[2], args[3], args[4]);
617+
secp256k1_nonce_function_musig(k2, args[0], args[1], args[2], args[3], args[4], args[5]);
614618
CHECK(secp256k1_scalar_eq(&k1[0], &k2[0]) == 0);
615619
CHECK(secp256k1_scalar_eq(&k1[1], &k2[1]) == 0);
616620
}
617621

618622
void musig_nonce_test(void) {
619-
unsigned char *args[5];
623+
unsigned char *args[6];
620624
unsigned char session_id[32];
621625
unsigned char sk[32];
626+
unsigned char pk[33];
622627
unsigned char msg[32];
623628
unsigned char agg_pk[32];
624629
unsigned char extra_input[32];
625630
int i, j;
626-
secp256k1_scalar k[5][2];
631+
secp256k1_scalar k[6][2];
627632

628633
secp256k1_testrand_bytes_test(session_id, sizeof(session_id));
629634
secp256k1_testrand_bytes_test(sk, sizeof(sk));
635+
secp256k1_testrand_bytes_test(pk, sizeof(pk));
630636
secp256k1_testrand_bytes_test(msg, sizeof(msg));
631637
secp256k1_testrand_bytes_test(agg_pk, sizeof(agg_pk));
632638
secp256k1_testrand_bytes_test(extra_input, sizeof(extra_input));
@@ -635,29 +641,33 @@ void musig_nonce_test(void) {
635641
args[0] = session_id;
636642
args[1] = msg;
637643
args[2] = sk;
638-
args[3] = agg_pk;
639-
args[4] = extra_input;
644+
args[3] = pk;
645+
args[4] = agg_pk;
646+
args[5] = extra_input;
640647
for (i = 0; i < count; i++) {
641648
musig_nonce_bitflip(args, 0, sizeof(session_id));
642649
musig_nonce_bitflip(args, 1, sizeof(msg));
643650
musig_nonce_bitflip(args, 2, sizeof(sk));
644-
musig_nonce_bitflip(args, 3, sizeof(agg_pk));
645-
musig_nonce_bitflip(args, 4, sizeof(extra_input));
651+
musig_nonce_bitflip(args, 3, sizeof(pk));
652+
musig_nonce_bitflip(args, 4, sizeof(agg_pk));
653+
musig_nonce_bitflip(args, 5, sizeof(extra_input));
646654
}
647655
/* Check that if any argument is NULL, a different nonce is produced than if
648656
* any other argument is NULL. */
649657
memcpy(msg, session_id, sizeof(msg));
650658
memcpy(sk, session_id, sizeof(sk));
659+
memcpy(pk, session_id, sizeof(session_id));
651660
memcpy(agg_pk, session_id, sizeof(agg_pk));
652661
memcpy(extra_input, session_id, sizeof(extra_input));
653-
secp256k1_nonce_function_musig(k[0], args[0], args[1], args[2], args[3], args[4]);
654-
secp256k1_nonce_function_musig(k[1], args[0], NULL, args[2], args[3], args[4]);
655-
secp256k1_nonce_function_musig(k[2], args[0], args[1], NULL, args[3], args[4]);
656-
secp256k1_nonce_function_musig(k[3], args[0], args[1], args[2], NULL, args[4]);
657-
secp256k1_nonce_function_musig(k[4], args[0], args[1], args[2], args[3], NULL);
658-
for (i = 0; i < 5; i++) {
662+
secp256k1_nonce_function_musig(k[0], args[0], args[1], args[2], args[3], args[4], args[5]);
663+
secp256k1_nonce_function_musig(k[1], args[0], NULL, args[2], args[3], args[4], args[5]);
664+
secp256k1_nonce_function_musig(k[2], args[0], args[1], NULL, args[3], args[4], args[5]);
665+
secp256k1_nonce_function_musig(k[3], args[0], args[1], args[2], NULL, args[4], args[5]);
666+
secp256k1_nonce_function_musig(k[4], args[0], args[1], args[2], args[3], NULL, args[5]);
667+
secp256k1_nonce_function_musig(k[5], args[0], args[1], args[2], args[3], args[4], NULL);
668+
for (i = 0; i < 6; i++) {
659669
CHECK(!secp256k1_scalar_eq(&k[i][0], &k[i][1]));
660-
for (j = i+1; j < 5; j++) {
670+
for (j = i+1; j < 6; j++) {
661671
CHECK(!secp256k1_scalar_eq(&k[i][0], &k[j][0]));
662672
CHECK(!secp256k1_scalar_eq(&k[i][1], &k[j][1]));
663673
}
@@ -729,10 +739,10 @@ void scriptless_atomic_swap(secp256k1_scratch_space *scratch) {
729739
CHECK(secp256k1_musig_pubkey_agg(ctx, scratch, &agg_pk_a, &keyagg_cache_a, pk_a_ptr, 2) == 1);
730740
CHECK(secp256k1_musig_pubkey_agg(ctx, scratch, &agg_pk_b, &keyagg_cache_b, pk_b_ptr, 2) == 1);
731741

732-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_a[0], &pubnonce_a[0], seed_a[0], sk_a[0], NULL, NULL, NULL) == 1);
733-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_a[1], &pubnonce_a[1], seed_a[1], sk_a[1], NULL, NULL, NULL) == 1);
734-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_b[0], &pubnonce_b[0], seed_b[0], sk_b[0], NULL, NULL, NULL) == 1);
735-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_b[1], &pubnonce_b[1], seed_b[1], sk_b[1], NULL, NULL, NULL) == 1);
742+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_a[0], &pubnonce_a[0], seed_a[0], sk_a[0], &pk_a[0], NULL, NULL, NULL) == 1);
743+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_a[1], &pubnonce_a[1], seed_a[1], sk_a[1], &pk_b[1], NULL, NULL, NULL) == 1);
744+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_b[0], &pubnonce_b[0], seed_b[0], sk_b[0], &pk_b[0], NULL, NULL, NULL) == 1);
745+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce_b[1], &pubnonce_b[1], seed_b[1], sk_b[1], &pk_b[1], NULL, NULL, NULL) == 1);
736746

737747
/* Step 2: Exchange nonces */
738748
CHECK(secp256k1_musig_nonce_agg(ctx, &aggnonce_a, pubnonce_ptr_a, 2) == 1);
@@ -840,8 +850,8 @@ void musig_tweak_test_helper(const secp256k1_xonly_pubkey* agg_pk, const unsigne
840850
CHECK(create_keypair_and_pk(&keypair[1], &pk[1], sk1) == 1);
841851
secp256k1_testrand256(msg);
842852

843-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce[0], &pubnonce[0], session_id[0], sk0, NULL, NULL, NULL) == 1);
844-
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce[1], &pubnonce[1], session_id[1], sk1, NULL, NULL, NULL) == 1);
853+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce[0], &pubnonce[0], session_id[0], sk0, &pk[0], NULL, NULL, NULL) == 1);
854+
CHECK(secp256k1_musig_nonce_gen(ctx, &secnonce[1], &pubnonce[1], session_id[1], sk1, &pk[1], NULL, NULL, NULL) == 1);
845855

846856
CHECK(secp256k1_musig_nonce_agg(ctx, &aggnonce, pubnonce_ptr, 2) == 1);
847857
CHECK(secp256k1_musig_nonce_process(ctx, &session, &aggnonce, msg, keyagg_cache, NULL) == 1);

0 commit comments

Comments
 (0)