Skip to content

Add independent P2MR CHECKSIGPQC codeseparator sighash vectors #49

Closed

Description

@kiwidream

Summary

0.1.x has a fixed independent P2MR OP_CHECKSIGPQC witness vector for the default/no-codeseparator path, but I could not find fixed, independent vectors that pin p2mrSigMsg / p2mrSighash when the last executed OP_CODESEPARATOR changes m_codeseparator_pos.

This is a test-vector coverage gap for a consensus-critical transcript field. I am not claiming a known consensus bug.

Evidence

  • P2MR sighash serialization includes execdata.m_codeseparator_pos in the BIP342/BIP360 extension data: src/script/interpreter.cpp:1785-1791.
  • Runtime P2MR script execution does update that field when OP_CODESEPARATOR executes: src/script/interpreter.cpp:1166-1174.
  • The wallet/signing helper path only supports the no-codeseparator signing path and sets m_codeseparator_pos = 0xffffffff: src/script/sign.cpp:108-122, also verification helper src/script/sign.cpp:145-159.
  • The unit-test helper BuildExecData() also hard-codes 0xffffffff: src/test/script_p2mr_tests.cpp:475-484.
  • The current fixed vector file has one vector named single_key_default_sighash; its leafScript is only <pubkey> OP_CHECKSIGPQC, and its p2mrSigMsg ends in ffffffff: src/test/data/p2mr_pqc_witness_vectors.json.
  • script_p2mr_tests pins that default vector's p2mrSigMsg/p2mrSighash, but recomputes through BuildExecData() with the default codeseparator position: src/test/script_p2mr_tests.cpp:551-580, src/test/script_p2mr_tests.cpp:1373-1401.
  • Existing generic Bitcoin/Taproot codeseparator coverage, for example test/functional/feature_taproot.py:764-781, exercises Taproot/Schnorr TapSighash, not P2MR CHECKSIGPQC with P2MRSighash.
  • The P2MR fuzz target signs through MutableTransactionSignatureCreator::CreatePQCSignature(), which uses the default codeseparator path, and is not a fixed independent oracle: src/test/fuzz/p2mr_script.cpp:475-494.

Current PR Reconciliation

Checked current 0.1.x and open PRs in Qbit-Org/qbit.

Expected Fixed-Vector Contents

Add independent fixtures, generated without qbit signing/sighash helpers, that include at least:

  • name
  • provenance
  • spendTx
  • prevoutAmount
  • prevoutScriptPubKey
  • leafScript
  • controlBlock
  • pubkey
  • signature
  • codeseparatorPos
  • raw p2mrSigMsg
  • p2mrSighash
  • a negative signature/hash for the wrong codeseparator position, or equivalent near-miss data

The tests should hash the pinned p2mrSigMsg with HASHER_P2MR_SIGHASH, compare it to the pinned p2mrSighash, then compare qbit's SignatureHashP2MR() result against the pinned value.

Boundary Cases To Cover

  • OP_CODESEPARATOR before OP_CHECKSIGPQC, proving a non-default position such as 0 is serialized instead of 0xffffffff.
  • Branch-dependent codeseparators, where two valid spends of the same committed script select different branches and therefore different last executed codeseparator positions.
  • An unexecuted branch codeseparator should not affect the transcript.
  • Wrong-position or wrong-branch signatures should fail with SCRIPT_ERR_P2MR_SIG.

Acceptance Criteria

  • Add fixed independent P2MR CHECKSIGPQC vectors for non-default codeseparator positions.
  • Extend script_p2mr_tests to load multiple CHECKSIGPQC witness vectors instead of assuming only the default vector.
  • Tests pin raw p2mrSigMsg bytes and p2mrSighash, not only production-helper recomputation.
  • Tests would fail if P2MR CHECKSIGPQC always serialized 0xffffffff for m_codeseparator_pos.
  • Do not count legacy, P2WSH, or Taproot codeseparator tests as satisfying this unless the new tests exercise P2MR CHECKSIGPQC and pin the P2MR-specific transcript.

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