BIP Draft: NestedMuSig2 for BIP340-compatible Signatures #2297

pull BEULAHEVANJALIN wants to merge 5 commits into bitcoin:master from BEULAHEVANJALIN:nested-musig changing 20 files +5789 −0
  1. BEULAHEVANJALIN commented at 9:02 AM on September 21, 2026: none

    This PR proposes NestedMuSig2 for BIP340-compatible Signatures, a BIP draft extending BIP327 MuSig2 to support trees of nested signing groups. Each subgroup participates through its aggregate public key, and the complete tree produces a single BIP340 signature verifiable without knowledge of the internal structure.

    The proposal includes the specification, a Python reference implementation, and test vectors covering nested key and nonce aggregation, signing, partial-signature verification, signature aggregation, and error handling. Multi-level examples and randomized tree tests accompany the vectors.

    Review is particularly welcome on recursive nonce binding, signer session construction, root tweaks, and compatibility with BIP327 in the flat case. The construction remains n-of-n at each aggregation node.

  2. Add BIP draft for nested MuSig2 with reference implementation and test vectors b3b0aa240e
  3. murchandamus added the label New BIP on Sep 21, 2026
  4. murchandamus renamed this:
    Add BIP draft for nested MuSig2 with reference implementation and tes…
    BIP Draft: NestedMuSig2 for BIP340-compatible Signatures
    on Sep 21, 2026
  5. murchandamus commented at 8:27 PM on September 22, 2026: member

    Hi Beulah, thank you for your submission. At first glance your document makes a great impression. I just wanted to let you know that I have seen it, but I will only get around to giving it a full read in a few weeks. I hope some other people will chime in with review here meanwhile.

  6. edilmedeiros commented at 9:15 PM on September 27, 2026: contributor
  7. patrickdugan commented at 11:55 AM on October 9, 2026: none

    Congratulations on your hard work and reaching this milestone!

    I ran a few million tokens over your BIP and got these findings and fixes:

    https://github.com/patrickdugan/bips/blob/nested-musig2-review/nested-musig2-review/FINDINGS.md

    https://github.com/BEULAHEVANJALIN/bips/pull/1

  8. Clarify X-only key encoding in Nested MuSig2 nonce binding docs 4523ee0eed
  9. BEULAHEVANJALIN commented at 6:50 AM on October 15, 2026: none

    @patrickdugan addressing F1. Fixed the inconsistent wording in 4523ee0. I’ve kept the 32-byte xbytes(pubkey) hash input, following BIP327’s convention.

  10. in bip-nested-musig2.mediawiki:153 in 4523ee0eed outdated
     148 | +The root aggregation node uses the same key-aggregation procedure as every other node. Let ''L<sub>0</sub>'' be the sorted list of root-level participant plain public keys. The untweaked root KeyAgg Context is ''keyagg_ctx<sub>0</sub> = KeyAgg(L<sub>0</sub>)''. Without aggregate-key tweaks, the root aggregate public key used for BIP340 verification is ''aggpk = GetXonlyPubkey(keyagg_ctx<sub>0</sub>)''.
     149 | +
     150 | +====Aggregate-Key Tweaking====
     151 | +
     152 | +The Nested MuSig2 construction referenced by this specification does not define aggregate-key tweaking. This specification also supports the BIP327 aggregate-key tweaking mechanism only at the root aggregation node. If the application specifies root-level aggregate-key tweaks, it MUST apply them sequentially to ''keyagg_ctx<sub>0</sub>'' using BIP327 ''ApplyTweak''. Any participants who act as an aggregator at the root level MUST use the same ordered tweak sequence and the same ''is_xonly_t'' value for each tweak. For tweaks ''tweak<sub>1</sub>, ..., tweak<sub>v</sub>'', let ''keyagg_ctx<sub>0,0</sub> = keyagg_ctx<sub>0</sub>'' and, for ''i = 1, ..., v'', ''keyagg_ctx<sub>0,i</sub> = ApplyTweak(keyagg_ctx<sub>0,i−1</sub>, tweak<sub>i</sub>, is_xonly_t<sub>i</sub>)''. Fail if any invocation of ''ApplyTweak'' fails according to BIP327.
     153 | +
    


    IsaqueFranklin commented at 10:26 PM on November 9, 2026:

    This specification also supports the BIP327 aggregate-key tweaking mechanism only at the root aggregation node.

    I saw the explanation in the rationale about it. Is this just to simplify the specification, or is there a deeper cryptographic assumption/problem?


    BEULAHEVANJALIN commented at 10:26 AM on November 21, 2026:

    This is just a simplification. If a non-root level aggregator is allowed to tweak then key aggregation and partialsig aggregation gets complicated.

  11. in bip-nested-musig2.mediawiki:284 in 4523ee0eed outdated
     279 | +* Let ''(Q, gacc, tacc) = keyagg_ctx''.
     280 | +* Let ''b<sub>0</sub> = int(hash<sub>MuSig/noncecoef</sub>(nonce_path[0] || xbytes(Q) || m)) mod n''.
     281 | +* Let ''R'<sub>1</sub> = cpoint_ext(nonce_path[0][0:33])''; if that fails, fail.
     282 | +* Let ''R'<sub>2</sub> = cpoint_ext(nonce_path[0][33:66])''; if that fails, fail.
     283 | +* Let ''R' = R'<sub>1</sub> + b<sub>0</sub>⋅R'<sub>2</sub>''.
     284 | +* If ''R''' is the point at infinity, let ''R = G''. Otherwise, let ''R = R'''.
    


    IsaqueFranklin commented at 6:01 PM on November 18, 2026:

    I believe this should be "If $R'$ is the point at infinity, let $R=G$. Otherwise, let $R=R'$." I believe this is a formatting issue. The mediawiki file clearly shows $R'$, but the rendered text on github shows $R$.


  12. danielabrozzoni commented at 6:23 PM on November 18, 2026: member

    I'm unfortunately not knowledgeable enough to fully review this, but the structure looks good, and the introduction section is well written and understandable :)

    I think you should submit the proposal to the mailing list to receive more feedback, and add the "Discussion:" link to the preamble, as specified in BIP3 (https://github.com/bitcoin/bips/blob/master/bip-0003.md#overview)

  13. in bip-nested-musig2.mediawiki:89 in 4523ee0eed outdated
      84 | +* ''b<sub>0</sub>'' is the root nonce-binding factor computed according to BIP327 from ''out<sub>0</sub>'', the final root X-only aggregate public key, and the message. If root-level aggregate-key tweaks are applied, use the public key after those tweaks.<br>''b<sub>0</sub>'' is the only nonce-binding factor that commits directly to the message.
      85 | +* ''b&#780;'' is the accumulated nonce-binding factor ''b&#780; = b<sub>0</sub>·b<sub>1</sub>·...·b<sub>&Lambda;−1</sub> mod n''.<br>Because this specification uses the BIP327 two-nonce construction, ''b&#780;'' is the coefficient multiplying the leaf signer's second secret nonce in its nested partial-signature equation.
      86 | +* ''c'' is the BIP340 challenge ''c = int(hash<sub>BIP0340/challenge</sub>(xbytes(R) || xbytes(Q) || m)) mod n'', where ''Q'' is the final root aggregate public key and ''R'' is the final effective nonce point.
      87 | +* ''c&#780;'' is the accumulated challenge coefficient ''c&#780; = c·a<sub>0</sub>·a<sub>1</sub>·...·a<sub>&Lambda;−1</sub> mod n''. It is the coefficient multiplying the leaf signer's secret-key contribution.
      88 | +* Let ''out<sub>0</sub> = cbytes_ext(R<sub>1,0</sub>) || cbytes_ext(R<sub>2,0</sub>)''. Compute ''R' = R<sub>1,0</sub> + b<sub>0</sub>·R<sub>2,0</sub>''.<br>If ''R'' is the point at infinity, let ''R = G''; otherwise, let ''R = R''. This is the unchanged BIP327 root effective-nonce rule.<br>Intermediate binding factors do not appear explicitly in this root expression because they have already been incorporated into nested nonce contributions by preceding invocations of ''NonceAggExt''.
      89 | +
    


    IsaqueFranklin commented at 6:43 PM on November 18, 2026:

    I think the infinity check here should refer to $R'$, rather than $R$.

    If R is the point at infinity, let $R = G$; otherwise, let $R = R$.

    Since $R'$ is the actual value computed, the point at infinity check should be performed on $R'$. And if so, $R=G$, otherwise $R=R'$.


  14. IsaqueFranklin commented at 7:17 PM on November 18, 2026: none

    I've finished a first reading, and overall I think the text looks pretty solid. Nice work! Next, I'm planning to take a closer look at the main algorithms over the next few weeks.

    I just think it's missing a general overview section, just like the one in BIP 327, especially the sub-section there about general signing flow. I think this would be a nice-to-have considering that most people reading this BIP won't read the paper, so a general introduction (without getting into much detail) just to build some context before the specification would be interesting.

  15. in bip-nested-musig2.mediawiki:8 in 4523ee0eed outdated
       0 | @@ -0,0 +1,827 @@
       1 | +<pre>
       2 | +  BIP: ?
       3 | +  Title: NestedMuSig2 for BIP340-compatible Signatures
       4 | +  Authors: Beulah Evanjalin <beulahebenezer777@gmail.com>
       5 | +  Status: Draft
       6 | +  Type: Specification
       7 | +  Assigned: ?
       8 | +  License: BSD-3-Clause
    


    jonatack commented at 10:06 PM on November 19, 2026:

    Per BIP 3, please add a Discussion: 2026-11-19: https://groups.google.com/g/bitcoindev/c/eSgxP8NmEnA/m/oSxrtE9jAQAJ header on the line after License.


  16. in bip-nested-musig2.mediawiki:611 in 4523ee0eed outdated
     606 | +
     607 | +Implementers are encouraged to reproduce the test vectors independently rather than treating the Python implementation as an independent proof of the specification.
     608 | +
     609 | +==Security Considerations==
     610 | +
     611 | +NestedMuSig2 is an interactive multi-signature protocol. Its security depends on correct nonce handling, correct recursive computation of key and nonce coefficients, consistent session state, and faithful implementation of the algorithms specified in this document. The security considerations of BIP327 apply in addition to the NestedMuSig2-specific considerations described below.
    


    jonatack commented at 10:10 PM on November 19, 2026:

    Should there be anything in this section about depth bounds / instantiation choices?


    BEULAHEVANJALIN commented at 5:20 PM on November 23, 2026:
  17. jonatack commented at 10:21 PM on November 19, 2026: member

    Concept ACK. The main gap here was the mailing-list discussion (normally required prior to opening a PR here; see this repo's README and BIP 3) and addressing outstanding review feedback (thank you @IsaqueFranklin!)

    Ran the tests locally.

    it's missing a general overview section, just like the one in BIP 327, especially the sub-section there about general signing flow. I think this would be a nice-to-have considering that most people reading this BIP won't read the paper, so a general introduction (without getting into much detail) just to build some context before the specification would be interesting.

    Agree.

  18. Added discussion and overview sections 46c1dbe28f
  19. jonatack added the label PR Author action required on Nov 20, 2026
  20. specify the security considerations for nesting depth cd4a96668b
  21. BEULAHEVANJALIN commented at 5:26 PM on November 23, 2026: none

    Congratulations on your hard work and reaching this milestone!

    I ran a few million tokens over your BIP and got these findings and fixes:

    https://github.com/patrickdugan/bips/blob/nested-musig2-review/nested-musig2-review/FINDINGS.md

    BEULAHEVANJALIN#1 @patrickdugan, I have acknowledged the concerns of F2 here https://github.com/bitcoin/bips/pull/2297/changes/cd4a96668bb3cca1bdfa63fc0bfc12151a43392f

  22. BEULAHEVANJALIN commented at 5:28 PM on November 23, 2026: none

    I've finished a first reading, and overall I think the text looks pretty solid. Nice work! Next, I'm planning to take a closer look at the main algorithms over the next few weeks.

    I just think it's missing a general overview section, just like the one in BIP 327, especially the sub-section there about general signing flow. I think this would be a nice-to-have considering that most people reading this BIP won't read the paper, so a general introduction (without getting into much detail) just to build some context before the specification would be interesting. @IsaqueFranklin, I have added overview section in this commit https://github.com/bitcoin/bips/pull/2297/commits/46c1dbe28fc0815df8ea1c9f57b4b9778e5d7c6a

  23. formatting c0a867d827
  24. patrickdugan referenced this in commit 1158af06db on Nov 24, 2026
  25. patrickdugan commented at 6:11 AM on November 24, 2026: none

    Thanks for 4523ee0 and cd4a966: F1 is resolved (one AggNonceCoeffHash, text and reference agree) and the new security section covers most of F2.

    Did an additional Mythos pass for your consideration:

    https://github.com/patrickdugan/bips/blob/nested-musig2-review/nested-musig2-review/SECOND-PASS-c0a867d.md

    https://github.com/patrickdugan/bips/commit/1158af06db88831e1911a98de2e80d8657171760

    1. The R' fix did not land. GetSessionValues now reads "Let R = R'1 + b0·R'2 / If R is the point at infinity, let R = G. Otherwise, let R = R" and renders as one bold run; the Notation line and the "Points at Infinity" paragraph have the same problem. BIP327's own three lines (Let ''R' = …'', If ''is_infinite(R'):, Let final nonce ''R = R' '') render correctly and can be copied.
    2. Sign calls PartialSigVerifyInternal, which the document never defines; GetSessionValues returns 6 values and its two callers destructure 7.
    3. The Overview says the reference supports all optional features, but schnorr_verify in reference.py rejects messages that are not 32 bytes.
    4. "Preferably D of 2 to 4": the text and footnote 2 give reasons for 2 and none for 4. Could you state Theorem 2's bound as a function of D, or recommend D ≤ 2?
    5. Still open from the first pass and untouched (reference and tests are byte-identical to b3b0aa2): F3 (the bip327-tests vectors are regenerated for sorted key lists), F4 (sign consumes the secnonce after get_session_values), F5 (reference vs text).

    I can rebase my fix PR onto c0a867d without the 33-byte commit if that is useful.

  26. Dunlap28 commented at 6:25 AM on November 24, 2026: none

    so you saying my assets that ruan down the chain to land here they are gone?

    On Tue, Nov 24, 2026 at 12:15 AM Patrick Dugan @.***> wrote:

    patrickdugan left a comment (bitcoin/bips#2297) https://github.com/bitcoin/bips/pull/2297#issuecomment-7123680222

    Thanks for 4523ee0 https://github.com/bitcoin/bips/commit/4523ee0eed72f2367a1d1774941f70b2aca5af43 and cd4a966 https://github.com/bitcoin/bips/commit/cd4a96668bb3cca1bdfa63fc0bfc12151a43392f: F1 is resolved (one AggNonceCoeffHash, text and reference agree) and the new security section covers most of F2.

    Did an additional Mythos pass for your consideration:

    https://github.com/patrickdugan/bips/blob/nested-musig2-review/nested-musig2-review/SECOND-PASS-c0a867d.md

    @.*** https://github.com/patrickdugan/bips/commit/1158af06db88831e1911a98de2e80d8657171760

    1. The R' fix did not land. GetSessionValues now reads "Let R = R'1 + b0·R'2 / If R is the point at infinity, let R = G. Otherwise, let R = R" and renders as one bold run; the Notation line and the "Points at Infinity" paragraph have the same problem. BIP327's own three lines (Let ''R' = …'', If ''is_infinite(R'):, Let final nonce ''R = R' '') render correctly and can be copied.
    2. Sign calls PartialSigVerifyInternal, which the document never defines; GetSessionValues returns 6 values and its two callers destructure 7.
    3. The Overview says the reference supports all optional features, but schnorr_verify in reference.py rejects messages that are not 32 bytes.
    4. "Preferably D of 2 to 4": the text and footnote 2 give reasons for 2 and none for 4. Could you state Theorem 2's bound as a function of D, or recommend D ≤ 2?
    5. Still open from the first pass and untouched (reference and tests are byte-identical to b3b0aa2 https://github.com/bitcoin/bips/commit/b3b0aa240ee4ee9d5ccc2de480cfe74a3018b02d): F3 (the bip327-tests vectors are regenerated for sorted key lists), F4 (sign consumes the secnonce after get_session_values), F5 (reference vs text).

    I can rebase my fix PR onto c0a867d https://github.com/bitcoin/bips/commit/c0a867d8278921342e7603d70af25c10542da606 without the 33-byte commit if that is useful.

    — Reply to this email directly, view it on GitHub https://github.com/bitcoin/bips/pull/2297?email_source=notifications&email_token=AT2NF6J4RVIQBUXSKRFUMDT52URONA5CNFSNUABFM5UWIORPF5TWS5BNNB2WEL2JONZXKZKDN5WW2ZLOOQXTOMJSGM3DQMBSGIZKM4TFMFZW63VKON2WE43DOJUWEZLEUVSXMZLOOSWGM33PORSXEX3DNRUWG2Y#issuecomment-7123680222, or unsubscribe https://github.com/notifications/unsubscribe-auth/AT2NF6ITK5DS7JWVRRD76YL52URONAVCNFSNUABEKJSXA33TNF2G64TZHMYTINJTGE3TGNZ3JFZXG5LFHM2TKMRUHA4DQOJWGKQXMAQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

  27. BEULAHEVANJALIN commented at 5:38 PM on November 24, 2026: none

    Thanks for 4523ee0 and cd4a966: F1 is resolved (one AggNonceCoeffHash, text and reference agree) and the new security section covers most of F2.

    Did an additional Mythos pass for your consideration:

    https://github.com/patrickdugan/bips/blob/nested-musig2-review/nested-musig2-review/SECOND-PASS-c0a867d.md

    patrickdugan@1158af0

    1. The `R'` fix did not land. `GetSessionValues` now reads "Let R = R'1 + b0·R'2 / If R is the point at infinity, let R = G. Otherwise, let R = R" and renders as one bold run; the Notation line and the "Points at Infinity" paragraph have the same problem. BIP327's own three lines (`Let ''R' = …''`, `If ''is_infinite(R'):`, `Let final nonce ''R = R' ''`) render correctly and can be copied.
    
    2. `Sign` calls `PartialSigVerifyInternal`, which the document never defines; `GetSessionValues` returns 6 values and its two callers destructure 7.
    
    3. The Overview says the reference supports all optional features, but `schnorr_verify` in `reference.py` rejects messages that are not 32 bytes.
    
    4. "Preferably D of 2 to 4": the text and footnote 2 give reasons for 2 and none for 4. Could you state Theorem 2's bound as a function of D, or recommend D ≤ 2?
    
    5. Still open from the first pass and untouched (reference and tests are byte-identical to [b3b0aa2](https://github.com/bitcoin/bips/commit/b3b0aa240ee4ee9d5ccc2de480cfe74a3018b02d)): F3 (the `bip327-tests` vectors are regenerated for sorted key lists), F4 (`sign` consumes the secnonce after `get_session_values`), F5 (reference vs text).

    I can rebase my fix PR onto c0a867d without the 33-byte commit if that is useful. @patrickdugan Thanks for the follow-up. I’m happy to work through the other proposed fixes. Could we address them incrementally, with each issue in a separate commit or small PR? That would let us review the reasoning, verify the changes, and agree on each fix before moving on.

    On depth, I see (D=2) as a conservative target for the ROM-only variant, which requires more nonces. With the singly exponential depth dependence under AGM+ROM, my preference for (D\le4) is an implementation guideline based on judgment—not a security cutoff established by the theorem. A concrete limit would be useful for implementers, though I’m comfortable keeping the paper’s “small (D)” wording in the BIP until we have stronger justification for a number.

    Please go ahead with the smaller fixes first; I’d like to give changes affecting signing behavior and security assumptions a separate, thorough review.

  28. in bip-nested-musig2.mediawiki:54 in c0a867d827
      49 | +* Applying root aggregate-key tweaks at all.
      50 | +* Supporting messages whose length is not exactly 32 bytes.
      51 | +* Identifying a disruptive participant after an abort; aborting when an algorithm requires it remains mandatory.
      52 | +* Supporting duplicate participant public keys within an aggregation node, including keys representing nested groups.
      53 | +
      54 | +Implementations must reject unsupported inputs rather than silently ignore them. For example, an implementation restricted to 32-byte messages must fail when given a message of another length. Tests for unsupported features may expect rejection or be skipped where appropriate. The reference implementation continues to support all specified features and run all required test-vector suites.
    


    edilmedeiros commented at 3:19 PM on December 2, 2026:

    Implementations must reject

    This is probably happening again in the text and have strong semantics. I suggest considering adhering to RFC2119 or even better to RFC8174.

  29. in bip-nested-musig2.mediawiki:95 in c0a867d827
      90 | +* ''KeyAggCoeff''
      91 | +* ''GetXonlyPubkey''
      92 | +* ''GetPlainPubkey''
      93 | +* ''ApplyTweak''
      94 | +* ''NonceGen''
      95 | +* ''NonceAgg''
    


    edilmedeiros commented at 3:25 PM on December 2, 2026:

    I think this is excellent, to refer to another specification document. But I fear changes to that specification can leak into this specification in an unsafe manner (you know, security in crypto lives in the details...).

    I don't want to recommend copying text from BIP327. Maybe you can refer to the version of that document? Current version is 1.0.5.

  30. in bip-nested-musig2.mediawiki:101 in c0a867d827
      96 | +
      97 | +All input requirements, failure conditions, serialization rules, and blame requirements for those algorithms apply whenever this specification invokes them.
      98 | +
      99 | +The [https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki#session-context BIP327 Session Context] and the algorithms ''GetSessionValues'', ''GetSessionKeyAggCoeff'', ''Sign'', ''PartialSigVerify'', ''PartialSigVerifyInternal'', and ''PartialSigAgg'' are replaced by the nested versions specified below. This specification additionally defines ''NonceAggExt'' for converting the internal aggregate nonce of a nested group into the first-round nonce contribution by which that group is represented at its parent aggregation node. This specification reuses only the BIP327 algorithms explicitly identified above. This specification does not specify other BIP327 signing algorithms, including DeterministicSign, for NestedMuSig2 sessions.
     100 | +
     101 | +As in BIP327, an algorithm instruction to ''fail'' means the algorithm terminates without producing its normal output. An instruction to ''fail and blame'' a party additionally identifies the party whose invalid protocol contribution caused the failure. This specification does not require a particular API error type or serialization for such failures.
    


    edilmedeiros commented at 3:28 PM on December 2, 2026:

    This specification does not require a particular API error type or serialization for such failures.

    Maybe add a footnote remembering/informing implementors (that many times are not cryptography specialists) that returning errors can work as an oracle for something in the protocol an potentially open a door to attacks?

  31. in bip-nested-musig2.mediawiki:103 in c0a867d827
      98 | +
      99 | +The [https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki#session-context BIP327 Session Context] and the algorithms ''GetSessionValues'', ''GetSessionKeyAggCoeff'', ''Sign'', ''PartialSigVerify'', ''PartialSigVerifyInternal'', and ''PartialSigAgg'' are replaced by the nested versions specified below. This specification additionally defines ''NonceAggExt'' for converting the internal aggregate nonce of a nested group into the first-round nonce contribution by which that group is represented at its parent aggregation node. This specification reuses only the BIP327 algorithms explicitly identified above. This specification does not specify other BIP327 signing algorithms, including DeterministicSign, for NestedMuSig2 sessions.
     100 | +
     101 | +As in BIP327, an algorithm instruction to ''fail'' means the algorithm terminates without producing its normal output. An instruction to ''fail and blame'' a party additionally identifies the party whose invalid protocol contribution caused the failure. This specification does not require a particular API error type or serialization for such failures.
     102 | +
     103 | +The [https://eprint.iacr.org/2026/223 Nested MuSig2] paper describes its construction over an abstract prime-order group. This specification instantiates that construction over secp256k1 using BIP327 key aggregation, BIP327's two-nonce representation, and the concrete tagged hashes specified below. This specification defines Bitcoin-specific serialization and aggregate-key tweaking rules that are not part of the abstract construction in the paper.
    


    edilmedeiros commented at 3:30 PM on December 2, 2026:

    Sounds more like part of the motivation than specification.

  32. in bip-nested-musig2.mediawiki:141 in c0a867d827
     136 | +
     137 | +{| class="wikitable"
     138 | +|-
     139 | +! Tag string !! Purpose
     140 | +|-
     141 | +| <code>KeyAgg list</code>, <code>KeyAgg coefficient</code>
    


    edilmedeiros commented at 3:39 PM on December 2, 2026:

    I'm not a fan of spaces in strings that will be hashed. Since you already uses '/', that might fit, or KeyAggList and KeyAddCoefficient (or even KeyAggCoef so that the two strings have the same size - I don't think that will break stuff and is nicer in the implementation code)

    Style change that implies lot of rework for regenerating/rechecking test vectors, ignore if you feel like so.

  33. in bip-nested-musig2.mediawiki:180 in c0a867d827
     175 | +
     176 | +Key aggregation is performed independently at every aggregation node. For a node at level ''d'' on a particular signer's path, let ''L<sub>d</sub>'' be the participant plain-public-key list for that node after sorting with ''KeySort''. The node's KeyAgg Context is ''keyagg_ctx<sub>d</sub> = KeyAgg(L<sub>d</sub>)''. Each aggregation node MUST compute a separate KeyAgg Context from exactly the participant occurrences belonging to that node. Duplicate participant public keys are permitted as specified by BIP327; sorting MUST preserve every occurrence. For every non-root aggregation node at level ''d > 0'', let ''pk<sub>d−1</sub> = GetPlainPubkey(keyagg_ctx<sub>d</sub>)''. The resulting 33-byte plain public key is the participant public key by which the level-''d'' node is represented in ''L<sub>d−1</sub>'' at its parent aggregation node.
     177 | +
     178 | +The parent node's ''KeyAgg'' invocation consumes this plain public key in the same way it consumes any other participant plain public key. An internal node's KeyAgg Context itself is not an input to the parent's ''KeyAgg'' computation. In particular, the internal node's ''gacc'' and ''tacc'' values are not inherited by the parent KeyAgg Context. The parent independently derives its own ''gacc'' and ''tacc'' as part of its own BIP327 key-aggregation and tweaking operations.
     179 | +
     180 | +Implementations MAY cache intermediate KeyAgg Contexts or other public metadata. Such cached state has no cryptographic role in the parent ''KeyAgg'' invocation beyond the internal aggregate plain public key derived from it.
    


    edilmedeiros commented at 3:41 PM on December 2, 2026:

    Using RFC2119/RFC8174 here without introducing it. See my other comment about it


    edilmedeiros commented at 3:43 PM on December 2, 2026:

    Saw that this happens in other places after this.

  34. in bip-nested-musig2.mediawiki:560 in c0a867d827
     555 | +
     556 | +This specification does not modify BIP341 Taproot validation rules.
     557 | +
     558 | +===Output Script Descriptors===
     559 | +
     560 | +This specification does not define a new output script descriptor expression for representing NestedMuSig2 signer trees. At the time this BIP was written, BIP390 defines the <code>musig()</code> descriptor key expression for BIP327 aggregate keys, but explicitly prohibits nesting one <code>musig()</code> expression inside another. Consequently, a NestedMuSig2 tree cannot be represented directly by nesting the existing BIP390 syntax, for example: <code>musig(KEY_A, musig(KEY_B, KEY_C))</code> is not a valid BIP390 expression. An existing descriptor may contain the already-computed aggregate public key of a nested subgroup where an ordinary key expression is permitted, but doing so does not encode the subgroup's internal signing structure and is therefore insufficient by itself for wallet recovery or coordination of NestedMuSig2 signing. A descriptor representation for nested signer trees, if desired, requires a separate specification or an extension of the applicable descriptor standard. Such descriptor syntax is outside the scope of this BIP.
    


    edilmedeiros commented at 3:47 PM on December 2, 2026:

    Asking out of curiosity if you are working in such a proposal too, would probably be useful for wallets.

  35. in bip-nested-musig2.mediawiki:566 in c0a867d827
     561 | +
     562 | +===Wallet and Protocol Compatibility===
     563 | +
     564 | +Wallets, hardware signers, remote signers, and coordinator protocols that understand only BIP327 MUST NOT assume that they can participate internally in a NestedMuSig2 subtree without additional support.
     565 | +
     566 | +NestedMuSig2-aware software must additionally understand at least:
    


    edilmedeiros commented at 3:49 PM on December 2, 2026:

    software must additionally understand

    nit: I don't feel like saying that software understands something, people do. What exactly do you mean here, implementing, being capable to parse, import, other thing?

  36. in bip-nested-musig2.mediawiki:651 in c0a867d827
     646 | +* root aggregation produces the expected signature; and
     647 | +* every successful final signature passes ordinary BIP340 verification.
     648 | +
     649 | +Implementers are encouraged to reproduce the test vectors independently rather than treating the Python implementation as an independent proof of the specification.
     650 | +
     651 | +==Security Considerations==
    


    edilmedeiros commented at 3:52 PM on December 2, 2026:

    See my comment about specification leaks from BIP327. Maybe a security consideration is that a key generated using a version of BIP327 (and thus this proposal) can become unspendable because of a software upgrade that will generate signatures in a slightly different (but incompatible) way.

    I don't have any specifics in mind at this time, but feels like something that should be analyzed/considered.


    edilmedeiros commented at 3:54 PM on December 2, 2026:

    Maybe a good thing is to already have versioning of this document and lock references to specific versions of BIP327 from day 1.

  37. in bip-nested-musig2.mediawiki:855 in c0a867d827
     850 | +
     851 | +This BIP is out of scope for such mechanisms.
     852 | +
     853 | +===Side Channels and Secret Memory===
     854 | +
     855 | +The accompanying Python reference implementation is not suitable for production use. Production implementations SHOULD use constant-time cryptographic operations for computations involving secret scalars and MUST avoid implementation behavior that exposes secret keys or secret nonce material through avoidable side channels.
    


    edilmedeiros commented at 3:56 PM on December 2, 2026:

    Production implementations SHOULD use constant-time cryptographic operations for computations involving secret scalars

    Wouldn't it be better to specify MUST here?

  38. in bip-nested-musig2.mediawiki:862 in c0a867d827
     857 | +Implementations SHOULD minimize unnecessary copies of:
     858 | +* secret signing keys;
     859 | +* secret nonce scalars; and
     860 | +* secret intermediate scalar values.
     861 | +
     862 | +Where reliable immediate memory erasure is unavailable, implementations should nevertheless structure ownership of secret nonce state so that consumed nonce material cannot be reused.
    


    edilmedeiros commented at 3:59 PM on December 2, 2026:

    MUST wouldn't be better?

    Also, I think "nevertheless" is only adding confusion here.

    I'm not sure what "consumed" means here.

  39. edilmedeiros commented at 4:04 PM on December 2, 2026: contributor

    Hi @BEULAHEVANJALIN thanks for proposing this, quite impressive work. I gave a first round of reading looking specifically for major text structure and coherence with other similar BIPs. I think you did a great job already, in particular to reusing the constructions from BIP327.

    Please note that this introduces a potential leak of specification changes from that spec into this. Since crypto lives in the details, that's something I would address being more explicit with versioning.

    I would ask to review the use of RFC2119/RFC8174, there are some places where I feel they should be more clear with capitalized letters. Also, add explicit mention to those standards.

    I'll schedule at least one more round of review going through the construction with pen and paper and also checking the reference implementation (this will take me a few weeks as I'm not totally familiar with the details of musig2).

    On regard of the implementation, not a blocker, but I would prefer it to be merged in https://github.com/secp256k1lab/secp256k1lab or a fork of it. I personally don't like having somewhat heavier source code together with the specification documents as they introduce more maintenance overhead over time. That would involve coordination with another project, but if I'm not mistaken, their intent was to be an umbrella reference for specification projects as well.

  40. patrickdugan commented at 11:10 PM on December 2, 2026: none

    Branch Commit PR Scope & Regression Tests CPU Tests (bip327 / multi-level

    / random_tree) C1 https://github.com/patrickdugan/bips/tree/nms2-c1-arbitrary-length-bip340-messages 2fc41cae4ad5dbc046986542110dbab9ea7bc276 bips#12 https://github.com/BEULAHEVANJALIN/bips/pull/12 Remove 32-byte limit in schnorr_verify; multi-level tests for 0-byte, 38-byte, 256-byte msgs PASS ( 51.4s / 155.2s / 64.5s) C2 https://github.com/patrickdugan/bips/tree/nms2-c2-secret-nonce-consumption 8b70cbf224218855ddc9c8ad42afe12827cb3207 bips#13 https://github.com/BEULAHEVANJALIN/bips/pull/13 Consume secnonce[:64] before all fallible ops; 5 failure-reuse regression tests (malformed nonce_path, bad cosigner pk, bad tweak, mismatched sk, post-success) PASS ( 43.8s / 139.0s / 53.3s) C3 https://github.com/patrickdugan/bips/tree/nms2-c3-psig-return-type 7c19341b51af026e39c8cb5b2376605e5f141e75 bips#14 https://github.com/BEULAHEVANJALIN/bips/pull/14 sign returns 32-byte psig only (not (xbytes(R), psig)) PASS (47.9s / 128.6s / 100.9s) C4 https://github.com/patrickdugan/bips/tree/nms2-c4-input-length-validation f40f5ff45d3cd8669ace8063085be48bcd3ff5f6 bips#15 https://github.com/BEULAHEVANJALIN/bips/pull/15 Enforce lengths in individual_pk, sign, get_session_values, partial_sig_verify, and 33-byte PlainPk in nonce_agg_ext + regression suite PASS (50.5s / 135.8s / 38.5s) C5 https://github.com/patrickdugan/bips/tree/nms2-c5-root-aggregation-and-session-c 92bb683aac720845c6c07482cba0d9fc2564b5af bips#16 https://github.com/BEULAHEVANJALIN/bips/pull/16 7-tuple get_session_values (c & c_check), partial_sig_agg_intermediate, and BIP327 root partial_sig_agg(psigs, RootSessionContext) deriving R PASS (51.9s / 131.2s / 57.7s) C6 https://github.com/patrickdugan/bips/tree/nms2-c6-tweak-aware-nonce-gen fc27bc0987cd441050803f69f46169afc8fd2c69 bips#17 https://github.com/BEULAHEVANJALIN/bips/pull/17 Fix nested_musig2_exec.py to pass final tweaked root aggpk (or None) to NonceGen before round 1 PASS ( 41.7s / 99.6s / 36.4s)

    On Thu, Dec 3, 2026 at 6:08 AM Edil Medeiros @.***> wrote:

    @.**** commented on this pull request.

    Hi @BEULAHEVANJALIN https://github.com/BEULAHEVANJALIN thanks for proposing this, quite impressive work. I gave a first round of reading looking specifically for major text structure and coherence with other similar BIPs. I think you did a great job already, in particular to reusing the constructions from BIP327.

    Please note that this introduces a potential leak of specification changes from that spec into this. Since crypto lives in the details, that's something I would address being more explicit with versioning.

    I would ask to review the use of RFC2119/RFC8174, there are some places where I feel they should be more clear with capitalized letters. Also, add explicit mention to those standards.

    I'll schedule at least one more round of review going through the construction with pen and paper and also checking the reference implementation (this will take me a few weeks as I'm not totally familiar with the details of musig2).

    On regard of the implementation, not a blocker, but I would prefer it to be merged in https://github.com/secp256k1lab/secp256k1lab or a fork of it. I personally don't like having somewhat heavier source code together with the specification documents as they introduce more maintenance overhead over time. That would involve coordination with another project, but if I'm not mistaken, their intent was to be an umbrella reference for specification projects as well.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4771825346:

    +Nested signing retains MuSig2's nonce-contribution and partial-signature stages, while contributions are recursively processed through the aggregation tree. This specification defines the additional key, nonce, session, signing, partial-signature verification, and signature-aggregation rules required to perform that recursive composition while producing a BIP340-compatible final signature.

    • +==Overview==
    • +NestedMuSig2 arranges signers in a tree. The leaves hold individual signing keys, and each group combines its participants' contributions before passing a single contribution to its parent. The root produces the final signature. Every participant in each group is required to sign.
    • +===Optionality of Features===
    • +As in BIP327, implementations may omit features that their applications do not need. Optional features include: +* Applying plain tweaks after X-only tweaks at the root. +* Applying root aggregate-key tweaks at all. +* Supporting messages whose length is not exactly 32 bytes. +* Identifying a disruptive participant after an abort; aborting when an algorithm requires it remains mandatory. +* Supporting duplicate participant public keys within an aggregation node, including keys representing nested groups.
    • +Implementations must reject unsupported inputs rather than silently ignore them. For example, an implementation restricted to 32-byte messages must fail when given a message of another length. Tests for unsupported features may expect rejection or be skipped where appropriate. The reference implementation continues to support all specified features and run all required test-vector suites.

    Implementations must reject

    This is probably happening again in the text and have strong semantics. I suggest considering adhering to RFC2119 https://www.rfc-editor.org/info/rfc2119/ or even better to RFC8174 https://www.rfc-editor.org/info/rfc8174/.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4771911703:

    +This specification builds directly on [https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki BIP327]. Unless explicitly stated otherwise, the notation, secp256k1 constants, point operations, serialization functions, and tagged-hash construction defined in BIP327 apply to this specification. In particular, this specification uses the BIP327 functions ''int(x)'', ''bytes(k, x)'', ''xbytes'', ''cbytes'', ''cbytes_ext'', ''cpoint'', ''cpoint_ext'', and ''has_even_y'', and the tagged hash construction ''hash<sub>tag</sub>(x)''.

    • +The following BIP327 algorithms are used unchanged: +* ''IndividualPubkey'' +* ''KeySort'' +* ''KeyAgg'' +* ''KeyAggCoeff'' +* ''GetXonlyPubkey'' +* ''GetPlainPubkey'' +* ''ApplyTweak'' +* ''NonceGen'' +* ''NonceAgg''

    I think this is excellent, to refer to another specification document. But I fear changes to that specification can leak into this specification in an unsafe manner (you know, security in crypto lives in the details...).

    I don't want to recommend copying text from BIP327. Maybe you can refer to the version of that document? Current version is 1.0.5.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4771954354:

    +The following BIP327 algorithms are used unchanged: +* ''IndividualPubkey'' +* ''KeySort'' +* ''KeyAgg'' +* ''KeyAggCoeff'' +* ''GetXonlyPubkey'' +* ''GetPlainPubkey'' +* ''ApplyTweak'' +* ''NonceGen'' +* ''NonceAgg''

    • +All input requirements, failure conditions, serialization rules, and blame requirements for those algorithms apply whenever this specification invokes them.
    • +The [https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki#session-context BIP327 Session Context] and the algorithms ''GetSessionValues'', ''GetSessionKeyAggCoeff'', ''Sign'', ''PartialSigVerify'', ''PartialSigVerifyInternal'', and ''PartialSigAgg'' are replaced by the nested versions specified below. This specification additionally defines ''NonceAggExt'' for converting the internal aggregate nonce of a nested group into the first-round nonce contribution by which that group is represented at its parent aggregation node. This specification reuses only the BIP327 algorithms explicitly identified above. This specification does not specify other BIP327 signing algorithms, including DeterministicSign, for NestedMuSig2 sessions.
    • +As in BIP327, an algorithm instruction to ''fail'' means the algorithm terminates without producing its normal output. An instruction to ''fail and blame'' a party additionally identifies the party whose invalid protocol contribution caused the failure. This specification does not require a particular API error type or serialization for such failures.

    This specification does not require a particular API error type or serialization for such failures.

    Maybe add a footnote remembering/informing implementors (that many times are not cryptography specialists) that returning errors can work as an oracle for something in the protocol an potentially open a door to attacks?

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4771983216:

    +* ''KeySort'' +* ''KeyAgg'' +* ''KeyAggCoeff'' +* ''GetXonlyPubkey'' +* ''GetPlainPubkey'' +* ''ApplyTweak'' +* ''NonceGen'' +* ''NonceAgg''

    • +All input requirements, failure conditions, serialization rules, and blame requirements for those algorithms apply whenever this specification invokes them.
    • +The [https://github.com/bitcoin/bips/blob/master/bip-0327.mediawiki#session-context BIP327 Session Context] and the algorithms ''GetSessionValues'', ''GetSessionKeyAggCoeff'', ''Sign'', ''PartialSigVerify'', ''PartialSigVerifyInternal'', and ''PartialSigAgg'' are replaced by the nested versions specified below. This specification additionally defines ''NonceAggExt'' for converting the internal aggregate nonce of a nested group into the first-round nonce contribution by which that group is represented at its parent aggregation node. This specification reuses only the BIP327 algorithms explicitly identified above. This specification does not specify other BIP327 signing algorithms, including DeterministicSign, for NestedMuSig2 sessions.
    • +As in BIP327, an algorithm instruction to ''fail'' means the algorithm terminates without producing its normal output. An instruction to ''fail and blame'' a party additionally identifies the party whose invalid protocol contribution caused the failure. This specification does not require a particular API error type or serialization for such failures.
    • +The [https://eprint.iacr.org/2026/223 Nested MuSig2] paper describes its construction over an abstract prime-order group. This specification instantiates that construction over secp256k1 using BIP327 key aggregation, BIP327's two-nonce representation, and the concrete tagged hashes specified below. This specification defines Bitcoin-specific serialization and aggregate-key tweaking rules that are not part of the abstract construction in the paper.

    Sounds more like part of the motivation than specification.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772117545:

    +* ''b<sub>0</sub>'' is the root nonce-binding factor computed according to BIP327 from ''out<sub>0</sub>'', the final root X-only aggregate public key, and the message. If root-level aggregate-key tweaks are applied, use the public key after those tweaks.<br>''b<sub>0</sub>'' is the only nonce-binding factor that commits directly to the message. +* ''b&#780;'' is the accumulated nonce-binding factor ''b&#780; = b<sub>0</sub>·b<sub>1</sub>·...·b<sub>&Lambda;−1</sub> mod n''.<br>Because this specification uses the BIP327 two-nonce construction, ''b&#780;'' is the coefficient multiplying the leaf signer's second secret nonce in its nested partial-signature equation. +* ''c'' is the BIP340 challenge ''c = int(hash<sub>BIP0340/challenge</sub>(xbytes(R) || xbytes(Q) || m)) mod n'', where ''Q'' is the final root aggregate public key and ''R'' is the final effective nonce point. +* ''c&#780;'' is the accumulated challenge coefficient ''c&#780; = c·a<sub>0</sub>·a<sub>1</sub>·...·a<sub>&Lambda;−1</sub> mod n''. It is the coefficient multiplying the leaf signer's secret-key contribution. +* Let ''out<sub>0</sub> = cbytes_ext(R<sub>1,0</sub>) || cbytes_ext(R<sub>2,0</sub>)''. Compute ''R' = R<sub>1,0</sub> + b<sub>0</sub>·R<sub>2,0</sub>''.<br>If ''R'' is the point at infinity, let ''R = G''; otherwise, let ''R = R''. This is the unchanged BIP327 root effective-nonce rule.<br>Intermediate binding factors do not appear explicitly in this root expression because they have already been incorporated into nested nonce contributions by preceding invocations of ''NonceAggExt''.

    • +===Tagged Hashes===
    • +Tagged hashes use the BIP340 construction ''SHA256(SHA256(tag) || SHA256(tag) || x)'', where ''tag'' is encoded as a UTF-8 byte string.
    • +{| class="wikitable" +|- +! Tag string !! Purpose +|- +| <code>KeyAgg list</code>, <code>KeyAgg coefficient</code>

    I'm not a fan of spaces in strings that will be hashed. Since you already uses '/', that might fit, or KeyAggList and KeyAddCoefficient (or even KeyAggCoef so that the two strings have the same size - I don't think that will break stuff and is nicer in the implementation code)

    Style change that implies lot of rework for regenerating/rechecking test vectors, ignore if you feel like so.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772144629:

    • +The final challenge is computed exactly using the BIP340 challenge hash and encoding. Together with the nested signing and partial-signature aggregation rules specified below, this causes the final 64-byte signature to satisfy the ordinary BIP340 verification equation under the root X-only aggregate public key.
    • +===Key Generation and Aggregation===
    • +This specification uses the BIP327 algorithms ''IndividualPubkey'', ''KeySort'', ''KeyAgg'', ''KeyAggCoeff'', ''GetPlainPubkey'', ''GetXonlyPubkey'', and ''ApplyTweak'' as specified in BIP327. Their input requirements, failure conditions, and serialization rules apply whenever they are invoked below.
    • +The Nested MuSig2 paper defines recursive key aggregation over group elements. This specification instantiates that construction using BIP327 plain public keys and BIP327's optimized key-aggregation algorithm. As an interoperability convention, participant plain public keys are sorted with ''KeySort'' independently at each aggregation node before invoking ''KeyAgg''.
    • +====Nested Key Aggregation====
    • +Key aggregation is performed independently at every aggregation node. For a node at level ''d'' on a particular signer's path, let ''L<sub>d</sub>'' be the participant plain-public-key list for that node after sorting with ''KeySort''. The node's KeyAgg Context is ''keyagg_ctx<sub>d</sub> = KeyAgg(L<sub>d</sub>)''. Each aggregation node MUST compute a separate KeyAgg Context from exactly the participant occurrences belonging to that node. Duplicate participant public keys are permitted as specified by BIP327; sorting MUST preserve every occurrence. For every non-root aggregation node at level ''d > 0'', let ''pk<sub>d−1</sub> = GetPlainPubkey(keyagg_ctx<sub>d</sub>)''. The resulting 33-byte plain public key is the participant public key by which the level-''d'' node is represented in ''L<sub>d−1</sub>'' at its parent aggregation node.
    • +The parent node's ''KeyAgg'' invocation consumes this plain public key in the same way it consumes any other participant plain public key. An internal node's KeyAgg Context itself is not an input to the parent's ''KeyAgg'' computation. In particular, the internal node's ''gacc'' and ''tacc'' values are not inherited by the parent KeyAgg Context. The parent independently derives its own ''gacc'' and ''tacc'' as part of its own BIP327 key-aggregation and tweaking operations.
    • +Implementations MAY cache intermediate KeyAgg Contexts or other public metadata. Such cached state has no cryptographic role in the parent ''KeyAgg'' invocation beyond the internal aggregate plain public key derived from it.

    Using RFC2119/RFC8174 here without introducing it. See my other comment about it

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772233186:

    +===Bitcoin Consensus and Taproot===

    • +NestedMuSig2 is an off-chain signing protocol. It requires no consensus change, soft fork, or new script opcode. When the resulting X-only aggregate public key is used in a context that already accepts BIP340 signatures, the completed NestedMuSig2 signature is verified using the existing BIP340 verification algorithm.
    • +In particular, when the root aggregate key is used as a Taproot output key, the blockchain does not reveal whether the signature was produced by: +* a single signer; +* an ordinary BIP327 MuSig2 signing group; or +* a NestedMuSig2 signing tree,
    • +except to the extent that such information is revealed through other application or transaction metadata.
    • +This specification does not modify BIP341 Taproot validation rules.
    • +===Output Script Descriptors===
    • +This specification does not define a new output script descriptor expression for representing NestedMuSig2 signer trees. At the time this BIP was written, BIP390 defines the <code>musig()</code> descriptor key expression for BIP327 aggregate keys, but explicitly prohibits nesting one <code>musig()</code> expression inside another. Consequently, a NestedMuSig2 tree cannot be represented directly by nesting the existing BIP390 syntax, for example: <code>musig(KEY_A, musig(KEY_B, KEY_C))</code> is not a valid BIP390 expression. An existing descriptor may contain the already-computed aggregate public key of a nested subgroup where an ordinary key expression is permitted, but doing so does not encode the subgroup's internal signing structure and is therefore insufficient by itself for wallet recovery or coordination of NestedMuSig2 signing. A descriptor representation for nested signer trees, if desired, requires a separate specification or an extension of the applicable descriptor standard. Such descriptor syntax is outside the scope of this BIP.

    Asking out of curiosity if you are working in such a proposal too, would probably be useful for wallets.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772261262:

    +* an ordinary BIP327 MuSig2 signing group; or +* a NestedMuSig2 signing tree,

    • +except to the extent that such information is revealed through other application or transaction metadata.
    • +This specification does not modify BIP341 Taproot validation rules.
    • +===Output Script Descriptors===
    • +This specification does not define a new output script descriptor expression for representing NestedMuSig2 signer trees. At the time this BIP was written, BIP390 defines the <code>musig()</code> descriptor key expression for BIP327 aggregate keys, but explicitly prohibits nesting one <code>musig()</code> expression inside another. Consequently, a NestedMuSig2 tree cannot be represented directly by nesting the existing BIP390 syntax, for example: <code>musig(KEY_A, musig(KEY_B, KEY_C))</code> is not a valid BIP390 expression. An existing descriptor may contain the already-computed aggregate public key of a nested subgroup where an ordinary key expression is permitted, but doing so does not encode the subgroup's internal signing structure and is therefore insufficient by itself for wallet recovery or coordination of NestedMuSig2 signing. A descriptor representation for nested signer trees, if desired, requires a separate specification or an extension of the applicable descriptor standard. Such descriptor syntax is outside the scope of this BIP.
    • +===Wallet and Protocol Compatibility===
    • +Wallets, hardware signers, remote signers, and coordinator protocols that understand only BIP327 MUST NOT assume that they can participate internally in a NestedMuSig2 subtree without additional support.
    • +NestedMuSig2-aware software must additionally understand at least:

    software must additionally understand

    nit: I don't feel like saying that software understands something, people do. What exactly do you mean here, implementing, being capable to parse, import, other thing?

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772314669:

    +===Testing===

    • +Running the reference implementation's test suite MUST execute all NestedMuSig2 test-vector suites defined by this specification. Tests that are temporarily disabled during development MUST NOT remain disabled in the version published with the BIP.
    • +The test suite MUST include checks that: +* unchanged BIP327 primitives continue to satisfy their BIP327 vectors; +* NestedMuSig2-specific vectors produce the expected intermediate values; +* partial signatures verify at both leaf and nested-subgroup boundaries; +* intermediate aggregate contributions verify using truncated Session Contexts; +* secret nonces cannot be reused; +* root aggregation produces the expected signature; and +* every successful final signature passes ordinary BIP340 verification.
    • +Implementers are encouraged to reproduce the test vectors independently rather than treating the Python implementation as an independent proof of the specification.
    • +==Security Considerations==

    See my comment about specification leaks from BIP327. Maybe a security consideration is that a key generated using a version of BIP327 (and thus this proposal) can become unspendable because of a software upgrade that will generate signatures in a slightly different (but incompatible) way.

    I don't have any specifics in mind at this time, but feels like something that should be analyzed/considered.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772368010:

    +===Transport and Transcript Security===

    • +This BIP does not define a network transport protocol. Applications must ensure that received protocol values are associated with the intended signing session and, where necessary, with the participant or aggregator that supplied them.
    • +Depending on the application threat model, suitable mechanisms may include: +* unique session identifiers; +* authenticated communication channels; +* signed protocol messages; +* authenticated transcripts; or +* persistent audit records.
    • +This BIP is out of scope for such mechanisms.
    • +===Side Channels and Secret Memory===
    • +The accompanying Python reference implementation is not suitable for production use. Production implementations SHOULD use constant-time cryptographic operations for computations involving secret scalars and MUST avoid implementation behavior that exposes secret keys or secret nonce material through avoidable side channels.

    Production implementations SHOULD use constant-time cryptographic operations for computations involving secret scalars

    Wouldn't it be better to specify MUST here?

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772411591:

    +* signed protocol messages; +* authenticated transcripts; or +* persistent audit records.

    • +This BIP is out of scope for such mechanisms.
    • +===Side Channels and Secret Memory===
    • +The accompanying Python reference implementation is not suitable for production use. Production implementations SHOULD use constant-time cryptographic operations for computations involving secret scalars and MUST avoid implementation behavior that exposes secret keys or secret nonce material through avoidable side channels.
    • +Implementations SHOULD minimize unnecessary copies of: +* secret signing keys; +* secret nonce scalars; and +* secret intermediate scalar values.
    • +Where reliable immediate memory erasure is unavailable, implementations should nevertheless structure ownership of secret nonce state so that consumed nonce material cannot be reused.

    MUST wouldn't be better?

    Also, I think "nevertheless" is only adding confusion here.

    I'm not sure what "consumed" means here.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772177525:

    • +The final challenge is computed exactly using the BIP340 challenge hash and encoding. Together with the nested signing and partial-signature aggregation rules specified below, this causes the final 64-byte signature to satisfy the ordinary BIP340 verification equation under the root X-only aggregate public key.
    • +===Key Generation and Aggregation===
    • +This specification uses the BIP327 algorithms ''IndividualPubkey'', ''KeySort'', ''KeyAgg'', ''KeyAggCoeff'', ''GetPlainPubkey'', ''GetXonlyPubkey'', and ''ApplyTweak'' as specified in BIP327. Their input requirements, failure conditions, and serialization rules apply whenever they are invoked below.
    • +The Nested MuSig2 paper defines recursive key aggregation over group elements. This specification instantiates that construction using BIP327 plain public keys and BIP327's optimized key-aggregation algorithm. As an interoperability convention, participant plain public keys are sorted with ''KeySort'' independently at each aggregation node before invoking ''KeyAgg''.
    • +====Nested Key Aggregation====
    • +Key aggregation is performed independently at every aggregation node. For a node at level ''d'' on a particular signer's path, let ''L<sub>d</sub>'' be the participant plain-public-key list for that node after sorting with ''KeySort''. The node's KeyAgg Context is ''keyagg_ctx<sub>d</sub> = KeyAgg(L<sub>d</sub>)''. Each aggregation node MUST compute a separate KeyAgg Context from exactly the participant occurrences belonging to that node. Duplicate participant public keys are permitted as specified by BIP327; sorting MUST preserve every occurrence. For every non-root aggregation node at level ''d > 0'', let ''pk<sub>d−1</sub> = GetPlainPubkey(keyagg_ctx<sub>d</sub>)''. The resulting 33-byte plain public key is the participant public key by which the level-''d'' node is represented in ''L<sub>d−1</sub>'' at its parent aggregation node.
    • +The parent node's ''KeyAgg'' invocation consumes this plain public key in the same way it consumes any other participant plain public key. An internal node's KeyAgg Context itself is not an input to the parent's ''KeyAgg'' computation. In particular, the internal node's ''gacc'' and ''tacc'' values are not inherited by the parent KeyAgg Context. The parent independently derives its own ''gacc'' and ''tacc'' as part of its own BIP327 key-aggregation and tweaking operations.
    • +Implementations MAY cache intermediate KeyAgg Contexts or other public metadata. Such cached state has no cryptographic role in the parent ''KeyAgg'' invocation beyond the internal aggregate plain public key derived from it.

    Saw that this happens in other places after this.

    In bip-nested-musig2.mediawiki https://github.com/bitcoin/bips/pull/2297#discussion_r4772336831:

    +===Testing===

    • +Running the reference implementation's test suite MUST execute all NestedMuSig2 test-vector suites defined by this specification. Tests that are temporarily disabled during development MUST NOT remain disabled in the version published with the BIP.
    • +The test suite MUST include checks that: +* unchanged BIP327 primitives continue to satisfy their BIP327 vectors; +* NestedMuSig2-specific vectors produce the expected intermediate values; +* partial signatures verify at both leaf and nested-subgroup boundaries; +* intermediate aggregate contributions verify using truncated Session Contexts; +* secret nonces cannot be reused; +* root aggregation produces the expected signature; and +* every successful final signature passes ordinary BIP340 verification.
    • +Implementers are encouraged to reproduce the test vectors independently rather than treating the Python implementation as an independent proof of the specification.
    • +==Security Considerations==

    Maybe a good thing is to already have versioning of this document and lock references to specific versions of BIP327 from day 1.

    — Reply to this email directly, view it on GitHub https://github.com/bitcoin/bips/pull/2297?email_source=notifications&email_token=AAS2CBNXIMWGEVFUCWIADBL54CG45A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTMMJVGM3TAOBVGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLDGN5XXIZLSL5RWY2LDNM#pullrequestreview-6153708539, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAS2CBKZPHPO4QHUXMUSVRT54CG45AVCNFSNUABEKJSXA33TNF2G64TZHMYTINJTGE3TGNZ3JFZXG5LFHM2TKMRUHA4DQOJWGKQXMAQ . Triage notifications, keep track of coding agent tasks and review pull requests on the go with GitHub Mobile for iOS https://github.com/notifications/mobile/ios/AAS2CBJ6DALGX7MSN6SXUP354CG45A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTMMJVGM3TAOBVGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJKTGN5XXIZLSL5UW64Y and Android https://github.com/notifications/mobile/android/AAS2CBIF3J2QXJ6BIF6ZEA354CG45A5CNFSNUABKM5UWIORPF5TWS5BNNB2WEL2QOVWGYUTFOF2WK43UKJSXM2LFO4XTMMJVGM3TAOBVGM42M4TFMFZW63VHNVSW45DJN5XKKZLWMVXHJLTGN5XXIZLSL5QW4ZDSN5UWI. Download it today! You are receiving this because you were mentioned.Message ID: <bitcoin/bips/pull/2297/review/6153708539 @.***>

  41. edilmedeiros commented at 11:21 PM on December 2, 2026: contributor

    @patrickdugan I would appreciate if your clanker refrained from tagging me in PRs that I don't care and won't review. Yet, since it summoned me, I left a comment that explains why some patches are just a waste of time just like the noise in the previous comment here.

    Spending tokens to review technical work is good, welcomed and encouraged, especially for complex work like this specification, but let's not annoy humans trying to do what humans do best...

  42. patrickdugan commented at 11:28 PM on December 2, 2026: none

    Duly noted! :D


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bips. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-12-03 01:42 UTC