From 907db2034822fb18010e1b65ea1167c303175d33 Mon Sep 17 00:00:00 2001 From: jbride Date: Wed, 22 Apr 2026 10:35:07 -0600 Subject: [PATCH] bip360 test vectors: non-standard leaf version should be allowed during construction of P2MR output (#46) --- bip-0360/ref-impl/common/tests/data/p2mr_construction.json | 2 +- bip-0360/ref-impl/rust/tests/p2mr_construction.rs | 3 +++ bip-0360/ref-impl/rust/tests/p2mr_pqc_construction.rs | 3 +++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/bip-0360/ref-impl/common/tests/data/p2mr_construction.json b/bip-0360/ref-impl/common/tests/data/p2mr_construction.json index 166b7a8d..c6b90683 100644 --- a/bip-0360/ref-impl/common/tests/data/p2mr_construction.json +++ b/bip-0360/ref-impl/common/tests/data/p2mr_construction.json @@ -57,7 +57,7 @@ }, { "id": "p2mr_different_version_leaves", - "objective": "Tests P2MR with two script leaves of different versions. TO-DO: currently ignores given leaf version and over-rides. Probably better to throw error", + "objective": "Tests P2MR with two script leaves of different versions. An unknown leaf version should be accepted and the P2MR output constructed successfully.", "given": { "scriptTree": [ { diff --git a/bip-0360/ref-impl/rust/tests/p2mr_construction.rs b/bip-0360/ref-impl/rust/tests/p2mr_construction.rs index bf1f9bbf..e9d93f7b 100644 --- a/bip-0360/ref-impl/rust/tests/p2mr_construction.rs +++ b/bip-0360/ref-impl/rust/tests/p2mr_construction.rs @@ -65,6 +65,9 @@ fn test_p2mr_single_leaf_script_tree() { process_test_vector_p2mr(test_vector).unwrap(); } +/// Verifies that P2MR construction succeeds when leaves carry non-standard leaf versions (e.g. 0xfa). +/// Unknown leaf versions are accepted: the TapLeaf hash is computed using the supplied version, +/// and the resulting merkle root and control blocks are valid. #[test] fn test_p2mr_different_version_leaves() { diff --git a/bip-0360/ref-impl/rust/tests/p2mr_pqc_construction.rs b/bip-0360/ref-impl/rust/tests/p2mr_pqc_construction.rs index 6a7ec8f9..22f13ae4 100644 --- a/bip-0360/ref-impl/rust/tests/p2mr_pqc_construction.rs +++ b/bip-0360/ref-impl/rust/tests/p2mr_pqc_construction.rs @@ -52,6 +52,9 @@ fn test_p2mr_pqc_single_leaf_script_tree() { process_test_vector_p2mr(test_vector).unwrap(); } +/// Verifies that P2MR construction succeeds when leaves carry non-standard leaf versions (e.g. 0xfa). +/// Unknown leaf versions are accepted: the TapLeaf hash is computed using the supplied version, +/// and the resulting merkle root and control blocks are valid. #[test] fn test_p2mr_pqc_different_version_leaves() {