Skip to content

Add independent CHECKDATASIGPQC vector coverage - #38

Merged
kiwidream merged 1 commit into
0.1.xfrom
p2mr-checkdatasigpqc-vector
Jun 30, 2026
Merged

kiwidream merged 1 commit into
0.1.xfrom
p2mr-checkdatasigpqc-vector

Conversation

@kiwidream

@kiwidream kiwidream commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Builds on PR #30 and adds independent OP_CHECKDATASIGPQC P2MR witness-vector coverage for issue #34.

This adds independently generated data-signature fixture fields and tests that verify the valid spend path plus near misses for corrupted signatures, raw-message signatures without the Qbit data-signature domain, mutated witness message hashes, mutated committed leaves, and wrong-pubkey leaves.

Testing

  • Built locally.
  • Ran focused unit or functional tests for the changed area.
  • Ran lint or formatting checks relevant to this change.
  • Not run. Reason:

Commands run:

  • cmake -B build -DBUILD_GUI=OFF -DBUILD_TESTS=ON
  • cmake --build build --target test_bitcoin -j2
  • build/bin/test_qbit --run_test=script_p2mr_tests/p2mr_checkdatasigpqc_accepts_independent_data_signature_vector --catch_system_error=no --log_level=message
  • build/bin/test_qbit --run_test=script_p2mr_tests/p2mr_checkdatasigpqc_rejects_independent_data_signature_vector_near_misses --catch_system_error=no --log_level=message
  • build/bin/test_qbit --run_test=script_p2mr_tests --catch_system_error=no --log_level=message
  • python3 -m json.tool src/test/data/p2mr_pqc_witness_vectors.json
  • git diff --check
  • DOCKER_BUILDKIT=1 docker build -t bitcoin-linter --file "./ci/lint_imagefile" . && docker run --rm -v "$(pwd)":/bitcoin -v /Users/miller/conductor/repos/qbit-v1:/Users/miller/conductor/repos/qbit-v1 bitcoin-linter

The full script_p2mr_tests run prints repeated file-descriptor warnings in this local environment, but exits successfully with no Boost test errors.

Target Branch

  • This PR targets main or a maintainer-requested release branch such as 0.1.x.

Target is PR #30's head branch, investigate-issue-20, as requested.

Risk / Review Notes

  • Consensus, script, crypto, wallet, P2P, release, CI, or security-sensitive behavior changed.
  • No consensus, script, crypto, wallet, P2P, release, CI, or security-sensitive behavior changed.

Notes: test fixture and unit-test coverage only.

Docs / Process Impact

Choose exactly one:

  • I updated public docs because this PR changes user-visible behavior, integration guidance, release/process guidance, or expected validation.
  • No public docs update needed. Reason: test coverage only.

libbitcoinpqc Subtree Checklist (if src/libbitcoinpqc changed)

  • Upstream fix is merged into the maintained libbitcoinpqc branch used by qbit.
  • Curated branch qbit-subtree was refreshed with prune.
  • Subtree update was done with contrib/devtools/update-libbitcoinpqc-subtree.sh.
  • test/lint/git-subtree-check.sh -r src/libbitcoinpqc passes locally.
  • Followed doc/subtrees/libbitcoinpqc.md.

Not applicable: src/libbitcoinpqc was not changed.


View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.


Note

Low Risk
Test fixtures and unit tests only; no interpreter, consensus, or production signing paths are modified.

Overview
Adds independently generated OP_CHECKDATASIGPQC fixture data to p2mr_pqc_witness_vectors.json (Qbit data-sig domain hash, P2MR leaf/scriptPubKey, signatures, and wrong-pubkey variants) so spends are not produced by qbit signing helpers.

Extends script_p2mr_tests to load those fields, build a four-item witness spend (signature, witness message hash, leaf, control block), and adds acceptance plus near-miss tests: bit-flipped signature or message hash, raw-message signature without the data-sig domain, mutated leaf/commitment, and wrong-pubkey leaf/scriptPubKey pairs.

Reviewed by Cursor Bugbot for commit b360ded. Bugbot is set up for automated code reviews on this repo. Configure here.

@kiwidream

Copy link
Copy Markdown
Member Author

PR Review

Findings

No blocking findings.

Consensus Impact

Consensus-adjacent test coverage only. The PR adds fixture/test coverage for OP_CHECKDATASIGPQC; I did not see production consensus, script, crypto, wallet, P2P, release, or CI behavior changes.

Review Scope

Reviewed PR #38 against issue #34, base 0.1.x at 31f6b39, head d71ff5f. Focused on src/test/data/p2mr_pqc_witness_vectors.json and src/test/script_p2mr_tests.cpp.

Deep Checks Performed

Traced the new fixture loading and witness construction through LoadIndependentP2MRWitnessVector, BuildDataSigVectorSpend, and VerifyVectorSpend (src/test/script_p2mr_tests.cpp:570, src/test/script_p2mr_tests.cpp:648). Also traced interpreter behavior for data-sig hashing, PQC verification, P2MR leaf hashing, and direct merkle-root commitment checks.

Issue Fit

The added vector pins the fixed 0x48 * 32 message hash, expected QbitDataSigPQC digest, PQC pubkey/signature, leaf script, control block, and P2MR scriptPubKey. The positive test verifies the four-item witness stack and succeeds through VerifyScript (src/test/script_p2mr_tests.cpp:1504).

The near-miss test covers mutated signature, raw-message signature without the data-signature digest, mutated message hash, mutated committed leaf, and wrong-pubkey leaf/scriptPubKey (src/test/script_p2mr_tests.cpp:1523). Malformed signature, message-hash, and pubkey sizes are already covered by existing OP_CHECKDATASIGPQC boundary tests (src/test/script_p2mr_tests.cpp:2022, src/test/script_p2mr_tests.cpp:2050, src/test/script_p2mr_tests.cpp:2074).

qbit-Specific Checks

The positive vector is not constructed by signing with qbit’s ComputeQbitDataSigPQCHash; the test only uses the production helper to assert it matches the fixed independent digest. I also independently recomputed the fixture’s QbitDataSigPQC digest and both P2MR scriptPubKey programs from the JSON fields, and they match.

Validation Reviewed

Reviewed the author’s listed local build/test/lint commands. Locally, I ran JSON parsing, git diff --check, and independent Python recomputation for the digest and P2MR commitments. I did not run the Boost test binary locally because this workspace has no existing build artifact. GitHub checks had no failures in the latest snapshot, but several checks were still queued or in progress.

Residual Risk

The fixture provenance is documented in JSON, but the external generator is not committed, so future regeneration still relies on those notes. Final merge should wait for the pending GitHub checks to complete.

@kiwidream
kiwidream merged commit e99987e into 0.1.x Jun 30, 2026
33 checks passed
djh58 pushed a commit that referenced this pull request Jul 2, 2026
* Accept legacy AuxPoW RPC payloads (#23)

* Prevent AuxPoW signalling in permissionless GBT (#22)

* wallet: defer P2MR getnewaddress keypool refill (#13)

* wallet: defer P2MR getnewaddress keypool refill

* wallet: bound internal P2MR keypool refill

* wallet: align P2MR top-up lock ordering

* wallet: schedule raw change P2MR refills

* wallet: report paused P2MR refills as failed

* wallet: log inline P2MR refill failures

* ci: fix BuildKit helper lint

* Document AuxPoW commitment order fields (#35)

* Restrict explicit wallet output types on P2MR-only chains (#25)

* Restrict explicit wallet output types

* test: run BECH32 wallet suites on unrestricted regtest

* fuzz: run wallet transaction target on unrestricted regtest

* Fix BuildKit helper lint

* Report missing wallet output managers accurately

* Allow managerless wallets with default output options

* test: add independent P2MR and CTV script vectors (#29)

* Add independent P2MR PQC witness vector tests (#30)

* test: add independent P2MR PQC witness vector

* test: verify P2MR wrong-domain vector signature

* Fix AuxPoW legacy payload disambiguation

* wallet: avoid MarkUnused P2MR full top-up (#31)

* wallet: avoid MarkUnused P2MR full top-up

* wallet: avoid MarkUnused lock inversion

* wallet: preserve P2MR recovery lookahead

* Split P2MR wallet unit tests (#52)

* Remove unused P2MR wallet test import (#58)

* Shard P2MR wallet unit tests (#60)

* Add independent CHECKDATASIGPQC vector tests (#38)

* test: add P2MR data-hash proof fixtures (#43)

* test: add independent P2MR commitment vectors (#47)

* Reject invalid raw funding outputs (#37)

* Validate witness-pruned assumevalid before wipe (#59)

* Add independent CHECKDATASIGADDPQC vector tests (#42)

* qt: recommend wallet encryption by default (#62)

* Verify libbitcoinpqc tagged subtree imports (#41)

* ci: verify libbitcoinpqc tagged subtree imports

* ci: handle peeled libbitcoinpqc tag refs

* ci: peel libbitcoinpqc tag objects before compare

* ci: pass auth to libbitcoinpqc verifier

* ci: pin libbitcoinpqc verifier inputs

* ci: verify libbitcoinpqc import tree

* Add P2MR PQC annex sighash vectors (#54)

* Add P2MR PQC annex sighash vectors

* Guard annex mutation vector test

* Add P2MR data signature support to Qt Sign/Verify (#63)

* qt: add P2MR data signature dialog

* qt: support text data in P2MR signatures

* qt: align P2MR proof verification with RPC

* test: add P2MR CHECKSIGPQC sighash vectors (#55)

* Add rawmr future-leaf coverage (#64)

* test: cover P2MR SIGHASH_SINGLE missing outputs (#57)

* test: add P2MR PQC codeseparator vectors (#56)

* Fix PQC data-hash counter accounting (#46)

* Fix PQC data-hash counter accounting

* Fix PQC data-hash leaf error priority

* Report final PQC slot failures as exhausted

* doc: add v0.1.2-testnet4 release notes

* build: bump version to v0.1.2-testnet4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants