Skip to content

Add independent OP_CHECKDATASIGADDPQC threshold data-signature vectors #40

Closed

Description

@kiwidream

Problem Statement

OP_CHECKDATASIGADDPQC currently has the same self-confirming coverage shape that issue #34 identified for OP_CHECKDATASIGPQC: tests generate PQC keys in-process, sign through qbit's SignDataSigPQC, and then verify through interpreter code that recomputes the same QbitDataSigPQC digest. That covers behavior, but does not pin an independent byte contract for the accumulator opcode's threshold script shape, empty-signature skip behavior, or near-miss failures.

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

Evidence

  • src/test/script_p2mr_tests.cpp:111 defines SignDataSigPQC, which signs ComputeQbitDataSigPQCHash(msg_hash).
  • src/script/interpreter.cpp:1245 handles OP_CHECKDATASIGADDPQC by reusing EvalCheckDataSigPQC, then adding successful verification to the numeric accumulator.
  • src/script/interpreter.cpp:2200 defines ComputeQbitDataSigPQCHash, which applies the QbitDataSigPQC tagged hash.
  • src/test/script_p2mr_tests.cpp:143 defines BuildP2MRDataSigAddScript, which constructs repeated <msg_hash> <count> <pubkey> OP_CHECKDATASIGADDPQC fragments.
  • Existing ADDPQC tests cover n-of-n, m-of-n with empty skip, threshold failure, and invalid non-empty signature, but their accepted signatures come from SignDataSigPQC: src/test/script_p2mr_tests.cpp:1684, src/test/script_p2mr_tests.cpp:1713, src/test/script_p2mr_tests.cpp:1747, and src/test/script_p2mr_tests.cpp:1781.
  • CTV plus ADDPQC integration tests also use generated signatures: src/test/script_p2mr_tests.cpp:2117.
  • Docs define the ADDPQC stack and accumulator semantics in doc/user/bitcoin-core-differences.md:100.

Proposed Acceptance Criteria

  • Extend PR Add independent CHECKDATASIGPQC vector coverage #38's fixture structure, preferably in src/test/data/p2mr_pqc_witness_vectors.json, with a distinct nested ADDPQC fixture object such as dataSigAdd.
  • Pin a minimal reusable fixture set: fixed message hash, fixed QbitDataSigPQC digest, three fixed PQC pubkeys, valid signatures for the needed keys, one wrong-domain/raw-message signature, leaf scripts, control blocks, scriptPubKeys, and witness stacks.
  • Assert the fixed QbitDataSigPQC digest in tests before script verification.
  • Verify independent ADDPQC spends without generating accepted signatures through SignDataSigPQC.
  • Cover n-of-n success and m-of-n success with an empty-signature skip.
  • Cover threshold failure, invalid non-empty signature, wrong message hash, wrong pubkey or wrong committed leaf, and wrong-domain/raw-message signature.
  • Keep existing generated behavior tests; the new fixture tests should harden independent byte-contract coverage.

Suggested Test / Vector Scope

Use one compact fixture set and mutate witness/script data where possible, rather than adding many full signatures.

Required:

  • 2-of-2 n-of-n success.
  • 2-of-3 m-of-n success with one empty-signature skip.
  • 2-of-3 threshold miss where empty skips contribute 0 and final OP_NUMEQUAL fails.
  • Bit-flipped or otherwise corrupted non-empty signature fails with SCRIPT_ERR_P2MR_SIG.
  • Wrong message hash fails.
  • Wrong pubkey or wrong committed leaf fails.
  • Raw-message or otherwise wrong-domain signature fails.

Out of scope unless cheap:

  • Independent CTV plus ADDPQC fixture. Existing generated tests already cover CTV composition; this issue should focus on ADDPQC threshold semantics.

Dependency Note

PR #38 is the natural base because it adds independent OP_CHECKDATASIGPQC fixture loading and data-signature vector tests. This issue can be stacked directly on PR #38 if maintainers want the adjacent coverage before merging the chain, but the cleaner path is to land PR #38 first and follow up by extending its fixture structure for ADDPQC. That avoids extra review and rebase coupling.

Risks / Open Questions

  • Fixture size can grow quickly because PQC signatures are large. Resolution: keep one compact three-key fixture set and reuse it across cases.
  • JSON structure could become hard to review if more flat fields are appended. Resolution: add a nested ADDPQC fixture object instead of another long flat field list.
  • Independent provenance needs to be auditable. Resolution: require notes matching PR Add independent CHECKDATASIGPQC vector coverage #38's standard: digest computed outside qbit's production helper and signatures generated through the external libbitcoinpqc path. A committed generator is useful but not required unless maintainers want that pattern.
  • CTV coverage may look adjacent. Resolution: do not require it for acceptance; add only if it falls out naturally from the fixture loader.

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