Skip to content

Add independent annex-present P2MR CHECKSIGPQC sighash vectors #51

Closed

Description

@kiwidream

Summary

0.1.x has one independent default OP_CHECKSIGPQC P2MR witness vector, but it only covers the no-annex path. Annex-present P2MR script-path spends change the committed sighash transcript: the P2MR sighash sets the low annex bit in spend_type and commits the serialized annex hash.

Current tests prove annex-present P2MR script-path acceptance, and fuzz can touch annex, but I could not find a fixed external vector that pins annex bytes, P2MRSighash message bytes, sighash, PQC signature, and near-miss behavior.

Affected Branch / Ref

Affected Files

  • src/script/interpreter.cpp
  • src/test/script_p2mr_tests.cpp
  • src/test/fuzz/p2mr_script.cpp
  • src/test/data/p2mr_pqc_witness_vectors.json
  • test/functional/feature_p2mr.py and other P2MR functional tests

Evidence

  • SignatureHashP2MR uses the P2MRSighash tag. In the common schnorr/P2MR sighash path, annex presence changes spend_type and appends m_annex_hash.
  • P2MR witness validation removes a final annex item when the last witness element starts with ANNEX_TAG, sets m_annex_present, and hashes the serialized annex before executing the P2MR leaf.
  • The existing fixed single_key_default_sighash vector in p2mr_pqc_witness_vectors.json is no-annex only. Its p2mrSigMsg is 212 bytes and has spend-type byte 0x02 at offset 170, not annex-present 0x03.
  • The fixed vector test builds ScriptExecutionData with m_annex_present = false.
  • p2mr_annex_present_path_succeeds appends an annex to an OP_TRUE P2MR spend and checks acceptance only. It does not involve OP_CHECKSIGPQC, a fixed signature, or a pinned sighash transcript.
  • src/test/fuzz/p2mr_script.cpp may append an annex and may sign via CreatePQCSignature, but that is a production-helper mirror path, not an independent consensus oracle.
  • PR Add independent CHECKDATASIGPQC vector coverage #38 and Add independent CHECKDATASIGADDPQC vector coverage #42 add independent data-signature fixtures for OP_CHECKDATASIGPQC / OP_CHECKDATASIGADDPQC, not annex-present transaction sighash vectors.
  • PR Add P2MR data-hash proof fixtures #43 adds pinned signdatapqchash / verifydatapqchash proof coverage, not OP_CHECKSIGPQC transaction sighash coverage.
  • PR Add independent P2MR commitment vectors #47 adds P2MR commitment vectors, not PQC transaction signature sighash vectors.
  • PR Reject non-P2MR raw funding outputs #37, Verify libbitcoinpqc tagged subtree imports #41, and Fix PQC data-hash counter accounting #46 do not add annex-present P2MR sighash fixtures.

Impact

An implementation could omit the annex bit, hash the annex incorrectly, place the annex hash at the wrong transcript position, or accidentally reuse the no-annex transcript and still pass the current fixed vector coverage. The existing annex tests would not catch that if signing and verification share the same production helper behavior.

Why This Is Consensus-Relevant

OP_CHECKSIGPQC validation depends on the exact P2MRSighash digest. Annex presence is committed into that digest. A mismatch between implementations on annex-present transcript bytes can produce consensus disagreement for otherwise valid-looking P2MR spends.

Suggested Acceptance Criteria

  • Add at least one independent annex-present OP_CHECKSIGPQC P2MR vector.
  • Fixture pins: prevout, spend transaction, witness stack including annex bytes, leaf script, control block, scriptPubKey, p2mrSigMsg, p2mrSighash, pubkey, and signature.
  • Test recomputes SignatureHashP2MR and compares to fixture bytes/hash.
  • Test verifies the fixed signature against the fixed hash.
  • Test verifies the full spend succeeds.
  • Near misses fail for mutated signature, removed annex, mutated annex byte, wrong sighash domain or no-annex transcript signature, mutated committed leaf, and wrong pubkey leaf.
  • Generator/provenance must not use qbit wallet/signing/sighash helpers for the transcript.

Test / Vector Plan

  1. Extend p2mr_pqc_witness_vectors.json or add a new focused annex fixture file.
  2. Generate a deterministic single-key P2MR OP_CHECKSIGPQC spend with witness stack: [signature, leaf_script, control_block, annex].
  3. Independently serialize the P2MR sighash message with spend type 0x03 and the serialized annex hash.
  4. Hash with TaggedHash("P2MRSighash").
  5. Sign that digest with libbitcoinpqc using deterministic test entropy.
  6. Add unit tests for valid spend plus the near misses above.
  7. Keep fuzz and functional coverage as supplemental, not as the fixed oracle.

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