Repository navigation
Conversation
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 stored 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 and for the bare OP_2 input. 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.
fametrano
force-pushed
the
bip375-p2wpkh-vectors
branch
from
September 29, 2026 19:57
80a0698 to
d4d3e08
Compare
This was referenced Sep 29, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The P2WPKH inputs in BIP-375's test vectors cannot be spent by the keys they carry, and none of the 42 signatures in the vectors verifies. Each P2WPKH program is
SHA256(pubkey)[:20]instead ofHASH160(pubkey), and the reference validator does not check signatures, so no test catches it.This PR repairs the file in place. Each P2WPKH program becomes
HASH160(pubkey). The signatures are re-made with RFC 6979 and low S, under BIP 143 for P2WPKH and P2SH-P2WPKH and under the legacy sighash for P2PKH and the bare input. TheSIGHASH_NONEvector now has aSIGHASH_NONEsignature, as BIP 174 requires. The two signatures with no defined sighash, on the segwit v2 input and in the vector missingPSBT_OUT_SCRIPT, are removed; both vectors still fail for the same reason. The other 40 signatures now verify, and the runner's-vvoutput is unchanged: 43 passed. I did not regenerate the file, because that would also change unrelated values such as the prevout txids.#2317, which depends on this PR, makes the test runner check these signatures: on master's vectors it reports 39 of 43 failing, on this PR's none. #2256 and #2207 edit some of the same vectors, and their P2WPKH inputs have the same defect. Whichever of this PR and #2256 lands second needs a rebase and the same repair.
Made with my usual tools: a computer, the Internet and an LLM. The mistakes, as usual, are all mine.