bip-0375: fix P2WPKH scriptPubKeys and signatures in test vectors #2316

pull fametrano wants to merge 3 commits into bitcoin:master from fametrano:bip375-p2wpkh-vectors changing 2 files +125 −123
  1. fametrano commented at 6:39 PM on September 29, 2026: contributor

    Except in the vector #2315 added, the P2WPKH inputs in BIP-375's test vectors cannot be spent by the keys they carry, and 42 of the 43 signatures in the vectors do not verify. Each of those P2WPKH programs is SHA256(pubkey)[:20] instead of HASH160(pubkey). The test runner does not check signatures, so it does not catch this.

    This PR sets each P2WPKH program to HASH160(pubkey) and makes the signatures again: BIP 143 for P2WPKH and P2SH-P2WPKH, legacy for P2PKH. The vector for a non-SIGHASH_ALL signature had a SIGHASH_ALL signature; it now has a SIGHASH_NONE one, matching its PSBT_IN_SIGHASH_TYPE. The three signatures with no defined sighash, on the two segwit v2 inputs and in the vector without PSBT_OUT_SCRIPT, are removed; the one in the vector #2310 added has a commit of its own. The other 40 now verify, and the test runner's output is unchanged: 44 passed. #2317 makes the runner check the signatures. A separate commit sets Version 0.1.5 with its changelog entry; 0.1.6 is #2324's, and whichever of the two lands second rebases its version if needed.

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

  2. fametrano force-pushed on Sep 29, 2026
  3. fametrano force-pushed on Oct 25, 2026
  4. fametrano force-pushed on Nov 4, 2026
  5. murchandamus commented at 6:37 PM on November 5, 2026: member
  6. fametrano force-pushed on Nov 5, 2026
  7. jonatack added the label Tests on Nov 9, 2026
  8. jonatack commented at 4:36 PM on November 9, 2026: member

    ACK

    Prerequisite for #2317.

    A changelog entry might not be strictly required but could be good, here or in the follow-up #2317.

  9. jonatack added the label Pending acceptance on Nov 9, 2026
  10. fametrano force-pushed on Nov 10, 2026
  11. fametrano commented at 10:25 PM on November 10, 2026: contributor

    Added 0.1.4 with a changelog entry here, and #2317 adds its line to the same entry; this push also drops the segwit v2 signature from #2310's new vector, in its own commit, since no sighash is defined for it.

  12. bip-0375: fix P2WPKH scriptPubKeys and signatures in test vectors
    Except in the In Progress vector added in 0.1.4, the P2WPKH inputs of
    the test vectors spend a witness program equal to SHA256(pubkey)[:20]
    instead of HASH160(pubkey), so the key each input carries cannot spend
    it. None of the other vectors' ECDSA signatures verifies against the
    transaction its PSBT describes, whatever the input type. The reference
    validator does not check signatures, so no test fails.
    
    Set every P2WPKH witness program to HASH160 of the input's public key,
    in PSBT_IN_WITNESS_UTXO and in the supplementary witness_utxo and
    prevout_scriptpubkey. Re-sign the PSBT_IN_PARTIAL_SIG signatures
    deterministically (RFC 6979, low S): BIP 143 for P2WPKH and P2SH-P2WPKH,
    the legacy signature hash for P2PKH. Where an input sets
    PSBT_IN_SIGHASH_TYPE, its signature uses that type, as BIP 174
    requires.
    
    Two vectors carried a signature with no defined signature hash: one on
    a segwit v2 input, one in the vector whose output lacks PSBT_OUT_SCRIPT.
    Remove both signatures, and mark the segwit v2 input as not signed in
    the supplementary material. Both vectors still fail for their stated
    reason.
    
    Inside the PSBTs only PSBT_IN_WITNESS_UTXO and PSBT_IN_PARTIAL_SIG
    change, and the test runner's result for every vector is unchanged.
    4e1e6e5505
  13. bip-0375: drop the segwit v2 signature from the non-witness UTXO vector
    No signature hash is defined for segwit v2. The previous commit removed
    the same signature from the other segwit v2 vector. The validator still
    rejects the input for its segwit version.
    1d9b85daf3
  14. bip-0375: add 0.1.5 changelog for P2WPKH test vector fix 37c30cf98b
  15. fametrano force-pushed on Nov 11, 2026

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

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