Skip to content

Document and freeze the qbit P2MR v1 consensus profile before mainnet #105

Closed

Description

@kiwidream

Summary

Keep the existing qbit P2MR consensus behavior and formally define it as qbit P2MR v1.

qbit P2MR v1 intentionally uses qbit-specific commitment domains, a qbit-specific sighash domain, depth-zero script execution, and PQC opcodes. It is not consensus-compatible with BIP-360, even though both formats use the same native witness-v2, 32-byte output shape and the same 1 + 32*m control-block shape.

The current qbit implementation and its independent vectors are internally coherent. This issue does not report a verifier defect or a disagreement between current qbit nodes. Its purpose is to freeze the existing byte-level contract, state unambiguously that qbit P2MR v1 is not BIP-360, and give third-party implementations a normative specification and conformance gate.

Treat this as a pre-genesis specification and interoperability requirement, not a request to change the current consensus semantics.

Affected ref: origin/1.0.0 at 988756471aeecdf4463c04be49da2b7b89a98c21.

Why qbit P2MR v1 needs its own profile

The audit's BIP reference is pinned to bitcoin/bips@6740c533, which identifies itself as BIP-360 v0.12.0. qbit differs on several consensus surfaces:

Surface Pinned BIP-360 v0.12.0 qbit origin/1.0.0
Outer output OP_2 PUSH32 <root> Same
Leaf hash TaggedHash("TapLeaf", ...) TaggedHash("P2MRLeaf", ...)
Branch hash TaggedHash("TapBranch", ...) TaggedHash("P2MRBranch", ...)
Signature domain BIP-342 message under TapSighash Same message layout under P2MRSighash
Depth-zero leaf Commitment match succeeds without executing the script Leaf version 0xc0 executes
Active language BIP-342 Tapscript / Schnorr qbit P2MR v1 / PQC opcodes; legacy checksig is forbidden

The qbit domains are defined in src/script/interpreter.cpp, used for P2MR sighash at lines 1805-1809, and used for leaf/branch commitments at lines 2195-2228. Witness validation executes a depth-zero 0xc0 leaf at lines 2345-2406.

Restricted-output consensus accepts any native witness-v2, 32-byte program based on its outer shape at src/consensus/restricted_outputs.h:18-25. That is expected for an opaque hash commitment, but it means the funding output cannot identify which inner dialect constructed the root.

Minimal byte-level reproduction

For leaf version 0xc0 and script 00 (OP_0), the serialized leaf payload is:

c0 01 00

Independent tagged-SHA256 calculation gives:

TapLeaf:  e7e4d593fcb72926eedbe0d1e311f41acd6f6ef161dcba081a75168ec4dcd379
P2MRLeaf: fae97225114b26d9ef3e3bea70f90d08fec30d9833c50b23e4a6cf8c33e6b200

Use the BIP-derived output and depth-zero witness:

scriptPubKey: 5220e7e4d593fcb72926eedbe0d1e311f41acd6f6ef161dcba081a75168ec4dcd379
witness:      02010001c1
  • Pinned BIP-360 derives the TapLeaf root, matches the witness program, and succeeds immediately because m = 0.
  • qbit derives the P2MRLeaf root and rejects the same spend with a witness-program commitment mismatch.
  • qbit restricted-output consensus nevertheless permits the funding output because it is native witness v2 with a 32-byte program.

A separate depth-zero disagreement remains even if an implementer copies qbit's hash tags: with the qbit-derived output 5220fae97225114b26d9ef3e3bea70f90d08fec30d9833c50b23e4a6cf8c33e6b200 and the same witness, a BIP-style depth-zero shortcut succeeds, while qbit executes OP_0 and fails.

Existing coverage to build on

The following work is valuable and should be retained:

Those artifacts already pin important qbit outcomes and should form the basis of the qbit P2MR v1 conformance corpus. The remaining work is to connect them to one complete normative consensus profile and prove cross-implementation agreement. In particular, the exact P2MRLeaf, P2MRBranch, and P2MRSighash domains are not stated in the public documentation, while source and test comments repeatedly describe the incompatible rules as "BIP-360."

Intended solution

Retain the current qbit consensus semantics and freeze them as qbit P2MR v1:

  1. Publish a normative, versioned qbit P2MR v1 specification derived from the current consensus implementation.
  2. State prominently that qbit P2MR v1 is not BIP-360 compatible and that BIP-360 implementations must not be used as qbit consensus validators or qbit P2MR output builders without implementing the qbit profile.
  3. Replace misleading source and documentation references to "BIP-360 P2MR" with "qbit P2MR v1," retaining pinned BIP links only where documenting ancestry or intentional differences.
  4. Promote the existing independent qbit vectors into a versioned conformance corpus, add explicit BIP/qbit boundary cases, and require an independent implementation or oracle to consume it.
  5. Make the specification and conformance version part of the pre-mainnet integration and release checklist.

This solution should not change which transactions current qbit nodes accept. Any consensus change discovered while writing the specification must be split into a separate issue and independently reviewed rather than silently folded into this documentation work.

Acceptance criteria

  • Adopt the public profile name qbit P2MR v1 consistently across consensus comments, tests, documentation, release material, and integration guidance.
  • State explicitly that qbit P2MR v1 is not BIP-360 compatible. Pin every external specification revision cited for ancestry or comparison; do not use a floating BIP master reference as a normative dependency.
  • Publish a normative qbit P2MR consensus document that completely defines:
    • activation and native witness-program rules;
    • witness and annex parsing;
    • control-block encoding, marker bit, size, and maximum depth;
    • leaf-version masking, active/reserved ranges, and unknown-leaf behavior;
    • exact leaf and branch tagged-hash preimages and direct root comparison;
    • depth-zero behavior;
    • the complete signature message, tag, hash-type matrix, annex and code-separator commitments, and missing-output SIGHASH_SINGLE behavior;
    • active, invalid, and upgrade-reserved opcodes for each leaf version;
    • PQC algorithm/profile identifiers, public-key and signature encodings, and signature limits;
    • stack, element-size, validation-weight, and other resource limits; and
    • consensus versus relay/wallet policy boundaries.
  • Remove or qualify every source, test, and documentation reference that presents qbit's rules as BIP-360 rather than qbit P2MR v1.
  • Extend the machine-readable corpus with explicit cross-profile vectors, including:
    • the TapLeaf-root spend above: pinned-BIP accept / qbit reject;
    • the qbit-root depth-zero OP_0 spend above: shortcut accept / qbit reject;
    • positive and negative qbit vectors for commitment, sighash, leaf versions, opcode semantics, annexes, malformed inputs, and resource boundaries; and
    • expected accept/reject results and failure stage, not only computed hashes.
  • Make the corpus independently reproducible without qbit wallet, signing, or consensus helpers.
  • Run the corpus through qbit and at least one independent implementation or standalone consensus oracle, and release-gate exact agreement.
  • Inventory every supported wallet, exchange, explorer, miner/pool, signer, PSBT tool, and alternative validator; record the profile/vector version each consumes before mainnet signoff.
  • Add the qbit P2MR v1 specification version and conformance result to the mainnet release checklist, then re-run the consensus review on the exact release SHA.

Non-goals

  • Do not treat this as proof that current qbit nodes disagree with each other; the inspected qbit builders, wallet, interpreter, and tests are internally consistent.
  • Do not change the current qbit P2MR acceptance rules as part of this issue. This issue names, specifies, and tests the existing contract.
  • Do not try to infer hash provenance when a v2/32-byte funding output is created. A 32-byte commitment is opaque, so interoperability must be secured by the frozen profile, vectors, and integration gate.
  • Do not close this with documentation prose alone unless the prose is normative, versioned, matched by machine-readable vectors, and exercised by an independent oracle.

Activity

  1. added
    documentation
    enhancement
    on Jul 11, 2026
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

    documentationenhancement

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions