Skip to content

Add P2MR CHECKSIGPQC sighash vectors - #55

Merged
kiwidream merged 1 commit into
0.1.xfrom
p2mr-checksigpqc-sighash-vectors
Jul 2, 2026
Merged

kiwidream merged 1 commit into
0.1.xfrom
p2mr-checksigpqc-sighash-vectors

Conversation

@kiwidream

@kiwidream kiwidream commented Jun 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Closes #50.

Adds independent fixed P2MR OP_CHECKSIGPQC witness vectors for the non-default sighash modes:

  • SIGHASH_NONE
  • SIGHASH_SINGLE
  • SIGHASH_ALL|ANYONECANPAY
  • SIGHASH_NONE|ANYONECANPAY
  • SIGHASH_SINGLE|ANYONECANPAY

The fixture set now pins the serialized spend transaction, spent outputs, P2MR leaf/control data, pubkey, signature with explicit hashtype where required, raw p2mrSigMsg, and final p2mrSighash.

Details

  • Adds a reproducible standalone generator for the witness vectors.
  • Regenerates the existing default vector and adds the five non-default vectors.
  • Refactors the unit test loader to consume all vector fixtures.
  • Adds positive spend checks under P2MR verification flags.
  • Adds mutation checks for committed fields and intentionally omitted fields across the sighash matrix.

Validation

  • python3 contrib/devtools/generate-p2mr-pqc-witness-vectors.py --output /tmp/p2mr_pqc_witness_vectors.json && diff -u src/test/data/p2mr_pqc_witness_vectors.json /tmp/p2mr_pqc_witness_vectors.json
  • cmake --build build --target test_bitcoin -j"$(sysctl -n hw.ncpu)"
  • build/bin/test_qbit --run_test=script_p2mr_tests
  • Docker lint test runner passed with worktree Git metadata mounted for Git discovery.

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


Note

Low Risk
Changes are confined to devtools and checked-in test vectors; they do not alter node consensus code, though incorrect fixtures could weaken P2MR PQC sighash test coverage.

Overview
Introduces contrib/devtools/generate-p2mr-pqc-witness-vectors.py, a standalone generator that hand-serializes witness transactions, P2MR leaf/scriptPubKey data, and P2MRSighash messages, then signs digests with a locally built libbitcoinpqc (no qbit wallet/script helpers). It can emit JSON via --output for reproducible regeneration.

src/test/data/p2mr_pqc_witness_vectors.json is regenerated from that tool: the default single_key_default_sighash entry gets richer metadata (spentOutputs, leafHash, sighash fields, data-sig/ADDPQC blocks) and new hex values; five additional vectors cover non-default sighash modes (NONE, SINGLE, and three ANYONECANPAY combinations). The annex-present vector gains some of the same structural fields while keeping its prior provenance wording.

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

@kiwidream
kiwidream force-pushed the p2mr-checksigpqc-sighash-vectors branch from b29d673 to 775f260 Compare June 29, 2026 19:12
@kiwidream

Copy link
Copy Markdown
Member Author

No actionable findings from this pass.

Review Scope

Reviewed PR #55 against backing issue #50. The PR changes only the standalone generator, p2mr_pqc_witness_vectors.json, and script_p2mr_tests.cpp. No prior PR comments, reviews, or unresolved threads were visible.

Consensus Impact

Consensus-adjacent. Runtime consensus code is not changed, but this adds fixed P2MR OP_CHECKSIGPQC sighash vectors and tests that act as a consensus oracle for non-default sighash modes. Issue #50 explicitly calls for this coverage.

Issue Fit

The PR satisfies the requested matrix: SIGHASH_NONE, SIGHASH_SINGLE, SIGHASH_ALL|ANYONECANPAY, SIGHASH_NONE|ANYONECANPAY, and SIGHASH_SINGLE|ANYONECANPAY, while retaining the default vector. Each fixture pins the spend tx, spent outputs, leaf/control data, pubkey, signature with hashtype where applicable, raw p2mrSigMsg, final p2mrSighash, annex: none, and provenance.

Deep Checks Performed

I traced the generator’s hand-serialized P2MR sighash message against SignatureHashP2MR/SignatureHashSchnorrCommon: epoch, hashtype, version, locktime, shared input hashes, output hash behavior, spend type, current-input serialization under ANYONECANPAY, single-output hashing, leaf hash, key version, and code-separator position match the production layout. The C++ tests load all six named vectors, compare the pinned message/hash, verify positive spends, and exercise committed vs intentionally omitted fields across the matrix.

Validation Reviewed

Locally ran the generator reproducibility check from the PR body; it passed with no diff:

python3 contrib/devtools/generate-p2mr-pqc-witness-vectors.py --output /tmp/p2mr_pqc_witness_vectors_pr55.json && diff -u src/test/data/p2mr_pqc_witness_vectors.json /tmp/p2mr_pqc_witness_vectors_pr55.json

CI Core Checks passed, including the focused unit job building script_p2mr_tests.cpp and running build/bin/test_qbit --run_test=script_p2mr_tests; the new vector tests entered and passed. Docker lint also passed in the visible Full Validation jobs.

Residual Risk

Full Validation and Required Merge Gate were not complete at the time of review, so I would still wait for the final required checks before merge.

@kiwidream
kiwidream force-pushed the p2mr-checksigpqc-sighash-vectors branch from 775f260 to c7d1d2c Compare June 30, 2026 01:00
@djh58
djh58 self-requested a review June 30, 2026 13:52
djh58
djh58 previously approved these changes Jun 30, 2026
@kiwidream
kiwidream force-pushed the p2mr-checksigpqc-sighash-vectors branch 2 times, most recently from 2a3abca to 2ee233b Compare June 30, 2026 19:44
@kiwidream
kiwidream force-pushed the p2mr-checksigpqc-sighash-vectors branch from 2ee233b to 85fb76f Compare July 2, 2026 13:51
@kiwidream
kiwidream merged commit 94f6965 into 0.1.x Jul 2, 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