Repository navigation
Description
Expected Behavior
P2MR OP_CHECKSIGPQC with SIGHASH_SINGLE must reject when the signing input has no corresponding transaction output.
Source behavior on 0.1.x:
SignatureHashP2MRusesSignatureHashSchnorrCommonwith theP2MRSighashtag.- In that common path,
SIGHASH_SINGLEreturns failure whenin_pos >= tx_to.vout.size(). CheckPQCSignaturemaps that failed P2MR sighash computation toSCRIPT_ERR_P2MR_SIG_HASHTYPE.- Wallet signing also avoids producing
SIGHASH_SINGLEsignatures for inputs without matching outputs.
So the intended behavior appears to be rejection with SCRIPT_ERR_P2MR_SIG_HASHTYPE, not substitution with another mode and not a defined digest.
Current Evidence Gap
Generic Bitcoin tests cover legacy/taproot missing-output SIGHASH_SINGLE, but I did not find a fixed P2MR/PQC-specific fixture for this edge.
Checked:
src/script/interpreter.cpp: P2MR sighash implementation and CHECKSIGPQC verification path.src/script/sign.cpp: P2MR signing behavior forSIGHASH_SINGLE.src/test/script_p2mr_tests.cpp: P2MR CHECKSIGPQC, sighash-domain, explicit-hashtype, and rejection tests.src/test/data/p2mr_pqc_witness_vectors.json: current independent vector issingle_key_default_sighash; it has one input and one output and does not coverSIGHASH_SINGLE.src/test/fuzz/p2mr_script.cpp: randomly selectsSIGHASH_SINGLE, but constructs a one-input, one-output spend, so it is not fixed missing-output coverage.- Functional and PSBT P2MR tests: no fixed missing-output CHECKSIGPQC vector found.
- Open PRs Reject non-P2MR raw funding outputs #37, Add independent CHECKDATASIGPQC vector coverage #38, Verify libbitcoinpqc tagged subtree imports #41, Add independent CHECKDATASIGADDPQC vector coverage #42, Add P2MR data-hash proof fixtures #43, Fix PQC data-hash counter accounting #46, Add independent P2MR commitment vectors #47: no added P2MR
SIGHASH_SINGLEmissing-output fixture found.
Consensus Risk
This is a consensus-sensitive edge because P2MR uses a P2MR-specific sighash domain and PQC signature verification path. Relying on inherited legacy/taproot tests leaves a gap where a future refactor could accidentally:
- produce a digest for missing-output
SIGHASH_SINGLE, - map the failure to a different script error,
- sign such inputs in wallet/PSBT code,
- or diverge from intended P2MR behavior while generic tests still pass.
Randomized fuzz coverage is useful but not a launch-blocking oracle for this exact consensus boundary.
Recommended Fixed Fixture
Add independent P2MR CHECKSIGPQC vectors, preferably in p2mr_pqc_witness_vectors.json, with tests in script_p2mr_tests.
Cover these boundaries:
-
input_index == outputs.size() - 1- Valid matched-output
SIGHASH_SINGLE. - Include exact transaction transcript, prevout, leaf script, control block,
p2mrSigMsg,p2mrSighash, and PQC signature. - Expected result:
SCRIPT_ERR_OK.
- Valid matched-output
-
input_index == outputs.size()- First missing-output case.
- Include exact transaction/witness transcript and signature bytes with explicit
SIGHASH_SINGLE. - Expected result:
SCRIPT_ERR_P2MR_SIG_HASHTYPE. - Assert
SignatureHashP2MR(..., MissingDataBehavior::FAIL)returns false.
-
input_index > outputs.size()- Beyond-bound missing-output case.
- Same expected result:
SCRIPT_ERR_P2MR_SIG_HASHTYPE. - This prevents an off-by-one-only test from missing deeper out-of-range handling.
If practical, repeat the missing-output cases for SIGHASH_SINGLE | SIGHASH_ANYONECANPAY, since the output selector is still SIGHASH_SINGLE.
Closure Criteria
- A PR adds fixed, deterministic P2MR/PQC fixture coverage for the three boundary cases above.
- The valid boundary vector includes independently generated
p2mrSigMsg,p2mrSighash, and signature. - The missing-output vectors assert exact rejection reason
SCRIPT_ERR_P2MR_SIG_HASHTYPE. - Tests prove P2MR behavior directly through
VerifyScript/CHECKSIGPQC, not only wallet signing refusal. - The test comments explain that P2MR intentionally rejects missing-output
SIGHASH_SINGLErather than inheriting legacy’suint256::ONEbehavior.
Activity