Skip to content

Add MuSig2 adaptor sig exercise in example code - #188

Open
instagibbs wants to merge 1 commit into
BlockstreamResearch:masterfrom
instagibbs:musig_adaptor_example
Open

Add MuSig2 adaptor sig exercise in example code#188
instagibbs wants to merge 1 commit into
BlockstreamResearch:masterfrom
instagibbs:musig_adaptor_example

Conversation

@instagibbs

Copy link
Copy Markdown
Contributor

Code examples are clearer than doc explanations in a few ways, so figured I'd just submit this.

@rage-proof

Copy link
Copy Markdown

I would like to see in the example secp256k1_musig_extract_adaptor, so to verify that the input and output secret-adaptor are identical.

@instagibbs
instagibbs force-pushed the musig_adaptor_example branch from 427ca95 to e502240 Compare February 27, 2023 16:09
@instagibbs

Copy link
Copy Markdown
Contributor Author

@rage-proof year late, but I came back around to the API and would have found it useful so done.

@real-or-random real-or-random left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Concept ACK

I wonder if this example should go to a separate function. Adaptors add quite a lot to the flow and increase the brain power necessary to follow this example, so this is probably confusing for users who want to see a minimal example. If that means duplicating some of the code, this is not a problem, I think.

Comment thread examples/musig.c Outdated
if (!secp256k1_musig_adapt(ctx, sig64, presig, adaptor_key, nonce_parity)) {
return 0;
}
/* With sig64 "on-chain" now, other party can grab the revealed adaptor secret */

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
/* With sig64 "on-chain" now, other party can grab the revealed adaptor secret */
/* With sig64 "on-chain" now, other party can grab the revealed adaptor secret */

wrong indentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed tabs

Comment thread examples/musig.c Outdated
if (!secp256k1_musig_nonce_parity(ctx, &nonce_parity, &session)) {
return 0;
}
if (!secp256k1_musig_partial_sig_agg(ctx, presig, &session, partial_sigs, N_SIGNERS)){

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (!secp256k1_musig_partial_sig_agg(ctx, presig, &session, partial_sigs, N_SIGNERS)){
if (!secp256k1_musig_partial_sig_agg(ctx, presig, &session, partial_sigs, N_SIGNERS)) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread examples/musig.c Outdated
if (!secp256k1_musig_extract_adaptor(ctx, extracted_adaptor, sig64, presig, nonce_parity)) {
return 0;
}
if (memcmp(extracted_adaptor, adaptor_key, sizeof(adaptor_key)) != 0) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you assert this? We normally use assert for these comparisons in the other examples.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Comment thread examples/musig.c Outdated
}
printf("ok\n");
printf("Verifying signature.....");
printf("Verifying signature and revealed adaptor.....");

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we're verifying the adaptor here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

errr extracting revealed secret, I guess is the phrase?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm only saying that the printf not match the code below, which still only verifies a sig.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, I added this in the wrong spot

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

removed

@instagibbs
instagibbs force-pushed the musig_adaptor_example branch from e502240 to 94ab85b Compare October 28, 2025 14:11
@instagibbs

instagibbs commented Oct 28, 2025

Copy link
Copy Markdown
Contributor Author

a bit of renewed interest in adaptor sigs, so rebased this

granted, this is likely not synced with upstream...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants