Skip to content

BIP-375: allow SIGHASH_DEFAULT, harden validator, regenerate vectors - #2389

Open
macgyver13 wants to merge 12 commits into
bitcoin:masterfrom
macgyver13:bip375-vector-regen
Open

macgyver13 wants to merge 12 commits into
bitcoin:masterfrom
macgyver13:bip375-vector-regen

Conversation

@macgyver13

Copy link
Copy Markdown
Contributor

This PR allows SIGHASH_DEFAULT for taproot inputs, hardens the BIP-375 reference validator and regenerates bip375_test_vectors.json from bip375-test-generator v1.2.0. It builds on and replaces #2316, #2317 and #2324 by @fametrano, #2318 by @myetcd and #2321 by @gophersg. The regenerated vectors derive from two BIP-39 test wallets, so their prevout scripts match the wallet keys and a real signer can reproduce the signatures. Vector file 1.2.0 has 26 valid and 51 invalid vectors (1.1.1 had 20 and 24).

This is groundwork for a role-based test strategy. Replacing checks with task is the first step. Each vector now names the role step it targets (deserialize, sign or finalize) and whether that step should succeed. A follow-up PR will add workflow vectors that take a PSBT through each BIP-375 role and check every transition.

Here is a categorical overview of each of the 12 commits.

Spec change

  1. Allow taproot SIGHASH_DEFAULT and check signature sighash types. This is the only change to the specification, and implementors have read the spec differently. BIP-341 defines SIGHASH_DEFAULT as committing to the same transaction data as SIGHASH_ALL, and BIP-352 recommends it for taproot inputs. The validator now also checks the sighash type of each signature, so a non-SIGHASH_ALL signature fails even when PSBT_IN_SIGHASH_TYPE is omitted. The BIP version moves to 0.2.0.

Make the validator check what a signer checks

  1. Raise ValidationError from the checks and report the failing one.
  2. Check signing order and TX_MODIFIABLE flags. No input may be signed until every SP output has PSBT_OUT_SCRIPT, and the Inputs/Outputs Modifiable flags must be cleared once one is set. BIP-370 allows omitting PSBT_GLOBAL_TX_MODIFIABLE, and the validator no longer rejects that.

Edge cases found in open PRs and review

  1. Reject inputs with missing UTXO or redeem script, from bip-0375: reject inputs with missing UTXO or redeem script instead of crashing #2324. The output index check is kept without its vector. An index past the outputs is a malformed PSBT rather than a BIP-375 rule.
  2. Verify per-input DLEQ proofs before output scripts are set, from BIP375: require DLEQ proof for every per-input ECDH share #2321. Its missing proof vector is left out. The existing missing proof vector and the new invalid proof vectors cover the rule.
  3. Validate scan key keydata lengths, from BIP375: validate scan-key keydata lengths #2318. One vector covers the PSBT_IN_SP_ECDH_SHARE case in place of the unit tests in BIP375: validate scan-key keydata lengths #2318.
  4. Check that SP keys and ECDH shares are valid points.
  5. Fail ECDH shares with no eligible key or an infinite key sum. @fametrano reported both.
  6. Vendor Core's pure-Python RIPEMD-160 for hash160, as bip-0375: check test vector signatures in the test runner #2317 does.
  7. Check P2SH redeem scripts and skip uncompressed P2PKH inputs. @fametrano found these edge cases in bip-0375: check test vector signatures in the test runner #2317.

Regenerate the vectors

  1. Regenerate the test vectors, replacing checks with task and fixing the P2WPKH programs and signatures from bip-0375: fix P2WPKH scriptPubKeys and signatures in test vectors #2316.

Bind input keys

  1. Bind input keys to scriptPubKeys. It follows the regeneration because the 1.1.1 P2WPKH programs did not commit to their keys. A reviewer of the @caravan/psbt BIP-375 PR found this gap and bip-0375: check test vector signatures in the test runner #2317 noted a similar one.
python test_runner.py -vv (77 passed, 0 failed, 0 skipped)
Description: BIP-375 Test Vectors
Version: 1.2.0

Invalid PSBTs: 51
psbt structure: missing PSBT_OUT_SP_V0_INFO field when PSBT_OUT_SP_V0_LABEL set
  PSBT_STRUCTURE: Output 0 has PSBT_OUT_SP_V0_LABEL but missing PSBT_OUT_SP_V0_INFO
psbt structure: incorrect byte length for PSBT_OUT_SP_V0_LABEL field
  PSBT_STRUCTURE: Output 0 PSBT_OUT_SP_V0_LABEL has wrong length (1 bytes, expected 4)
psbt structure: incorrect byte length for PSBT_OUT_SP_V0_INFO field
  PSBT_STRUCTURE: Output 0 SP_V0_INFO has wrong length (65 bytes, expected 66)
psbt structure: incorrect byte length for PSBT_IN_SP_ECDH_SHARE field
  PSBT_STRUCTURE: Input 0 ECDH share value has wrong length (32 bytes, expected 33)
psbt structure: incorrect byte length for PSBT_IN_SP_ECDH_SHARE scan key
  PSBT_STRUCTURE: Input 0 ECDH share scan key has wrong length (32 bytes, expected 33)
psbt structure: incorrect byte length for PSBT_IN_SP_DLEQ field
  PSBT_STRUCTURE: Input 0 DLEQ proof has wrong length (63 bytes, expected 64)
psbt structure: PSBT_IN_SP_ECDH_SHARE scan key is not a valid point
  PSBT_STRUCTURE: Input 0 ECDH share scan key is not a valid point
psbt structure: PSBT_IN_SP_ECDH_SHARE value is not a valid point
  PSBT_STRUCTURE: Input 0 ECDH share value is not a valid point
psbt structure: PSBT_OUT_SP_V0_INFO scan key is not a valid point
  PSBT_STRUCTURE: Output 0 SP_V0_INFO scan key is not a valid point
psbt structure: PSBT_OUT_SP_V0_INFO spend key is not a valid point
  PSBT_STRUCTURE: Output 0 SP_V0_INFO spend key is not a valid point
psbt structure: missing PSBT_OUT_SCRIPT field when sending to non-sp output
  PSBT_STRUCTURE: Output 0 must have either PSBT_OUT_SCRIPT or PSBT_OUT_SP_V0_INFO
ecdh coverage: only one ineligible P2SH multisig input when PSBT_OUT_SCRIPT set for sp output
  ECDH_COVERAGE: Silent payment output present but no ECDH share for scan key
ecdh coverage: missing PSBT_IN_SP_ECDH_SHARE field for input 0 when PSBT_OUT_SCRIPT set for sp output
  ECDH_COVERAGE: Output script set but eligible input 0 missing ECDH share
ecdh coverage: input 1 with no PSBT_IN_WITNESS_UTXO or PSBT_IN_NON_WITNESS_UTXO and no ECDH share
  ECDH_COVERAGE: Input 1 scriptPubKey could not be extracted
ecdh coverage: P2SH input 1 with no PSBT_IN_REDEEM_SCRIPT and no ECDH share
  ECDH_COVERAGE: Input 1 is P2SH and missing redeem script
ecdh coverage: missing PSBT_IN_SP_DLEQ field for input when PSBT_IN_SP_ECDH_SHARE set
  ECDH_COVERAGE: Input 0 ECDH share missing DLEQ proof
ecdh coverage: invalid proof in PSBT_IN_SP_DLEQ field
  ECDH_COVERAGE: Input 0 DLEQ proof verification failed
ecdh coverage: invalid proof in PSBT_IN_SP_DLEQ field when PSBT_OUT_SCRIPT not set for sp output
  ECDH_COVERAGE: Input 0 DLEQ proof verification failed
ecdh coverage: missing PSBT_GLOBAL_SP_DLEQ field when PSBT_GLOBAL_SP_ECDH_SHARE set
  ECDH_COVERAGE: Global ECDH share missing DLEQ proof
ecdh coverage: invalid proof in PSBT_GLOBAL_SP_DLEQ field
  ECDH_COVERAGE: Global DLEQ proof verification failed
ecdh coverage: invalid proof in PSBT_GLOBAL_SP_DLEQ field when PSBT_OUT_SCRIPT not set for sp output
  ECDH_COVERAGE: Global DLEQ proof verification failed
ecdh coverage: PSBT_GLOBAL_SP_DLEQ proven without input 1 (also missing PSBT_IN_BIP32_DERIVATION)
  ECDH_COVERAGE: Input 1 has no PSBT_IN_BIP32_DERIVATION
ecdh coverage: PSBT_GLOBAL_SP_ECDH_SHARE set when the only input is ineligible (P2TR with NUMS internal key)
  ECDH_COVERAGE: Global ECDH share set but no eligible input public key found
ecdh coverage: eligible input keys sum to the point at infinity when PSBT_GLOBAL_SP_ECDH_SHARE set and PSBT_OUT_SCRIPT not set for sp output
  ECDH_COVERAGE: Global eligible input public keys sum to the point at infinity
ecdh coverage: missing PSBT_IN_BIP32_DERIVATION field for input when PSBT_IN_SP_DLEQ set
  ECDH_COVERAGE: Input 0 has no PSBT_IN_BIP32_DERIVATION
ecdh coverage: output 1 missing ECDH share for scan key with one input / three sp outputs (different scan keys)
  ECDH_COVERAGE: Silent payment output present but no ECDH share for scan key
ecdh coverage: input 1 missing ECDH share for output 1 with two inputs / two sp outputs (different scan keys)
  ECDH_COVERAGE: Output script set but eligible input 1 missing ECDH share
ecdh coverage: input 1 missing ECDH share for scan key with two inputs / one sp output
  ECDH_COVERAGE: Output script set but eligible input 1 missing ECDH share
ecdh coverage: P2WPKH PSBT_IN_BIP32_DERIVATION pubkey does not match scriptPubKey
  ECDH_COVERAGE: Input 1 PSBT_IN_BIP32_DERIVATION keys do not match its scriptPubKey
ecdh coverage: P2PKH PSBT_IN_BIP32_DERIVATION pubkey does not match scriptPubKey
  ECDH_COVERAGE: Input 1 PSBT_IN_BIP32_DERIVATION keys do not match its scriptPubKey
ecdh coverage: P2SH-P2WPKH PSBT_IN_BIP32_DERIVATION pubkey does not match scriptPubKey
  ECDH_COVERAGE: Input 1 PSBT_IN_BIP32_DERIVATION keys do not match its scriptPubKey
ecdh coverage: global ECDH share computed from a PSBT_IN_BIP32_DERIVATION pubkey not matching scriptPubKey
  ECDH_COVERAGE: Input 1 PSBT_IN_BIP32_DERIVATION keys do not match its scriptPubKey
ecdh coverage: P2TR input 1 with a NUMS PSBT_IN_TAP_INTERNAL_KEY that does not tweak to scriptPubKey and no ECDH share
  ECDH_COVERAGE: Output script set but eligible input 1 missing ECDH share
ecdh coverage: P2SH-P2WPKH input 1 with a non-P2WPKH PSBT_IN_REDEEM_SCRIPT that does not hash to scriptPubKey and no ECDH share
  ECDH_COVERAGE: Input 1 P2SH redeem script does not match scriptPubKey
input eligibility: segwit version greater than 1 in transaction inputs with sp output
  INPUT_ELIGIBILITY: Input 0 uses segwit version > 1 with silent payments
input eligibility: segwit version greater than 1 supplied via PSBT_IN_NON_WITNESS_UTXO when PSBT_OUT_SCRIPT not set for sp output
  INPUT_ELIGIBILITY: Input 0 uses segwit version > 1 with silent payments
input eligibility: non-SIGHASH_ALL signature on input with sp output
  INPUT_ELIGIBILITY: Input 0 PSBT_IN_SIGHASH_TYPE is non-SIGHASH_ALL (0x02) with silent payments
input eligibility: non-SIGHASH_ALL signature on input with sp output and PSBT_IN_SIGHASH_TYPE omitted
  INPUT_ELIGIBILITY: Input 0 has a non-SIGHASH_ALL signature (0x02) with silent payments
input eligibility: non-SIGHASH_ALL signature on ineligible input with sp output
  INPUT_ELIGIBILITY: Input 1 PSBT_IN_SIGHASH_TYPE is non-SIGHASH_ALL (0x02) with silent payments
input eligibility: non-SIGHASH_ALL signature on ineligible input with sp output and PSBT_IN_SIGHASH_TYPE omitted
  INPUT_ELIGIBILITY: Input 1 has a non-SIGHASH_ALL signature (0x02) with silent payments
input eligibility: non-SIGHASH_ALL signature on taproot input with sp output
  INPUT_ELIGIBILITY: Input 0 PSBT_IN_SIGHASH_TYPE is non-SIGHASH_ALL (0x02) with silent payments
input eligibility: non-SIGHASH_ALL signature on taproot input with sp output and PSBT_IN_SIGHASH_TYPE omitted
  INPUT_ELIGIBILITY: Input 0 has a non-SIGHASH_ALL signature (0x02) with silent payments
input eligibility: SIGHASH_ALL|ANYONECANPAY sighash type on input with sp output
  INPUT_ELIGIBILITY: Input 0 PSBT_IN_SIGHASH_TYPE is non-SIGHASH_ALL (0x81) with silent payments
input eligibility: SIGHASH_DEFAULT sighash type on non-taproot input with sp output
  INPUT_ELIGIBILITY: Input 0 PSBT_IN_SIGHASH_TYPE is non-SIGHASH_ALL (0x00) with silent payments
input eligibility: PSBT_GLOBAL_TX_MODIFIABLE Inputs/Outputs Modifiable flags not cleared when PSBT_OUT_SCRIPT set for sp output
  INPUT_ELIGIBILITY: Output 0 has PSBT_OUT_SCRIPT set for silent payments output but PSBT_GLOBAL_TX_MODIFIABLE Inputs/Outputs Modifiable flags not cleared
input eligibility: input signed before every sp output has PSBT_OUT_SCRIPT
  INPUT_ELIGIBILITY: Input 0 is signed before every silent payment output has PSBT_OUT_SCRIPT
output scripts: P2TR input with NUMS internal key cannot derive sp output
  OUTPUT_SCRIPTS: Output 0 has PSBT_OUT_SCRIPT but missing ECDH share or input pubkeys
output scripts: PSBT_OUT_SCRIPT does not match derived sp output
  OUTPUT_SCRIPTS: Output 0 script doesn't match silent payments derivation
output scripts: two sp outputs (same scan / different spend keys) not sorted lexicographically by spend key
  OUTPUT_SCRIPTS: Output 0 script doesn't match silent payments derivation
output scripts: k values assigned to wrong output indices with three sp outputs (same scan / spend keys)
  OUTPUT_SCRIPTS: Output 1 script doesn't match silent payments derivation
output scripts: PSBT_OUT_SCRIPT set for sp output when the eligible input keys sum to the point at infinity
  OUTPUT_SCRIPTS: Eligible input public keys sum to the point at infinity

Valid PSBTs: 26
can finalize: one P2PKH input single-signer
  All checks passed
can finalize: one P2WPKH input with PSBT_GLOBAL_TX_MODIFIABLE omitted
  All checks passed
can finalize: two inputs single-signer using global ECDH share
  All checks passed
can finalize: two inputs single-signer using per-input ECDH shares
  All checks passed
can finalize: two inputs / two sp outputs with mixed global and per-input ECDH shares
  All checks passed
can finalize: one input / one sp output with both global and per-input ECDH shares
  All checks passed
can finalize: three sp outputs (different scan keys) with multiple global ECDH shares
  All checks passed
can finalize: one P2TR input signed with SIGHASH_DEFAULT
  All checks passed
can finalize: one P2WPKH input / two mixed outputs - labeled sp output and BIP 32 change
  All checks passed
can finalize: one input / two sp outputs - output 0 has no label / output 1 uses label=0 convention for sp change
  All checks passed
can finalize: three sp outputs (same scan key) - output 0 uses label=1, outputs 1 and 2 uses label=2 (same spend key)
  All checks passed
can finalize: two inputs using per-input ECDH shares - only eligible inputs contribute shares (P2SH excluded)
  All checks passed
can finalize: two inputs using global ECDH share - only eligible inputs contribute shares (P2SH excluded)
  All checks passed
can finalize: two mixed input types - only eligible inputs contribute ECDH shares (NUMS internal key excluded)
  All checks passed
can finalize: two mixed input types - only eligible inputs contribute ECDH shares (uncompressed P2PKH excluded)
  All checks passed
can finalize: P2WPKH input with ineligible P2SH multisig input declaring SIGHASH_ALL
  All checks passed
can finalize: three sp outputs (same scan key) - each output has distinct k value
  All checks passed
can finalize: three sp outputs (same scan key) / two regular outputs - k values assigned independently of output index
  All checks passed
can finalize: P2WPKH with decoy PSBT_IN_BIP32_DERIVATION before the matching key
  All checks passed
can finalize: P2PKH with decoy PSBT_IN_BIP32_DERIVATION before the matching key
  All checks passed
in progress: two P2TR inputs, neither is signed
  All checks passed
in progress: one P2TR input / one sp output with no ECDH shares when PSBT_OUT_SCRIPT field is not set
  All checks passed
in progress: two inputs / one sp output, input 1 missing ECDH share when PSBT_OUT_SCRIPT field is not set
  All checks passed
in progress: one input / two sp outputs, input 0 missing ECDH share for output 0 when PSBT_OUT_SCRIPT field is not set
  All checks passed
in progress: two mixed input types - only eligible inputs contribute ECDH shares (bare OP_2 excluded, not a segwit v2 witness program)
  All checks passed
in progress: large PSBT with nine mixed inputs / six outputs - some inputs signed
  All checks passed

Summary: 77 passed, 0 failed, 0 skipped

macgyver13 and others added 12 commits December 4, 2026 16:21
The Signer rules now allow SIGHASH_DEFAULT for a taproot input. Clarify
that the sighash type means PSBT_IN_SIGHASH_TYPE or a signature's type.

The validator accepts SIGHASH_DEFAULT on a taproot input. It also checks
the sighash type of every signature in the PSBT signature fields, not
only PSBT_IN_SIGHASH_TYPE.

Add 7 invalid vectors:
- non-SIGHASH_ALL signature on input with sp output and PSBT_IN_SIGHASH_TYPE omitted
- non-SIGHASH_ALL signature on ineligible input with sp output
- non-SIGHASH_ALL signature on ineligible input with sp output and PSBT_IN_SIGHASH_TYPE omitted
- non-SIGHASH_ALL signature on taproot input with sp output
- non-SIGHASH_ALL signature on taproot input with sp output and PSBT_IN_SIGHASH_TYPE omitted
- SIGHASH_ALL|ANYONECANPAY sighash type on input with sp output
- SIGHASH_DEFAULT sighash type on non-taproot input with sp output

Add 2 valid vectors:
- one P2TR input signed with SIGHASH_DEFAULT
- P2WPKH input with ineligible P2SH multisig input declaring SIGHASH_ALL
… one

The runner runs the checks in order on every vector and reports the
first one that rejects it. It no longer reads the per-vector `checks`
field. A PSBT that does not parse counts as a PSBT Structure failure.

The checks now raise ValidationError and name the failing input
instead of returning a result.
Check two Signer rules in Input Eligibility:
- no input is signed until every sp output has PSBT_OUT_SCRIPT
- the Inputs Modifiable and Outputs Modifiable flags are cleared once a
  PSBT_OUT_SCRIPT is set for an sp output

Now a present PSBT_OUT_SCRIPT counts as set, even when empty. An
omitted PSBT_GLOBAL_TX_MODIFIABLE counts as zero.

Rename 1 invalid vector from
psbt structure: PSBT_GLOBAL_TX_MODIFIABLE field is non-zero...
to
input eligibility: PSBT_GLOBAL_TX_MODIFIABLE Inputs/Outputs Modifiable flags not cleared...

Add 1 invalid vector:
- input signed before every sp output has PSBT_OUT_SCRIPT

Add 1 valid vector:
- one P2WPKH input with PSBT_GLOBAL_TX_MODIFIABLE omitted
Fix the validator so it no longer crashes when an input's scriptPubKey
cannot be found. It now fails the check when an input has no witness or
non-witness UTXO, or when a P2SH input has no redeem script.

Add 2 invalid vectors:
- input 1 with no PSBT_IN_WITNESS_UTXO or PSBT_IN_NON_WITNESS_UTXO and no ECDH share
- P2SH input 1 with no PSBT_IN_REDEEM_SCRIPT and no ECDH share

Based on bitcoin#2324.

Co-authored-by: Ferdinando Ametrano <ferdinando@ametrano.net>
A Signer relies on the per-input DLEQ proofs before it computes the
output scripts. The validator only checked them once PSBT_OUT_SCRIPT was
set. An invalid proof on an in-progress PSBT passed.

Every share on an eligible input now needs a proof that verifies,
whether or not the script is set. Coverage of every eligible input is
still only required once a script is set. Also add the matching vector
for the existing global DLEQ proof check before PSBT_OUT_SCRIPT is set.

Add 2 invalid vectors:
- invalid proof in PSBT_IN_SP_DLEQ field when PSBT_OUT_SCRIPT not set for sp output
- invalid proof in PSBT_GLOBAL_SP_DLEQ field when PSBT_OUT_SCRIPT not set for sp output

Based on bitcoin#2321.

Co-authored-by: gophersg <gopher@2980.com>
ECDH share and DLEQ proof keydata must be 33-byte scan keys. This is from
the validator change in bitcoin#2318.

Add 1 invalid vector:
- incorrect byte length for PSBT_IN_SP_ECDH_SHARE scan key

Co-authored-by: myetcd <mytech@139.com>
PSBT Structure rejects a scan key, ECDH share, or either
PSBT_OUT_SP_V0_INFO key that is 33 bytes but not a valid point. 
Matching Bitcoin Core and rust-psbt deserialize behavior.

Add 4 invalid vectors:
- PSBT_IN_SP_ECDH_SHARE scan key is not a valid point
- PSBT_IN_SP_ECDH_SHARE value is not a valid point
- PSBT_OUT_SP_V0_INFO scan key is not a valid point
- PSBT_OUT_SP_V0_INFO spend key is not a valid point
A global ECDH share fails when no input is eligible. Eligible input
pubkeys that sum to the point at infinity fail instead of crashing.

Add 3 invalid vectors:
- PSBT_GLOBAL_SP_ECDH_SHARE set when the only input is ineligible (P2TR with NUMS internal key)
- eligible input keys sum to the point at infinity when PSBT_GLOBAL_SP_ECDH_SHARE set and PSBT_OUT_SCRIPT not set for sp output
- PSBT_OUT_SCRIPT set for sp output when the eligible input keys sum to the point at infinity
hashlib only offers RIPEMD-160 when OpenSSL provides it, and OpenSSL 3 moved
it to the legacy provider. Bring in crypto/ripemd160.py from Bitcoin Core
test/functional/test_framework, and compute hash160 with it as Core's messages.py
does.

Based on bitcoin#2317, which makes the same change.

Co-authored-by: macgyver13 <4712150+macgyver13@users.noreply.github.com>
A P2SH redeem script must hash to the scriptPubKey before eligibility is
read from it. An uncompressed P2PKH input is ineligible and should be
skipped.

Add 1 invalid vector:
- P2SH-P2WPKH input 1 with a non-P2WPKH PSBT_IN_REDEEM_SCRIPT that does not hash to scriptPubKey and no ECDH share

Add 1 valid vector:
- two mixed input types - only eligible inputs contribute ECDH shares (uncompressed P2PKH excluded)

The redeem script check follows the P2SH commitment check fametrano
proposed in bitcoin#2317.

Co-authored-by: Ferdinando Ametrano <ferdinando@ametrano.net>
Refresh bip375_test_vectors.json with the bip375-test-generator file
(version 1.2.0). The remaining 8 key binding v1.2.0 vectors arrive in the
next commit with the validator changes. 

Use the `task` field from each vector to determine the outcome a runner
should expect: fail_deserialize, fail_sign, deserialize, sign, finalize.

Every vector has new keys, prevouts, and derivations. The P2WPKH
programs and signatures that bitcoin#2316 fixes are repaired. The
runner now maps PSBT Structure to fail_deserialize and the other checks
to fail_sign.

Rename 1 vector: "segwit version greater than 1 supplied via
PSBT_IN_NON_WITNESS_UTXO..." now ends with "when
PSBT_OUT_SCRIPT not set for sp output"
Nothing checked that a PSBT_IN_BIP32_DERIVATION pubkey matches the
prevout script it claims to spend. A valid share and DLEQ proof made
with an incorrect key, intentional or accidental, do not catch it. A
false NUMS PSBT_IN_TAP_INTERNAL_KEY on a key-path spendable input
makes the sender leave out an input the receiver expects. Either way the
receiver never finds the output.

An input's pubkey must now come from the BIP32 derivation its
scriptPubKey commits to. A NUMS claim counts only when
PSBT_IN_TAP_MERKLE_ROOT reproduces the scriptPubKey. An eligible input
with no usable pubkey now fails instead of dropping out of the global
share's key sum.

Add 6 invalid vectors:
- PSBT_GLOBAL_SP_DLEQ proven without input 1 (also missing PSBT_IN_BIP32_DERIVATION)
- P2WPKH PSBT_IN_BIP32_DERIVATION pubkey does not match scriptPubKey
- P2PKH PSBT_IN_BIP32_DERIVATION pubkey does not match scriptPubKey
- P2SH-P2WPKH PSBT_IN_BIP32_DERIVATION pubkey does not match scriptPubKey
- global ECDH share computed from a PSBT_IN_BIP32_DERIVATION pubkey not matching scriptPubKey
- P2TR input 1 with a NUMS PSBT_IN_TAP_INTERNAL_KEY that does not tweak to scriptPubKey and no ECDH share

Add 2 valid vectors:
- P2WPKH with decoy PSBT_IN_BIP32_DERIVATION before the matching key
- P2PKH with decoy PSBT_IN_BIP32_DERIVATION before the matching key

A reviewer of the caravan BIP-375 PR raised this case. Binding input keys
to the scriptPubKey adapts the key commitment check fametrano proposed
for the test vectors in bitcoin#2317 (signatures.py).

Co-authored-by: Ferdinando Ametrano <ferdinando@ametrano.net>
@jonatack jonatack added the BIP Update by Owner PR by Author or Deputy to modify their own BIP label Dec 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

BIP Update by Owner PR by Author or Deputy to modify their own BIP

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants