Skip to content

BIP352: add taproot key-path spend with annex vector - #2337

Open
Eunovo wants to merge 2 commits into
bitcoin:masterfrom
Eunovo:bip352-key-spend-annex-vector
Open

Eunovo wants to merge 2 commits into
bitcoin:masterfrom
Eunovo:bip352-key-spend-annex-vector

Conversation

@Eunovo

@Eunovo Eunovo commented Oct 23, 2026

Copy link
Copy Markdown
Contributor

Add a BIP-352 test vector where a taproot input is spent via the key path with an annex (2-item witness). The annex must be stripped before deciding between key-path and script-path spends, so the input is still eligible and all expected values match the plain key-path case.

@theStack

Copy link
Copy Markdown
Contributor

Concept ACK

@fametrano

Copy link
Copy Markdown

btclib-wallet, a BIP352 implementation I maintain, reproduces the new vector at 48493fa: sending and receiving both match the expected values.

I ran its BIP352 tests at commit 3b88201 with this file in place of its copy of the vectors, and all tests on the new vector pass.

The vector does not catch a missing annex strip, though. With the strip removed from btclib-wallet, those tests still pass: the annex 0x5000 is taken for a control block, but not one with the NUMS internal key, so the input stays eligible. With the annex set to 0x50 followed by BIP341's NUMS key H, 0x5050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0, the same change fails on both sending and receiving, and the unmodified code still matches the expected values. Only the witness changes; its signature has to be redone, since BIP341 signs the annex.

@jonatack jonatack added the Tests label Oct 23, 2026

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

Concept ACK

Agree with @fametrano's stronger annex (0x50 + BIP-341 NUMS point H), see suggestions below.

Comment thread bip-0352/send_and_receive_test_vectors.json Outdated
Comment thread bip-0352/send_and_receive_test_vectors.json Outdated
@Eunovo
Eunovo force-pushed the bip352-key-spend-annex-vector branch from 48493fa to 28205c4 Compare October 24, 2026 06:30
@Eunovo

Eunovo commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

The vector does not catch a missing annex strip, though. With the strip removed from btclib-wallet, those tests still pass: the annex 0x5000 is taken for a control block, but not one with the NUMS internal key, so the input stays eligible. With the annex set to 0x50 followed by BIP341's NUMS key H, 0x5050929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0, the same change fails on both sending and receiving, and the unmodified code still matches the expected values. Only the witness changes; its signature has to be redone, since BIP341 signs the annex.

Thanks for the review. Done!

@theStack

Copy link
Copy Markdown
Contributor

LGTM, can you rebase on master (this PR branch is still based on BIP-352 version 1.1.0 from March), and add a small changelog entry with bumped PATCH version? (see e.g. #2142 for an example).

Add a BIP-352 test vector where a taproot input is spent via the key path with an annex (2-item witness). The annex must be stripped before deciding between key-path and script-path spends, so the input is still eligible and all expected values match the plain key-path case.

The annex is 0x50 followed by the BIP341 NUMS point H, so an implementation that fails to strip it reads it as a control block with the NUMS internal key and wrongly skips the input.
@Eunovo
Eunovo force-pushed the bip352-key-spend-annex-vector branch from 28205c4 to 68927e5 Compare October 25, 2026 16:26
Add key-spend with annex test vector log
@Eunovo
Eunovo force-pushed the bip352-key-spend-annex-vector branch from 68927e5 to b19b139 Compare October 25, 2026 17:05
Comment thread bip-0352.mediawiki

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

تم

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

نم

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.

5 participants