Skip to content

Add pinned regtest fixtures for signdatapqchash / verifydatapqchash P2MR data-signature proofs #39

Closed

Description

@kiwidream

Problem Statement

signdatapqchash and verifydatapqchash exercise the QbitDataSigPQC data-signature domain, but current coverage mostly creates a proof through the wallet and verifies it through the RPC in the same run. That round-trip can miss regressions where wallet signing and verification drift together.

Add independent pinned regtest fixtures for P2MR data-signature proofs, including the full PQC signature, so the RPC/wallet proof format, data-signature domain, address commitment, leaf script, control block, and verification behavior are locked to known values.

Evidence From Code/Tests

  • signdatapqchash returns message_hash, datasig_hash, domain, algorithm, proof_mode, pubkey, signature, leaf_version, leaf_script, control_block, and p2mr_merkle_root: src/wallet/rpc/signmessage.cpp.
  • Wallet signing selects a P2MR v1 single-key <pubkey> OP_CHECKSIGPQC leaf, validates the control block against the address Merkle root, and signs ComputeQbitDataSigPQCHash(message_hash): src/wallet/scriptpubkeyman.cpp.
  • verifydatapqchash independently validates proof mode, address type, message/signature/pubkey sizes, leaf script shape, leaf version, control block shape/version, Merkle root commitment, and signature domain: src/rpc/signmessage.cpp.
  • The shared domain is QbitDataSigPQC: src/script/interpreter.cpp.
  • Current functional coverage round-trips generated proofs and mutates several fields, but does not use pinned fixture values: test/functional/feature_p2mr.py.

Proposed Acceptance Criteria

  • Add a regtest fixture with pinned full signature, not only a signature hash.
  • Fixture pins: message_hash, datasig_hash, pubkey, signature, leaf_script, control_block, p2mr_merkle_root, address, leaf_version, proof_mode, domain, and algorithm.
  • Add a valid-fixture test that passes the pinned proof directly to verifydatapqchash and asserts valid=true plus returned datasig_hash, p2mr_merkle_root, address, pubkey, and proof_mode.
  • Add a test for current extra-field behavior without changing behavior: if input proof includes contradictory informational fields such as wrong datasig_hash or wrong p2mr_merkle_root, verifydatapqchash should ignore those untrusted extras and return the recomputed verified values.
  • Add independent checks that message_hash -> datasig_hash, leaf_script/control_block -> p2mr_merkle_root, and p2mr_merkle_root -> regtest address match the fixture.
  • Keep the existing runtime wallet round-trip coverage.

Suggested Negative Cases

Wrong signature, wrong message hash, wrong leaf script/pubkey binding, wrong address/root, wrong control block, unsupported leaf_version, unsupported proof_mode, malformed message/signature/pubkey/control sizes, malformed leaf script, and control-block leaf-version mismatch.

Recommended Test Location

Use both:

  • src/test/data/p2mr_datapqchash_vectors.json for the pinned fixture.
  • A C++ unit test for deterministic hash/proof/address checks.
  • Functional RPC coverage in or near test_data_pqc_hash_rpc in test/functional/feature_p2mr.py for verifydatapqchash fixture acceptance and RPC error behavior.

Risks / Open Questions

  • The full signature is large, but should be pinned because signature verification is the core behavior under test.
  • Fixture schema should include an explicit version so future proof modes or leaf versions can be added cleanly.
  • Regtest address encoding should be explicit in the fixture metadata.

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