Skip to content

Commit 407d032

Browse files
authored
P2TSH -> P2MR (#42)
* P2TSH: Taptree can now be populated with a mix of leaves secured either via Schnorr based locking script or SLH-DSA based locking script * P2TSH: Improved docs and variable names * p2tsh: even more improvements to docs for Rust implementation * p2tsh rust: now using libbitcoinpqc bindings package (segregated from core C implementation) * bip360: p2tsh -> p2mr * BIP360: Test that P2TR uses only witness version 1 bitcoin#1670 (comment)
1 parent 2a041bf commit 407d032

36 files changed

+894
-643
lines changed

bip-0360/ref-impl/common/tests/data/p2tsh_construction.json renamed to bip-0360/ref-impl/common/tests/data/p2mr_construction.json

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,37 @@
22
"version": 1,
33
"test_vectors": [
44
{
5-
"id": "p2tsh_missing_leaf_script_tree_error",
6-
"objective": "Tests P2TSH with missing leaf script tree",
5+
"id": "p2tr_using_v2_witness_version_error",
6+
"objective": "Tests that a P2TR v2 scriptPubKey fails with use of witness version 2",
7+
"given": {
8+
"internalPubkey": "d6889cb081036e0faefa3a35157ad71086b123b2b144b649798b494c300a961d",
9+
"scriptTree": null
10+
},
11+
"intermediary": {
12+
"merkleRoot": null,
13+
"tweak": "b86e7be8f39bab32a6f2c0443abbc210f0edac0e2c53d501b36b64437d9c6c70",
14+
"tweakedPubkey": "53a1f6e454df1aa2776a2814a721372d6258050de330b3c6d10ee8f4e0dda343"
15+
},
16+
"expected": {
17+
"scriptPubKey": "522053a1f6e454df1aa2776a2814a721372d6258050de330b3c6d10ee8f4e0dda343",
18+
"error": "P2TR requires witness version of 1"
19+
}
20+
},
21+
{
22+
"id": "p2mr_missing_leaf_script_tree_error",
23+
"objective": "Tests P2MR with missing leaf script tree",
724
"given": {
825
"script_tree": ""
926
},
1027
"intermediary": {
1128
},
1229
"expected": {
13-
"error": "P2TSH requires a script tree with at least one leaf"
30+
"error": "P2MR requires a script tree with at least one leaf"
1431
}
1532
},
1633
{
17-
"id": "p2tsh_single_leaf_script_tree",
18-
"objective": "Tests P2TSH with single leaf script tree",
34+
"id": "p2mr_single_leaf_script_tree",
35+
"objective": "Tests P2MR with single leaf script tree",
1936
"given": {
2037
"scriptTree": {
2138
"id": 0,
@@ -39,8 +56,8 @@
3956
}
4057
},
4158
{
42-
"id": "p2tsh_different_version_leaves",
43-
"objective": "Tests P2TSH with two script leaves of different versions. TO-DO: currently ignores given leaf version and over-rides. Probably better to throw error",
59+
"id": "p2mr_different_version_leaves",
60+
"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",
4461
"given": {
4562
"scriptTree": [
4663
{
@@ -75,8 +92,8 @@
7592
}
7693
},
7794
{
78-
"id": "p2tsh_simple_lightning_contract",
79-
"objective": "Tests P2TSH with two script leaves that simulate a simple lightning network contract. Reference: https://github.com/bitcoin-core/btcdeb/blob/master/doc/tapscript-example-with-tap.md",
95+
"id": "p2mr_simple_lightning_contract",
96+
"objective": "Tests P2MR with two script leaves that simulate a simple lightning network contract. Reference: https://github.com/bitcoin-core/btcdeb/blob/master/doc/tapscript-example-with-tap.md",
8097
"given": {
8198
"scriptTree": [
8299
{
@@ -112,8 +129,8 @@
112129
}
113130
},
114131
{
115-
"id": "p2tsh_two_leaf_same_version",
116-
"objective": "Tests P2TSH with two script leaves of same version",
132+
"id": "p2mr_two_leaf_same_version",
133+
"objective": "Tests P2MR with two script leaves of same version",
117134
"given": {
118135
"scriptTree": [
119136
{
@@ -148,8 +165,8 @@
148165
}
149166
},
150167
{
151-
"id": "p2tsh_three_leaf_complex",
152-
"objective": "Tests P2TSH with a complex three-leaf script tree structure, demonstrating nested script paths and multiple verification options",
168+
"id": "p2mr_three_leaf_complex",
169+
"objective": "Tests P2MR with a complex three-leaf script tree structure, demonstrating nested script paths and multiple verification options",
153170
"given": {
154171
"internalPubkey": "e0dfe2300b0dd746a3f8674dfd4525623639042569d829c7f0eed9602d263e6f",
155172
"scriptTree": [
@@ -194,8 +211,8 @@
194211
}
195212
},
196213
{
197-
"id": "p2tsh_three_leaf_alternative",
198-
"objective": "Tests another variant of P2TSH with three leaves arranged in a different tree structure, showing alternative script path spending options",
214+
"id": "p2mr_three_leaf_alternative",
215+
"objective": "Tests another variant of P2MR with three leaves arranged in a different tree structure, showing alternative script path spending options",
199216
"given": {
200217
"internalPubkey": "55adf4e8967fbd2e29f20ac896e60c3b0f1d5b0efa9d34941b5958c7b0a0312d",
201218
"scriptTree": [

bip-0360/ref-impl/common/tests/data/p2tsh_pqc_construction.json renamed to bip-0360/ref-impl/common/tests/data/p2mr_pqc_construction.json

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,20 @@
22
"version": 1,
33
"test_vectors": [
44
{
5-
"id": "p2tsh_missing_leaf_script_tree_error",
6-
"objective": "Tests P2TSH with missing leaf script tree",
5+
"id": "p2mr_missing_leaf_script_tree_error",
6+
"objective": "Tests P2MR with missing leaf script tree",
77
"given": {
88
"script_tree": ""
99
},
1010
"intermediary": {
1111
},
1212
"expected": {
13-
"error": "P2TSH requires a script tree with at least one leaf"
13+
"error": "P2MR requires a script tree with at least one leaf"
1414
}
1515
},
1616
{
17-
"id": "p2tsh_single_leaf_script_tree",
18-
"objective": "Tests P2TSH with single leaf script tree",
17+
"id": "p2mr_single_leaf_script_tree",
18+
"objective": "Tests P2MR with single leaf script tree",
1919
"given": {
2020
"scriptTree": {
2121
"id": 0,
@@ -40,8 +40,8 @@
4040
}
4141
},
4242
{
43-
"id": "p2tsh_different_version_leaves",
44-
"objective": "Tests P2TSH with two script leaves of different versions. TO-DO: currently ignores given leaf version and over-rides. Probably better to throw error",
43+
"id": "p2mr_different_version_leaves",
44+
"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",
4545
"given": {
4646
"scriptTree": [
4747
{
@@ -77,8 +77,8 @@
7777
}
7878
},
7979
{
80-
"id": "p2tsh_simple_lightning_contract",
81-
"objective": "Tests P2TSH with two script leaves that simulate a simple lightning network contract. Reference: https://github.com/bitcoin-core/btcdeb/blob/master/doc/tapscript-example-with-tap.md",
80+
"id": "p2mr_simple_lightning_contract",
81+
"objective": "Tests P2MR with two script leaves that simulate a simple lightning network contract. Reference: https://github.com/bitcoin-core/btcdeb/blob/master/doc/tapscript-example-with-tap.md",
8282
"given": {
8383
"scriptTree": [
8484
{
@@ -116,8 +116,8 @@
116116
}
117117
},
118118
{
119-
"id": "p2tsh_two_leaf_same_version",
120-
"objective": "Tests P2TSH with two script leaves of same version",
119+
"id": "p2mr_two_leaf_same_version",
120+
"objective": "Tests P2MR with two script leaves of same version",
121121
"given": {
122122
"scriptTree": [
123123
{
@@ -153,8 +153,8 @@
153153
}
154154
},
155155
{
156-
"id": "p2tsh_three_leaf_complex",
157-
"objective": "Tests P2TSH with a complex three-leaf script tree structure, demonstrating nested script paths and multiple verification options",
156+
"id": "p2mr_three_leaf_complex",
157+
"objective": "Tests P2MR with a complex three-leaf script tree structure, demonstrating nested script paths and multiple verification options",
158158
"given": {
159159
"scriptTree": [
160160
{
@@ -201,8 +201,8 @@
201201
}
202202
},
203203
{
204-
"id": "p2tsh_three_leaf_alternative",
205-
"objective": "Tests another variant of P2TSH with three leaves arranged in a different tree structure, showing alternative script path spending options",
204+
"id": "p2mr_three_leaf_alternative",
205+
"objective": "Tests another variant of P2MR with three leaves arranged in a different tree structure, showing alternative script path spending options",
206206
"given": {
207207
"scriptTree": [
208208
{

bip-0360/ref-impl/common/utils/signet_miner_loop.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Invokes mining simulator a configurable number of times
44

5-
if [ -z "${P2TSH_ADDR}" ]; then
6-
echo "Error: Environment variable P2TSH_ADDR needs to be set"
5+
if [ -z "${P2MR_ADDR}" ]; then
6+
echo "Error: Environment variable P2MR_ADDR needs to be set"
77
exit 1
88
fi
99

@@ -33,7 +33,7 @@ for ((i=1; i<=LOOP_COUNT; i++))
3333
do
3434
echo "Iteration $i of $LOOP_COUNT"
3535
$BITCOIN_SOURCE_DIR/contrib/signet/miner --cli "bitcoin-cli -conf=$BITCOIN_CONF_FILE_PATH" generate \
36-
--address $P2TSH_ADDR \
36+
--address $P2MR_ADDR \
3737
--grind-cmd "$BITCOIN_SOURCE_DIR/build/bin/bitcoin-util grind" \
3838
--poolid "$POOL_ID" \
3939
--min-nbits --set-block-time $(date +%s)

bip-0360/ref-impl/common/utils/workshop/Dockerfile.bcli

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# podman build -f Dockerfile.bcli -t quay.io/jbride2000/p2tsh_bcli:0.1 .
2-
# podman run -it --entrypoint /bin/bash quay.io/jbride200/p2tsh_bcli:0.1
1+
# podman build -f Dockerfile.bcli -t quay.io/jbride2000/p2mr_bcli:0.1 .
2+
# podman run -it --entrypoint /bin/bash quay.io/jbride200/p2mr_bcli:0.1
33

44
FROM rust:1-slim-bookworm AS builder
55

@@ -28,7 +28,7 @@ WORKDIR /bitcoin
2828

2929
# Copy Bitcoin Core source (or clone)
3030
# COPY . /bitcoin
31-
RUN git clone --branch p2tsh-pqc --single-branch https://github.com/jbride/bitcoin.git
31+
RUN git clone --branch p2mr-pqc --single-branch https://github.com/jbride/bitcoin.git
3232

3333
# Environment variables for musl
3434
ENV CC=gcc

bip-0360/ref-impl/common/utils/workshop/Dockerfile.full

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# podman build -f Dockerfile.full -t quay.io/jbride2000/p2tsh_demo:0.1 .
2-
# podman run -it --entrypoint /bin/bash quay.io/jbride2000/p2tsh_demo:0.1
1+
# podman build -f Dockerfile.full -t quay.io/jbride2000/p2mr_demo:0.1 .
2+
# podman run -it --entrypoint /bin/bash quay.io/jbride2000/p2mr_demo:0.1
33

44
FROM rust:1-slim-bookworm AS builder
55

@@ -28,7 +28,7 @@ WORKDIR /bitcoin
2828

2929
# Copy Bitcoin Core source (or clone)
3030
# COPY . /bitcoin
31-
RUN git clone --branch p2tsh-pqc --single-branch https://github.com/jbride/bitcoin.git
31+
RUN git clone --branch p2mr-pqc --single-branch https://github.com/jbride/bitcoin.git
3232

3333
# Environment variables for musl
3434
ENV CC=gcc
@@ -96,7 +96,7 @@ USER bip360
9696

9797
WORKDIR /home/bip360
9898

99-
RUN git clone --no-checkout --depth 1 --branch p2tsh-pqc \
99+
RUN git clone --no-checkout --depth 1 --branch p2mr-pqc \
100100
--single-branch https://github.com/jbride/bips.git bips && \
101101
cd bips && \
102102
git sparse-checkout init --cone && \

bip-0360/ref-impl/js/README.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,6 @@ $ npx tsc
1313
1414
1515
# run tests
16-
$ node src/p2tsh-example.ts
16+
$ node src/p2mr-example.ts
1717
$ node src/test-npm-pqc-package.js
1818
-----

bip-0360/ref-impl/js/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bip-0360/ref-impl/js/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
"typescript": "^5.9.3"
1616
},
1717
"dependencies": {
18-
"@jbride/bitcoinjs-lib": "^7.0.0-rc.0-p2tsh-0.0",
18+
"@jbride/bitcoinjs-lib": "^7.0.0-rc.0-p2mr-0.0",
1919
"@jbride/bitcoinpqc-wasm": "^0.1.1",
2020
"ecpair": "^3.0.0",
2121
"tiny-secp256k1": "^2.2.4"

0 commit comments

Comments
 (0)