BIP-174: test data: make the witnessScript in the invalid-key case match its P2WSH hash #2238

pull fametrano wants to merge 1 commits into bitcoin:master from fametrano:bip174-witnessscript-vector-pubkey changing 1 files +2 −2
  1. fametrano commented at 10:46 PM on August 5, 2026: contributor

    In the "invalid output witnessScript typed key" case, the value no longer hashes to the redeemScript's P2WSH program: 65f0b3dd trimmed it to its last six bytes while fixing a short read. This restores the original 37-byte script as the value and keeps the key one byte too long — the only defect, same layout the redeemScript case already uses, same total length.

    Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.

  2. fametrano commented at 9:24 AM on September 7, 2026: contributor

    @achow101 as BIP174's author, could you take a look? In short: the "invalid output witnessScript typed key" vector is meant to fail on the key length alone, but the pushed key in its witnessScript is not a point on secp256k1, so an implementation that validates the key and skips the length check rejects the case for the wrong reason and the missing check goes unnoticed. This swaps in a valid point; nothing else changes and CI is green.

  3. fametrano renamed this:
    BIP-174: test data: a public key in the witnessScript case
    BIP-174: test data: fix off-curve pubkey in the witnessScript case
    on Sep 11, 2026
  4. fametrano renamed this:
    BIP-174: test data: fix off-curve pubkey in the witnessScript case
    BIP-174: test data: the witnessScript case should fail on the key length, can fail on an off-curve pubkey
    on Sep 11, 2026
  5. fametrano renamed this:
    BIP-174: test data: the witnessScript case should fail on the key length, can fail on an off-curve pubkey
    BIP-174: test data: fix off-curve pubkey in the witnessScript case
    on Sep 11, 2026
  6. fametrano force-pushed on Sep 12, 2026
  7. fametrano force-pushed on Sep 19, 2026
  8. fametrano force-pushed on Sep 23, 2026
  9. murchandamus requested review from achow101 on Sep 23, 2026
  10. murchandamus added the label Bug fix on Sep 23, 2026
  11. achow101 commented at 11:34 PM on September 23, 2026: member

    Tend to NACK

    The pr description is needlessly verbose and confusing. I've re-read it 5 times and do not understand what the actual problem is. What do curve points have to do with witness scripts? The keydata for a PSBT_OUT_WITNESS_SCRIPT does not contain any interpretable data, and the point of the test is to make sure that parsers are checking the length and not interpreting any data.

  12. jonatack commented at 11:49 PM on September 23, 2026: member

    FWIW, per Grok the description is confusing but the fix is correct: https://grok.com/share/bGVnYWN5_3c8755f5-bf63-4673-b6cf-6942c3a71cf1.

  13. fametrano renamed this:
    BIP-174: test data: fix off-curve pubkey in the witnessScript case
    BIP-174: test data: make the witnessScript in the invalid-key case match its P2WSH hash
    on Sep 24, 2026
  14. fametrano commented at 5:27 PM on September 24, 2026: contributor

    You're right about the curve points — the keydata is filler, so nothing off-curve is reachable; my description was wrong. The real defect: since 65f0b3dd the witnessScript value no longer hashes to the redeemScript's P2WSH program. This restores the original 37-byte script as the value and keeps the key one byte too long — the same layout the redeemScript case already uses. Happy to close if that check doesn't belong here.

  15. fametrano force-pushed on Sep 24, 2026
  16. fametrano force-pushed on Sep 26, 2026
  17. BIP-174: test data: make the witnessScript in the invalid-key case match its P2WSH hash
    In the "PSBT with invalid output witnessScript typed key" case, the
    value of the PSBT_OUT_WITNESS_SCRIPT record no longer hashes to the
    P2WSH program in the output's redeemScript: 65f0b3dd trimmed it to its
    last six bytes while fixing a short read.
    
    Re-encode the record as `02 0100 25 <script>`: the key stays one byte
    too long, which is what the case tests, and the value is the original
    37-byte script again. Same total length, same layout as the "invalid
    output redeemScript typed key" case.
    b7c7d7c199
  18. fametrano force-pushed on Sep 27, 2026


achow101

Labels

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-10-14 03:10 UTC

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