Skip to content

Add independent OP_CHECKDATASIGPQC data-signature vectors #34

Closed

Description

@kiwidream

Summary

OP_CHECKDATASIGPQC positive-path coverage is still self-confirming: tests sign ComputeQbitDataSigPQCHash(...) with qbit's own helper and then verify the same helper through the interpreter. The exact QbitDataSigPQC byte contract is documented, but there is no independent fixed digest or executable witness vector proving the data-signature path remains stable across signing and verification refactors.

This is a coverage hardening issue, not evidence that PQC verification is currently broken.

Current Status

Verified still present on 2026-06-26:

  • Default branch: main
  • main commit checked: 4b7e1043ced39218757f9c103460ef05ea4b86d7
  • Related issue: Qbit-Org/qbit#20 remains open and covers independent OP_CHECKSIGPQC P2MR/PQC witness vectors.
  • Related PR: Qbit-Org/qbit#30 remains open against 0.1.x from investigate-issue-20 at 5287f545d6c9a73a3c4b54dcfec8b3f2c1e5977b; it adds p2mr_checksigpqc_* vectors, but no OP_CHECKDATASIGPQC independent vector.
  • Issue searches for OP_CHECKDATASIGPQC, signdatapqchash, datasig_hash, CHECKDATASIGPQC, QbitDataSigPQC, and INDVEC found no existing issue for this narrower data-signature vector gap.

Impact

A shared bug in QbitDataSigPQC domain construction, byte serialization, message-hash handling, or witness assembly could be self-confirming:

  1. qbit computes the data-signature hash.
  2. qbit signs that hash.
  3. qbit interpreter verification recomputes the same hash.
  4. the positive test passes even if the externally intended byte contract changed.

The release currently has lower-level PQC vectors and related OP_CHECKSIGPQC vector work, but the OP_CHECKDATASIGPQC consensus path should have its own fixed data-signature vector because it validates a different domain and a different witness shape.

Evidence

  • Manifest SHA: sha256:19928603d4ba7883b0918f8698e0f5c7376c4cd287cc85e6c18034d472a830d5
  • Scope ID: r11-p2mr-pqc-independent-vectors
  • Code refs:
    • src/script/interpreter.cpp:462 verifies OP_CHECKDATASIGPQC by recomputing ComputeQbitDataSigPQCHash(msg_hash).
    • src/script/interpreter.cpp:2200 defines ComputeQbitDataSigPQCHash as the QbitDataSigPQC tagged hash over a 32-byte message hash.
    • src/test/script_p2mr_tests.cpp:111 defines SignDataSigPQC by signing ComputeQbitDataSigPQCHash(msg_hash).
    • src/test/script_p2mr_tests.cpp:1373 accepts a generated OP_CHECKDATASIGPQC signature produced by SignDataSigPQC.
    • src/test/script_p2mr_tests.cpp:1396 accepts a witness-supplied message hash using a generated SignDataSigPQC signature.
    • src/test/script_p2mr_tests.cpp:1618 checks the data-signature domain, but its positive branch still signs via SignDataSigPQC.
    • test/functional/feature_p2mr.py:528 exercises signdatapqchash / verifydatapqchash.
    • test/functional/feature_p2mr.py:621 spends a CHECKDATASIGPQC leaf using the RPC-produced signature.
  • Spec refs:
    • doc/design/p2mr-datapqchash.md documents ComputeQbitDataSigPQCHash(message_hash) and says OP_CHECKDATASIGPQC verifies the same QbitDataSigPQC domain.
    • Qbit-Org/qbit#20 / Qbit-Org/qbit#30 are related but currently cover OP_CHECKSIGPQC, not this data-signature opcode path.
  • Tests / fuzz refs:
    • script_p2mr_tests/p2mr_checkdatasigpqc_accepts_valid_signature
    • script_p2mr_tests/p2mr_checkdatasigpqc_accepts_witness_supplied_message_hash
    • script_p2mr_tests/p2mr_checkdatasigpqc_uses_data_signature_domain
    • feature_p2mr.py::test_data_pqc_hash_rpc

Review-local independent digest check:

TaggedHash("QbitDataSigPQC", 0x48 * 32)
= d9f39a1a0a8acc8147f683da6e063d060a287e9c959d613ac537dbd06a10c532

That digest is not asserted by main, the 0.1.x branch, or the related investigate-issue-20 PR branch.

Failure / Attack Path

This is a test-oracle failure mode:

  1. A refactor accidentally changes the QbitDataSigPQC digest construction, witness message-hash ordering, or opcode verification contract.
  2. qbit's signing helper and interpreter helper share the same changed implementation.
  3. Generated positive-path tests continue passing.
  4. External wallets, attestors, bridges, or other software producing signatures against the previous byte contract no longer interoperate, or worse, tests fail to catch an unintended consensus contract change before release.

Reproduction

No failing runtime repro is expected; this is a missing independent fixture.

Verification commands used:

git ls-remote --heads <qbit-remote>
gh repo view Qbit-Org/qbit --json defaultBranchRef,nameWithOwner,url
gh issue list --repo Qbit-Org/qbit --state all --search "OP_CHECKDATASIGPQC" --limit 20 --json number,title,state,url
gh issue list --repo Qbit-Org/qbit --state all --search "signdatapqchash" --limit 20 --json number,title,state,url
gh issue list --repo Qbit-Org/qbit --state all --search "datasig_hash" --limit 20 --json number,title,state,url
git grep -n "p2mr_checkdatasigpqc.*independent\\|datasig.*independent\\|QbitDataSigPQC.*d9f39a1a\\|d9f39a1a0a8acc8147f683da6e063d060a287e9c959d613ac537dbd06a10c532" <qbit-remote>/investigate-issue-20 -- src test doc

Suggested Fix

Add an independent OP_CHECKDATASIGPQC fixture that pins:

  • one fixed 32-byte message_hash
  • the exact QbitDataSigPQC digest
  • a fixed PQC public key
  • a fixed PQC signature over that digest
  • the leaf script and witness bytes for <pubkey> OP_CHECKDATASIGPQC
  • a VerifyScript positive case

Add near-miss negatives from the same fixture:

  • wrong data-signature domain or digest
  • one-byte mutated signature
  • wrong message hash
  • wrong public key
  • wrong leaf script or P2MR commitment
  • malformed signature / pubkey / message-hash sizes, where not already covered

If possible, derive the fixture outside qbit's production signing helper and commit the fixture generator or derivation notes so future reviewers can reproduce the vector.

Reverify Requirement

Reverify by confirming the target branch includes executable tests for OP_CHECKDATASIGPQC that do not call qbit's production ComputeQbitDataSigPQCHash before constructing the expected digest or signing the positive vector. The tests should assert at least one fixed digest and should fail when the domain, message hash, public key, signature, or P2MR commitment is changed.

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