Skip to content

Add P2MR data-hash proof fixtures - #43

Merged
kiwidream merged 1 commit into
0.1.xfrom
draft-rpc-wallet-proof-fixtures
Jun 30, 2026
Merged

kiwidream merged 1 commit into
0.1.xfrom
draft-rpc-wallet-proof-fixtures

Conversation

@kiwidream

@kiwidream kiwidream commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add a pinned regtest P2MR data-signature proof fixture for the QbitDataSigPQC data-hash domain.
  • Add a C++ fixture test that independently recomputes the data-signature hash, leaf script, control block root, address commitment, and pinned PQC signature verification.
  • Add wallet test coverage proving SignP2MRDataHash reproduces the pinned proof without changing signing behavior.
  • Extend feature_p2mr.py with RPC fixture coverage for verifydatapqchash, including negative cases for malformed proof shape, wrong signature/hash/script/root/control block, unsupported leaf version, and unsupported proof mode.

Fixes #39.

Validation

  • cmake --preset dev-mode -DWITH_USDT=OFF
  • cmake --build build_dev_mode --target test_bitcoin -j 8
  • build_dev_mode/bin/test_qbit --run_test=p2mr_datapqchash_tests
  • build_dev_mode/bin/test_qbit --run_test=wallet_tests/P2MRDataHashSigningMatchesPinnedProofFixture
  • cmake --build build_dev_mode --target qbitd qbit-cli -j 8
  • ulimit -n 1024 && test/functional/feature_p2mr.py --configfile build_dev_mode/test/config.ini
  • python3 -m json.tool src/test/data/p2mr_datapqchash_vectors.json >/dev/null
  • python3 -m py_compile test/functional/feature_p2mr.py
  • git diff --check

Note: -DWITH_USDT=OFF was needed locally because the dev environment is missing USDT headers.


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


Note

Low Risk
Test-only changes (fixtures and coverage); no node, wallet, or RPC implementation logic is modified.

Overview
Adds a pinned regtest fixture (p2mr_datapqchash_vectors.json) for the QbitDataSigPQC P2MR p2mr-pubkey data-hash proof path, wired into the unit test build.

C++ coverage recomputes datasig_hash, two-leaf Merkle root, address, and PQC verify from the vector, and asserts SignP2MRDataHash in the wallet reproduces the same signature and proof fields.

Functional tests load that JSON and exercise verifydatapqchash on the happy path plus negatives (bad signature/message, leaf/address/control mismatch, unsupported leaf version and proof mode, and RPC size/shape errors), ahead of the existing wallet round-trip test.

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

@kiwidream
kiwidream force-pushed the draft-rpc-wallet-proof-fixtures branch from cde2e86 to adb0c19 Compare June 29, 2026 15:09
@kiwidream

Copy link
Copy Markdown
Member Author

PR Review

Findings

No blocking findings from this review pass.

Consensus Impact

Consensus-adjacent

The diff is test/fixture-only, with no production consensus, wallet signing, or RPC implementation changes. I’m still classifying it as consensus-adjacent because it pins P2MR/PQC proof behavior around QbitDataSigPQC, P2MR merkle commitments, wallet signing output, and verifydatapqchash RPC verification.

Review Scope

Reviewed PR #43 against issue #39, the PR body, all five changed files, and the relevant production wallet/RPC/P2MR code paths. The main review targets were src/test/data/p2mr_datapqchash_vectors.json, src/test/p2mr_datapqchash_tests.cpp:62, src/wallet/test/wallet_tests.cpp:2428, and test/functional/feature_p2mr.py:558. There were no existing PR comments, reviews, or review threads.

Deep Checks Performed

Traced the fixture through the new C++ vector test, wallet SignP2MRDataHash reproduction test, and functional verifydatapqchash acceptance/negative cases. I also independently recomputed the pinned QbitDataSigPQC digest, sibling leaf hash, P2MR merkle root, control block, and regtest address from the JSON fixture; all matched the pinned values.

Issue Fit

The PR satisfies the issue #39 contract: the fixture pins the full signature and proof fields, includes schema versioning, validates fixed hash/tree/address/signature values, passes the pinned proof directly to verifydatapqchash, proves contradictory informational fields are ignored in favor of recomputed values, and keeps the existing wallet round-trip coverage.

The functional negatives cover wrong message hash, wrong signature, wrong leaf/pubkey binding, malformed leaf script, wrong address/root commitment, wrong control block, unsupported leaf version, unsupported proof mode, malformed message/signature/pubkey/control sizes, and control-block leaf-version mismatch.

qbit-Specific Checks

Checked the P2MR/PQC-specific surfaces: QbitDataSigPQC domain pinning, <pubkey> OP_CHECKSIGPQC leaf shape, control block branch binding, P2MR merkle root/address commitment, wallet proof reproduction, and RPC behavior that ignores untrusted datasig_hash / p2mr_merkle_root extras. AuxPoW, mining, PHOTON, release signing, and networking code were not touched.

Validation Reviewed

Reviewed the author’s listed local commands. Locally, I ran git diff --check, parsed the PR-head JSON fixture, syntax-compiled the PR-head functional test, and performed the independent fixture recomputation noted above. GitHub Core Checks were green, and the focused unit job built p2mr_datapqchash_tests.cpp plus the generated fixture header. However, that focused job’s hard-coded suite list skipped p2mr_datapqchash_tests and wallet tests; broader Full Validation was still partly queued/in progress in the latest snapshot.

Residual Risk

I did not locally build or run test_qbit, so the new Boost tests and full feature_p2mr.py execution rely on the author’s reported local runs and pending/remaining CI. Final merge should wait for Full Validation and the Required Merge Gate to complete.

@kiwidream
kiwidream merged commit bf12fcf into 0.1.x Jun 30, 2026
38 of 39 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