Skip to content

BIP460: CISA for Taproot Key Path Spends - #2212

Merged
jonatack merged 5 commits into
bitcoin:masterfrom
fjahr:cisa
Nov 4, 2026
Merged

jonatack merged 5 commits into
bitcoin:masterfrom
fjahr:cisa

Conversation

@fjahr

@fjahr fjahr commented Jul 21, 2026 •

Copy link
Copy Markdown
Contributor

This is a BIP draft for transaction-wide cross-input signature aggregation (CISA). It introduces witness version 2, which enables Taproot-style key path spending where inputs can aggregate their signatures within a transaction. Each input chooses between half-aggregation, full-aggregation, or an explicit opt-out via a marker byte in its witness and the signature message commits to that choice. The aggregation schemes themselves are specified in BIP458 half-aggregation and BIP459 full-aggregation.

Compared to the version shared on the mailing list recently, this version incorporates feedback from vostrnad, most notably a rewritten rationale for excluding script path aggregation, describing the conflict with the OP_SUCCESS upgrade mechanism.

The test vectors are generated with Python code that builds on the reference implementations of BIP458 and BIP459, and the latest master of secp256k1lab is vendored with the BIP, same as it was done for BIP458/459.

Note to the BIP editors: I am aware that SegWit v2 here collides with BIP360. I am curious what you have to say about this, and I am happy to make a change here if you request it, but I couldn't find any rules assigning witness numbers in BIPs or anything that seemed close enough. Since witness versions are a scarce resource and not assigning them sequential would be kind of confusing, it seems whatever soft fork goes in next that requires a new witness version should get the next one available. Since both this one and BIP360 aren't close to activation, I am happy with whatever you decide to write into the specs in the meantime. Maybe we'll want to move to a more generic language for the version instead of prescribing it explicitly until activation comes close. On the other hand, maybe making it explicit and avoiding collisions makes sense for tests on Bitcoin Inquisition etc. Either way, it can't be avoided that there is a chance a "final" BIP might need a change in this regard at some point when it actually gets activated.

@fjahr

fjahr commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

This completes the CISA BIP triplet with half-agg (458) and full-agg (459) and should get BIP number 460 but I will wait for the editor confirmation again :)

@vostrnad vostrnad left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Second pass of review for things I didn't notice the first time around, especially the opportunity to structure the specification around differences from SegWit v1 instead of reiterating many of its rules. The rationale for leaving out script path inputs reads great now.

Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-0460.mediawiki
A work in progress implementation for Bitcoin Core is available at https://github.com/fjahr/bitcoin/tree/2026-07-cisa-txwide.
It implements the validation rules of this BIP and validates all consensus test vectors.

== Rationale ==

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It seems a bit inconsistent to have sections named Rationale (which describes rationale inline) and Footnotes (which describes rationale as footnotes). As an example, BIP-341 only has a Rationale section where all points are footnotes, and that way they can be referenced inline from places where the rationale needs explaining.

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.

I left this as is. It is consistent with, for example, BIP340 and BIP458 (where I didn't come up with the initial structure). Both mix prose rationale and a separate footnotes section. I think such a split can help with readability by keeping the parts that are deeper in the weeds in the footnotes.

Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
Comment thread bip-XXXX.mediawiki Resolved
@murchandamus

murchandamus commented Jul 21, 2026 •

Copy link
Copy Markdown
Member

I am aware that SegWit v2 here collides with BIP360.

I would also expect that whatever gets deployed first would get to use the next version and other proposals would shift. I guess you could write “version 2 (or the next unencumbered version available when this proposal is deployed)” or similar to be abundantly clear. At least one of the authors of BIP 360 was keen on using version 3 anyway, because he wanted quantum-resistant addresses to start with bc1r.

@fjahr fjahr changed the title BIP draft: CISA for Taproot Key Path Spends BIP460: CISA for Taproot Key Path Spends Jul 28, 2026
@fjahr

fjahr commented Jul 28, 2026

Copy link
Copy Markdown
Contributor Author

Addressed inline comments from @vostrnad , thanks again for the extensive review!

I also added a bit to the rationale section in response to waxwing's comment here: https://groups.google.com/g/bitcoindev/c/1XH6sBLWZuA/m/-zRSmrFZGQAJ See my response on the mailing list for a bit more detail. As mentioned, there are, well, I am still open to consider adding this if reviewers can envision possible use cases or are just generally of the opinion we should offer as much flexibility as possible.

Also added the assigned number and made changes in response the recent renaming of BIP459.

I guess you could write “version 2 (or the next unencumbered version available when this proposal is deployed)” or similar to be abundantly clear.

I have something like this in the deployment section already, so I didn't make any further change in this regard.

@fjahr

fjahr commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

I have been working on a bigger revision of this proposal that I would like to ask if anyone sees downsides that I have missed before actually pushing it here. This new version would be making opted-out inputs plain BIP 341 key path spends. Draft version of the spec changes: fjahr/bips@cisa...cisa-plain-optout

A bit more detail: the opt-out marker 0xbb would be removed. Opted-out inputs carry a bare 64 or 65-byte BIP 341 signature over the unchanged BIP 341 message. The aggregation markers 0xbc/0xbd move from the first byte of the witness element to the last, the position of the sighash byte. Marker values are disjoint from valid sighash values, so this resolves the 65-byte ambiguity that the opt-out marker existed to resolve. Aggregated inputs are otherwise unchanged and their messages still commit to the mode, so aggregation remains consensual.

The motivation comes from the adoption discussion in the PQC output type thread: https://delvingbitcoin.org/t/pqc-output-type-discussion/2749/6. My perspective has changed because if external factors like PQ migration drive part of the adoption of the output type, opted-out spends may be less of an exception than I thought. With this change a wallet that never aggregates spends witness v2 outputs with its existing Taproot signing logic, no new sighash code path, no new witness logic. A CISA-enabled witness v2 becomes a strict superset of a plain "P2TRv2" with BIP 341 semantics.

@vostrnad suggested the key elements of this in earlier review, the sighash byte trailing the signature and opting out by omitting the marker. I rejected both at the time because I saw opting out as a rare case that could afford an explicit byte. Due to the external motivation for adoption of the output type I now see this differently. I also didn't put these two suggestions together which caused me to expect this change to be more complicated than it ended up actually being.

Pros of the new version:

  • Opted-out spends are byte-identical to BIP 341 key path spends: same witness, same message, same signing code, making initial adoption easier even if CISA use is not interesting/too complex for a wallet/client implementation at the start.
  • One byte saved per opted-out input.

Cons:

  • Cross-version replay protection between v1 and v2 now rests on the scriptPubKey commitment in SigMsg instead of a separate sighash epoch.
  • The marker sits at the end of the element, unlike other tags in the taproot family, and its values cannot become sighash types in a future witness version that inherits this grammar.

By now I believe that this is an improvement even if there is no combination with a PQ P2TRv2 proposal so I plan to update the pull shortly if I didn't overlook any serious issues. Feedback very welcome.

@conduition

conduition commented Aug 24, 2026 •

Copy link
Copy Markdown
Contributor

Hey @fjahr, reviewing the spec changes, here's a few observations:

  • '''Marker''': Last byte (0xbc or 0xbd)

Nit: It's unusual to document the last element of an object's encoding first.

Opted-out spends are byte-identical to BIP 341 key path spends, so wallets that do not aggregate can adopt the new output type without new signing logic.

I think there would still be a difference w/r/t the witness program version, and perhaps some implementations naively assume the witness version during message hashing. So there will be some change needed during signing (otherwise replay can occur), but still changing a single byte is pretty minimal. Perhaps that one byte is still worth mentioning?

Opted-out inputs still need protection from non-consensual aggregation.

Crazy idea, but could you flip this logic on its head, and swap the signature message functions of the "opted out" and "half-agg" signatures? Then the default 'lazy path' (i.e. BIP341-style key spend with a new witness version) would be half-aggregatable, while the explicit opt-out signature would require manual changes by wallet devs.

Then if we allow half-aggregation by third parties, users who upgrade to CISA addresses would automatically gain the benefits of half-aggregation without doing any work aside from changing the witness version, since half-agg will presumably be done automatically for them by someone in the mempool, or by miners themselves (they have incentive to).

This has a security drawback though, for users who depend on adaptor signatures. They'd need to update their systems, using stock BIP341 signatures would subject their signatures to half-aggregation, possibly by accident. Is this a big deal? IDK.

It also places an expected burden of doing half-agg work on the rest of the network, when really it should be the spender's wallet software.


A few observations unrelated to the new changes:

Half-aggregation non-interactively reduces n signatures from 64*n bytes to (n+1)*32 bytes

Since the half-agg signature is variable-size scaling with n (the number of signers in the group), does this mean half-agg groups could hit size limits that would put a ceiling on n?

I don't know of any limits applying in this situation. The 520b stack element size limit doesn't apply. The 10000 byte script size limit doesn't apply. Is there some other limit on witness sizes?

Is there a reason you went with this design with a growing variable-size half-agg signature attached to one input, rather than the one i was expecting to see, where you distribute the nonce components across the individual inputs' witnesses?

This approach would have the added bonus that all the keyspend witness elements will become fixed-size (33 bytes for half-agg placeholders, 65 bytes for half-agg finals, i think), making parsing a little easier.

@fjahr

fjahr commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

Thanks a lot for the review and posting those ideas @conduition! Your last question sent me down a rabbit hole that ended in another big revision of the draft and I think it's another great improvement.

Nit: It's unusual to document the last element of an object's encoding first.

Right, that's a left-over from my previous edits. In my latest edits (see further below) I fixed the ordering.

So there will be some change needed during signing (otherwise replay can occur), but still changing a single byte is pretty minimal. Perhaps that one byte is still worth mentioning?

You are right that a wallet has to recognize the new output type, so "no new signing logic" is meant as the sighash and signature code specifically and the reference point that I was comparing to in this case was a theoretical P2TRv2 that only add PQC but doesn't add CISA. I should have made that more clear. But on the replay concern: the witness version is in the message through the committed scriptPubKey, so an implementation that wrongly assumes v1 there should produce an invalid signature and replaying should be prevented through the spk commitment.

Crazy idea, but could you flip this logic on its head, and swap the signature message functions of the "opted out" and "half-agg" signatures?

It's an interesting idea but I don't think it's worth it. The adaptor footgun is not great but the deal breaker IMO would be witness maleability. If third parties could fold plain signatures in the mempool, the same transaction would validly exist in multiple witness encodings. Wtxids would change in flight and that would degrade a lot of stuff that we are doing in P2P and local optimization, things like tx relay, compact blocks and caching. L2 protocols like Lightning would likely also have a lot of work to do to adapt to this and there would likely be security issues from this as well.

I don't know of any limits applying in this situation. [...] Is there some other limit on witness sizes?

Correct, nothing should bind this below the transaction weight limits afaik. But your related comment answered below made this question moot anyway, I think :)

Is there a reason you went with this design with a growing variable-size half-agg signature attached to one input, rather than the one i was expecting to see, where you distribute the nonce components across the individual inputs' witnesses?

No good reason, as it turns out. I think it is a great idea. I worked through this encoding and it indeed makes every element fixed-size, and distributes the witness weight of the aggregate almost evenly across the group. That nicely dissolves the question of who pays for the final input's extra weight. And it allowed me to go even further: these members need no marker at all anymore since their lengths are disjoint from everything else, and full-agg members can shrink to an empty witness element because of that. The marker overhead can be reduced to one byte per group which is on the final input only. And this also means of course we save one weight unit per member (-1 for the last). Here is another branch with these latest ideas implemented: fjahr/bips@cisa...cisa-plain-optout-split-halfagg and here is the final BIP460 after both revisions: https://github.com/fjahr/bips/blob/0aac2460376dd1acaaf5ea4da7dd600ee6e681fb/bip-0460.mediawiki

More awesome feedback like this is very welcome before I update the PR.

@fjahr

fjahr commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

I didn't receive any negative feedback to the latest changes of the scheme so I have pushed it here now after spending some more time with it and making some minor improvements to the text compared to the draft versions linked above.

@fjahr

fjahr commented Aug 29, 2026

Copy link
Copy Markdown
Contributor Author

Just updated the bitcoin core reference implementation branch

@fjahr

fjahr commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

Updated due to the change in the tagged hashes in BIP458 and BIP459.

MrHodlX added a commit to MrHodlX/entropylab that referenced this pull request Oct 6, 2026
Until a soft fork defines them, outputs to SegWit v2-v16, and to v1
programs that are not 32 bytes, can be spent by anyone. Draft BIP460
(bitcoin/bips#2212) proposes v2 (bc1z...). The PSBT diagram showed these
as a plain "script" with no warning. A v0 program that is not 20 or 32
bytes can never be spent, and the diagram showed that the same way.

witnessProgramNote() classifies an output script against BIP141, BIP341
and BIP350, with P2A from BIP-433. It returns nothing for defined or
non-witness scripts. Otherwise the diagram labels the output (SegWit vN
(not active), SegWit v1 N-byte (undefined), P2A (anchor), SegWit v0 N-byte
(unspendable)), and the editor summary adds one note per output. The notes
never block export, since BIP350 says wallets must be able to pay future
versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdLdXojMnf41tg3dXaTMNH

@PeterXMR PeterXMR left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Two small issues found while checking the vectors and examples against the spec text. The first is worth fixing before merge since it is a vector/spec mismatch; the second is just arithmetic in the examples.

Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460.mediawiki Resolved
Comment thread bip-0460.mediawiki Resolved
MrHodlX added a commit to MrHodlX/entropylab that referenced this pull request Oct 14, 2026
Until a soft fork defines them, outputs to SegWit v2-v16, and to v1
programs that are not 32 bytes, can be spent by anyone. Draft BIP460
(bitcoin/bips#2212) proposes v2 (bc1z...). The PSBT diagram showed these
as a plain "script" with no warning. A v0 program that is not 20 or 32
bytes can never be spent, and the diagram showed that the same way.

witnessProgramNote() classifies an output script against BIP141, BIP341
and BIP350, with P2A from BIP-433. It returns nothing for defined or
non-witness scripts. Otherwise the diagram labels the output (SegWit vN
(not active), SegWit v1 N-byte (undefined), P2A (anchor), SegWit v0 N-byte
(unspendable)), and the editor summary adds one note per output. The notes
never block export, since BIP350 says wallets must be able to pay future
versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdLdXojMnf41tg3dXaTMNH
MrHodlX added a commit to MrHodlX/entropylab that referenced this pull request Oct 18, 2026
Until a soft fork defines them, outputs to SegWit v2-v16, and to v1
programs that are not 32 bytes, can be spent by anyone. Draft BIP460
(bitcoin/bips#2212) proposes v2 (bc1z...). The PSBT diagram showed these
as a plain "script" with no warning. A v0 program that is not 20 or 32
bytes can never be spent, and the diagram showed that the same way.

witnessProgramNote() classifies an output script against BIP141, BIP341
and BIP350, with P2A from BIP-433. It returns nothing for defined or
non-witness scripts. Otherwise the diagram labels the output (SegWit vN
(not active), SegWit v1 N-byte (undefined), P2A (anchor), SegWit v0 N-byte
(unspendable)), and the editor summary adds one note per output. The notes
never block export, since BIP350 says wallets must be able to pay future
versions.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JdLdXojMnf41tg3dXaTMNH
@fjahr

fjahr commented Oct 21, 2026

Copy link
Copy Markdown
Contributor Author

Thanks @PeterXMR, good catches. I fixed all of them per your suggestions.

@fametrano fametrano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A validator I wrote from the BIP's text agrees with every vector at ca1312e, but only one vector catches a verifier that hashes an undefined sighash byte instead of refusing it, and none spends a P2SH-wrapped v2 program.

I wrote it on btclib, with my BIP458 and BIP459 code from #2205 and #2210, and switched its 25 rules off one at a time to see which vector notices. All 53 consensus vectors give the stated result and reason, and all 59 checks on the wallet vectors pass. A vector catches each rule except two checks that later steps repeat.

Only member-sighash-undefined catches the undefined-sighash rule, because only it is signed over the message that hashes its byte, as Bitcoin Core's taproot unk_hashtype vectors are. The inline suggestions re-sign optout-sighash-undefined and sighash-value-undefined over the message that hashes their byte, add a 66-byte half-aggregation final with sighash byte 0xbc, and add a P2SH-wrapped v2 spend next to program-not-32-bytes. Each is a generator change plus the JSON it emits; regenerating with the patched script reproduces the suggested JSON byte for byte, and the validator agrees with all 55 vectors. I can share the code.

Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460/test-vectors.py Resolved
Comment thread bip-0460/consensus-test-vectors.json Resolved
Comment thread bip-0460/consensus-test-vectors.json Resolved
Comment thread bip-0460/consensus-test-vectors.json Resolved
Comment thread bip-0460/consensus-test-vectors.json Resolved
@fjahr

fjahr commented Nov 2, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the review, addressed the comments and updated the BIP 459 reference code included here.

@jonatack jonatack 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.

ACK modulo rebase for merge of 458

@fjahr

fjahr commented Nov 3, 2026

Copy link
Copy Markdown
Contributor Author

Added two test vectors based on core pull review. Will still need to rebase anyway after 459 is merged.

@jonatack

jonatack commented Nov 3, 2026

Copy link
Copy Markdown
Member

Ready for post-459-merge rebase.

@fjahr

fjahr commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Ready for post-459-merge rebase.

Done 🥳

@jonatack jonatack 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.

ACK

The 2 new test vectors are valid and correct.

The witness v2 collision with BIP 360 can be resolved by a later update or coordination before activation / first activation and isn't a blocker to merge in draft status.

@jonatack
jonatack merged commit d5ca385 into bitcoin:master Nov 4, 2026
4 checks passed
@fametrano

Copy link
Copy Markdown
Contributor

Two corrections to my review of ca1312e. First, the wallet vectors have 56 checks, not 59; all 56 pass, also on the merged tree.

Second, that review said all 53 consensus vectors "give the stated result and reason", but I had compared only results. I have now compared reasons. Of the 34 invalid vectors, 21 fail in my validator on the stated rule. 11 fail on the signature, and a separate check showed the stated cause holds in each. In one of them, program-offcurve-optout, input 0's r is not a valid x coordinate either, and my validator stops there (fametrano#2). My validator rejects the other two, halfagg-two-finals and fullagg-two-finals, as an input after the group's final, which they also are, rather than as a second final.

Scripts and outputs: https://gist.github.com/fametrano/2a66f0b0064f4bf754edaf48bda44cdc/c4fea95b9d10bd7e79ec25ce2709043655db80fa

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants