Skip to content

Add independent P2MR PQC witness vectors for consensus verification tests #20

Closed

Description

@kiwidream

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:

  1. qbit builds the message/hash.
  2. qbit signs it.
  3. qbit verifies it.
  4. 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 tests
  • src/test/pqc_tests.cpp: raw PQC known-answer and malformed-vector tests
  • src/script/interpreter.cpp: OP_CHECKSIGPQC / P2MR verification path
  • src/crypto/pqc.cpp and src/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_CHECKSIGPQC P2MR 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

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