Commit Graph
19 Commits
Author SHA1 Message Date
JP 1baf0e71bb bip360: fix leafHashes order and a control byte in the pqc vectors
In p2mr_pqc_construction.json, the three-leaf vectors
(p2mr_three_leaf_complex, p2mr_three_leaf_alternative) listed
intermediary.leafHashes with entries 0 and 2 swapped relative to the
depth-first order of the script tree, while the merkle root,
scriptPubKey, address and control blocks all follow depth-first
order (as do the same trees in p2mr_construction.json).

In p2mr_different_version_leaves, scriptPathControlBlocks[1] started
with byte 0xc1 although the leaf it commits to has leafVersion 0xfa;
the control byte carries the leaf version in its upper 7 bits with
the low bit set, so it must be 0xfb. The vector's leafHashes[1] and
merkle root already correspond to the 0xfa leaf.
2026-07-27 21:40:00 +01:00
jbride cca3852acc bip360: remove rust and js reference implementations as per https://github.com/bitcoin/bips/pull/2202 2026-07-16 22:06:39 -06:00
notmike 3e3e4347e2 bip360: cleanup rust tests a bit and remove unused imports 2026-06-28 20:33:31 -06:00
notmike 75167ec077 bip360: mask tapleaf_version in tapleaf_hash 2026-06-27 22:40:15 -06:00
notmike 94b0f9db4c bip360: consistency changes to p2mr core functions
Standardizes all P2MR-specific functions to use bytes uniformly for
input/output. Hex conversions are now confined to two boundaries:
reading `script` field out of ScriptTree input, and comparing against
hex-encoded test vector data in `run_single_test`.

bech32 functions and s2w are left unchanged.
2026-06-26 23:03:50 -06:00
notmike 64d068e9d1 bip360: minor syntax fix on tapbranch_hash() 2026-06-26 20:08:22 -06:00
notmike 8ea1eaac2d bip360: move collect_leaf_hashes() to the test code section 2026-06-26 20:03:12 -06:00
notmike ac2aa2ff7d bip360: much cleaner, more readable s2w function 2026-06-26 20:03:12 -06:00
notmike 9bf46b5cfe bip360: make consistent use of h2b 2026-06-26 20:03:12 -06:00
notmikeandconduition 50a6b91352 bip360: simplify tapbranch_hash function
Implements @conduitions improvement on tapbranch_hash()

Co-authored-by: conduition <conduition@proton.me>
2026-06-26 20:00:28 -06:00
notmike 2706a6181d bip360: Optional type removed / no longer needed 2026-06-26 19:35:32 -06:00
conduition 1325ccc7db return type is not optional anymore 2026-06-27 01:15:28 +00:00
conduition 86e7f9d4ca add new test case for duplicate script leaves 2026-06-27 01:12:47 +00:00
conduition 98c0289805 bip360: simplify computing control blocks using explicit traversal paths
This refactors `compute_control_block` to improve performance, and make
the function simpler to read (to me at least).

The previous version walked the entire script tree searching for the
first matching instance of the leaf node.

The new version expects the caller to pass in an explicit `path`
parameter, which tells us exactly where the leaf node lives, with
left/right steps encoded as bits in an integer. We walk down the
tree straight to that leaf node, and build the control block as we go.

This might not be the best DX for a real-world API or library, but this
is just reference code, so we can accept poor usage ergonomics if it makes
the code clearer and more explicit.
2026-06-27 01:11:26 +00:00
notmike 29e1a158e7 bip-0360: added python reference example; test vector fixes
This commit adds a python reference example for construction of BIP-360 outputs and control blocks.
This commit also updates the test vectors.
2026-06-26 13:20:03 -06:00
jbride 8d28eb4517 bip360 test vectors: control block now reflects use of non-standard
leaf version
2026-06-25 19:59:03 -06:00
jbride 907db20348 bip360 test vectors: non-standard leaf version should be allowed during construction of P2MR output (#46) 2026-06-25 19:59:03 -06:00
jbride 35b9ffe21b bip360 test vectors: elements in control block array should be ordered to match tree structure of test vectors (#45) 2026-06-25 19:59:03 -06:00
eae7d9fc57 BIP360: Pay to Merkle Root (P2MR) (#1670)
Review comments and assistance by:
  Armin Sabouri <armins88@gmail.com>
  D++ <82842780+dplusplus1024@users.noreply.github.com>
  Jameson Lopp <jameson.lopp@gmail.com>
  jbride <jbride2001@yahoo.com>
  Joey Yandle <xoloki@gmail.com>
  Jon Atack <jon@atack.com>
  Jonas Nick <jonasd.nick@gmail.com>
  Kyle Crews <kylecrews@Kyles-Mac-Studio.local>
  Mark "Murch" Erhardt <murch@murch.one>
  notmike-5 <notmike-5@users.noreply.github.com>
  Vojtěch Strnad <43024885+vostrnad@users.noreply.github.com>

Co-authored-by: Ethan Heilman <ethan.r.heilman@gmail.com>
Co-authored-by: Isabel Foxen Duke <110147802+Isabelfoxenduke@users.noreply.github.com>
2026-02-11 13:01:47 -08:00