Skip to content

Add independent P2MR CHECKSIGPQC vectors for non-default sighash modes #50

Closed

Description

@kiwidream

Problem

0.1.x currently has a fixed independent P2MR OP_CHECKSIGPQC witness vector only for single_key_default_sighash. That fixture pins the serialized transaction, P2MR leaf/control data, p2mrSigMsg, p2mrSighash, pubkey, and PQC signature.

The production sighash path appears to support the full BIP341-style matrix for P2MR, including SIGHASH_NONE, SIGHASH_SINGLE, and ANYONECANPAY combinations, but the non-default modes are not pinned by fixed independent consensus vectors.

This should be tracked as a vector-oracle gap, not as a confirmed consensus failure.

Evidence

  • src/test/data/p2mr_pqc_witness_vectors.json contains one vector named single_key_default_sighash.
  • src/test/script_p2mr_tests.cpp loads that single fixture and checks p2mrSigMsg, p2mrSighash, domain separation, PQC signature verification, and valid spend acceptance.
  • src/test/fuzz/p2mr_script.cpp enumerates SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ALL | ANYONECANPAY, SIGHASH_NONE | ANYONECANPAY, and SIGHASH_SINGLE | ANYONECANPAY, but fuzz coverage is not a fixed independent vector oracle.
  • src/script/interpreter.cpp uses the P2MRSighash tagged hash and switches committed fields based on output type and ANYONECANPAY.
  • Functional tests exercise wallet/RPC P2MR signing paths, mostly default sighash, but do not pin independent OP_CHECKSIGPQC message bytes/hash/signature for the non-default matrix.
  • Current open PRs do not close this exact gap:

Proposed Minimal Vector Matrix

Add independent fixed OP_CHECKSIGPQC vectors for:

Vector Hashtype Required commitment behavior
single_key_sighash_none 0x02 Commit all inputs through shared prevouts, amounts, scriptPubKeys, and sequences; omit all outputs.
single_key_sighash_single_matching_output 0x03 Commit all inputs through shared input hashes; commit only the output at the signing input index; omit the all-outputs hash.
single_key_sighash_all_anyonecanpay 0x81 Commit only the current input prevout, spent output, and sequence; commit all outputs; omit shared input hashes.
single_key_sighash_none_anyonecanpay 0x82 Commit only the current input prevout, spent output, and sequence; omit shared input hashes and all outputs.
single_key_sighash_single_anyonecanpay 0x83 Commit only the current input prevout, spent output, sequence, and matching output; omit shared input hashes and all other outputs.

Each vector should also commit the common P2MR sighash fields: epoch, hashtype byte, transaction version, locktime, spend type, P2MR leaf hash, key version, and code-separator position. If the vectors intentionally omit annex coverage, state annex: none explicitly.

Risk

If a non-default P2MR CHECKSIGPQC mode is miscommitted, implementations can diverge on which transaction fields are signed. That is a consensus split risk after activation: one node may accept a PQC signature that another rejects, or reject a valid spend that another accepts. Because these modes are rarely used compared with default/all signing, the missing independent vectors leave a hard-fork-sensitive edge under-tested.

Closure Criteria

  • Add fixed, independently generated fixtures for all five non-default modes above.
  • For each fixture, pin at least:
    • serialized spend transaction
    • prevout amount and scriptPubKey
    • P2MR leaf script, control block, and leaf version
    • pubkey
    • signature including explicit hashtype byte
    • raw p2mrSigMsg
    • final p2mrSighash
    • provenance explaining the independent generator and that qbit signing/sighash helpers were not used
  • Add positive tests proving each fixture spends successfully under SCRIPT_VERIFY_P2MR_RULES.
  • Add mutation checks that fail when committed fields change and continue to pass when intentionally omitted fields change.
  • Do not count generic sighash tests, wallet signing tests, or fuzz enumeration as closure unless they consume these fixed P2MR OP_CHECKSIGPQC vectors.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions