BIP322: update test vectors #2377

pull guggero wants to merge 1 commits into bitcoin:master from guggero:bip322-update-test-vectors changing 4 files +968 −307
  1. guggero commented at 9:17 AM on December 3, 2026: contributor

    Updates the test vectors to the latest version of the btcd pull request they are generated by (btcsuite/btcd#2521), which grew considerably during review:

    • Every error vector now states the verification state that is expected for it, invalid or inconclusive.
    • The basic vectors gain valid edge cases and more hand-picked error cases.
    • The generated error vectors move to their own file and now cover the consensus, required and upgradeable rules as well as the structure of to_sign for all three variants. That includes the taproot upgrade mechanisms that were added to the upgradeable rules in version 2.1.0.

    Bump the version to 2.1.1 and add a changelog entry.

  2. BIP-0322: update test vectors
    Updates the test vectors to the latest version of the btcd pull request
    they are generated by (btcsuite/btcd#2521), which grew considerably
    during review:
    
     - Every error vector now states the verification state that is
       expected for it, invalid or inconclusive.
     - The basic vectors gain valid edge cases and more hand-picked error
       cases.
     - The generated error vectors move to their own file and now cover the
       consensus, required and upgradeable rules as well as the structure
       of to_sign for all three variants. That includes the taproot upgrade
       mechanisms that were added to the upgradeable rules in version
       2.1.0.
    
    Bump the version to 2.1.1 and add a changelog entry.
    5342ee112b
  3. guggero renamed this:
    BIP-0322: update test vectors
    BIP322: update test vectors
    on Dec 3, 2026
  4. jonatack added the label BIP Update by Owner on Dec 3, 2026
  5. jonatack added the label Tests on Dec 3, 2026
  6. in bip-0322/generated-negative-test-vectors.json:362 in 5342ee112b
     357 | +      "message": "probe",
     358 | +      "address": "bc1qft5p2uhsdcdc3l2ua4ap5qqfg4pjaqlp250x7us7a8qqhrxrxfsq2gp3gp",
     359 | +      "signature": "pofcHNidP8BAGYAAAAAAmYb1fFuDTtm8ZysRgBkdesyTwY3KY18Cy3BNkDnQv0NAAAAAAAAAAAARAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABAAAAAAAAAAABagAAAAABCRFkaWZmZXJlbnQgbWVzc2FnZQABAIAAAAAAAQAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA/////yIAIAqIRqwkJjB2nFdwnBnS+JBpG5ok8MliEKBYUI8jKZgEAAAAAAEAAAAAAAAAACIAIEroFXLwbhuI/VztehoACUVDLoPhVR5vch7pwAuMwzJgAAAAAAEBKwAAAAAAAAAAIgAgSugVcvBuG4j9XO16GgAJRUMug+FVHm9yHunAC4zDMmABCAMBAVEAAQErAQAAAAAAAAAiACBK6BVy8G4biP1c7XoaAAlFQy6D4VUeb3Ie6cALjMMyYAEIAwEBUQAA",
     360 | +      "expected_result": "invalid",
     361 | +      "error_substr": "generic signed message field"
     362 | +    },
    


    jonatack commented at 6:08 PM on December 3, 2026:

    Possible spec gap here?

    In this vector "proof-of-funds generic signed message does not match", to_sign.vin[0] validly spends to_spend("probe") and both OP_TRUE P2WSH inputs succeed; the only mismatch is global key 0x09 (PSBT_GLOBAL_GENERIC_SIGNED_MESSAGE = "different message").

    However, Verification Process in bip-0322.mediawiki never mentions checking 0x09 (line 245 says "confirm all fields are set as specified above", while 0x09 isn't introduced until line 333 under PSBT-based signing, and all 3 valid PoF vectors in generated-test-vectors.json omit 0x09). A verifier implementing Verification Process as written would accept this vector as valid.

    Could we explicitly state in Verification Process that if PSBT_GLOBAL_GENERIC_SIGNED_MESSAGE is present on a pof PSBT it must match m?

  7. in bip-0322/basic-test-vectors.json:249 in 5342ee112b
     244 | +      "message": "Hello World",
     245 | +      "address": "bc1ppv609nr0vr25u07u95waq5lucwfm6tde4nydujnu8npg4q75mr5sxq8lt3",
     246 | +      "signature": "fulAAAAAAABAQZ52yMWanylo3mYung2wzGYu6l1UmV7Eo2xCNKfbmYhAAAAAAAAAAAAAQAAAAAAAAAAAWoBQeWGTijlm2zsFP/scDgJ1Z9oJGXI04hbwDN0aSYV6dduty9fJukSljKih3NhPLm+rR8nrHfymhOThSP/NTC+NgsCAAAAAA==",
     247 | +      "expected_result": "invalid",
     248 | +      "error_substr": "invalid sighash flag"
     249 | +    },
    


    jonatack commented at 6:11 PM on December 3, 2026:

    Minor: in "P2TR Schnorr signature with incorrect explicit sighash byte..."

    The 64-byte Schnorr signature here actually signs SIGHASH_ALL (0x01), with only the trailing sighash byte flipped to 0x02 (SIGHASH_NONE). Because it already fails BIP-341 consensus Schnorr verification in step 1, a verifier that forgets to enforce BIP-322's step 3 sighash rule on P2TR key-path spends will still reject it.

    The rule is already properly isolated by "taproot key-path simple signature uses SIGHASH_SINGLE" in generated-negative-test-vectors.json, so this isn't a coverage gap, but re-signing this vector with SIGHASH_NONE (0x02) would make it consistent with the other sighash vectors.

  8. in bip-0322/generated-negative-test-vectors.json:34 in 5342ee112b
      29 | +      "message": "probe",
      30 | +      "address": "bc1qft5p2uhsdcdc3l2ua4ap5qqfg4pjaqlp250x7us7a8qqhrxrxfsq2gp3gp",
      31 | +      "signature": "fulAgAAAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAP////8A/////wEAAAAAAAAAAAFqAAAAAN6tvu8=",
      32 | +      "expected_result": "invalid",
      33 | +      "error_substr": "more data present after parsing input"
      34 | +    },
    


    jonatack commented at 6:12 PM on December 3, 2026:

    Minor: in "full transaction contains trailing data"

    After stripping the 4 trailing bytes (deadbeef), the underlying to_sign still spends 0000…0000:ffffffff (not to_spend:0) with an empty witness, so a lenient parser that ignores trailing data still rejects it as invalid.

    Building this from an otherwise valid ful to_sign + deadbeef (like "proof-of-funds packet contains trailing data" right below it, which becomes valid once deadbeef is trimmed) would cleanly isolate the trailing-data check.

  9. in bip-0322/basic-test-vectors.json:291 in 5342ee112b
     286 | +      "signature": "smpAQK0UQ==",
     287 | +      "expected_result": "inconclusive",
     288 | +      "error_substr": "inconclusive"
     289 | +    },
     290 | +    {
     291 | +      "description": "tx version 1 is inconclusive",
    


    jonatack commented at 6:13 PM on December 3, 2026:

    Nit: This entry is byte-for-byte identical to "full transaction version 1 is inconclusive" in generated-negative-test-vectors.json (lines 140–146), and basic-test-vectors.json already covers tx version 1 above at lines 203–209 ("to_sign has tx version 1 (must be 0 or 2)"). Looks like a leftover from splitting out the generated negative vectors.

    (Note: lines 251 and 283 also share the same signature and address as generated-negative-test-vectors.json lines 44 and 116 with only "Hello World" vs "probe" changed, though keeping those two may be intentional so basic-test-vectors.json remains self-contained.)

  10. in bip-0322/basic-test-vectors.json:299 in 5342ee112b
     294 | +      "signature": "fulAQAAAAABAWYb1fFuDTtm8ZysRgBkdesyTwY3KY18Cy3BNkDnQv0NAAAAAAAAAAAAAQAAAAAAAAAAAWoBAVEAAAAA",
     295 | +      "expected_result": "inconclusive",
     296 | +      "error_substr": "inconclusive"
     297 |      }
     298 |    ]
     299 |  }
    


    jonatack commented at 6:14 PM on December 3, 2026:

    nit, missing EOL at the end

  11. jonatack commented at 6:19 PM on December 3, 2026: member

    Looks great. Independently verified all 139 test vectors by Neon (High), Opus 5.5 (High), and Grok 4.7 (Heavy).

    Left a few inline comments that were found by Neon and verified by Opus 5.5, feel free to ignore.

    • Spec alignment (main item): "proof-of-funds generic signed message does not match" relies on checking PSBT_GLOBAL_GENERIC_SIGNED_MESSAGE (0x09) during verification, which isn't currently specified in Verification Process.

    • Vector isolation (minor): Two negative vectors already fail earlier consensus/structure checks even if the targeted rule isn't enforced.

    • Dupe nit: The final entry in basic-test-vectors.json duplicates both an earlier entry in the same file and "full transaction version 1 is inconclusive" in generated-negative-test-vectors.json.

    Let me know if you prefer to merge as-is, or update.


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-04 10:10 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me