Repository navigation
Description
Summary
The current P2MR/PQC positive-path tests mostly verify signatures generated by qbit's own signing and sighash helpers.
That proves the qbit signing path and verification path agree with each other, but it does not fully lock down the byte-level consensus contract for externally produced P2MR/PQC witnesses.
Impact
A shared bug in qbit's P2MR sighash construction, domain separation, signature encoding, or witness assembly could be self-confirming:
- qbit builds the message/hash.
- qbit signs it.
- qbit verifies it.
- the test passes.
For consensus code, we should also have fixed vectors that say: these exact transaction/script/witness bytes must verify, and these near-miss bytes must fail.
This is a test coverage hardening issue, not evidence that PQC verification is currently broken.
Source Trace
Relevant areas:
src/test/script_p2mr_tests.cpp: P2MR script-level PQC verification testssrc/test/pqc_tests.cpp: raw PQC known-answer and malformed-vector testssrc/script/interpreter.cpp:OP_CHECKSIGPQC/ P2MR verification pathsrc/crypto/pqc.cppandsrc/crypto/pqc.h: PQC wrapper contract
The raw PQC tests include fixed lower-level vectors, but the interpreter-level P2MR witness path should also have at least one externally derived positive vector.
Expected Behavior
The test suite should include at least one fixed P2MR/PQC spend vector whose valid witness was produced independently of qbit's wallet/signing helpers.
It should also include at least one negative companion vector from the same corpus, such as:
- mutated signature byte
- mutated public key byte
- wrong sighash/domain
- wrong script or committed leaf
- wrong hashtype byte
Proposed Fix
Add a fixed P2MR script witness vector with:
- serialized transaction/input/output context
- P2MR leaf/script bytes
- control/branch data if applicable
- 32-byte PQC public key
- PQC signature bytes
- expected verification result
The positive vector should pass through VerifyScript.
The negative companion vector should fail through the same interpreter-level path with the expected script error.
Suggested Tests
Add coverage that verifies:
- a fixed externally produced valid
OP_CHECKSIGPQCP2MR spend succeeds - a one-byte signature mutation fails
- a wrong-domain or wrong-sighash vector fails
- a wrong public key vector fails
- the same vector remains stable across future refactors of qbit signing helpers
The goal is to prevent qbit signing helpers and qbit verification helpers from accidentally redefining the consensus-valid byte contract together.
Activity