1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
Delivery-date: Wed, 09 Jul 2025 15:42:54 -0700
Received: from mail-qv1-f61.google.com ([209.85.219.61])
by mail.fairlystable.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
(Exim 4.94.2)
(envelope-from <bitcoindev+bncBCWIRLWI4EPRBZHAXPBQMGQEIESL3PI@googlegroups.com>)
id 1uZdV7-00055p-VK
for bitcoindev@gnusha.org; Wed, 09 Jul 2025 15:42:54 -0700
Received: by mail-qv1-f61.google.com with SMTP id 6a1803df08f44-6fd5e0bc378sf7599156d6.1
for <bitcoindev@gnusha.org>; Wed, 09 Jul 2025 15:42:53 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=googlegroups.com; s=20230601; t=1752100968; x=1752705768; darn=gnusha.org;
h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
:list-id:mailing-list:precedence:x-original-sender:mime-version
:subject:message-id:to:from:date:sender:from:to:cc:subject:date
:message-id:reply-to;
bh=+p/daLOEVS1h+BoMcJkpBlgzLeJ2MfTKJfWetBBUSYk=;
b=cNs3h7WX1EVLJJoIpf8peQdQ5KnDbsPMbNku6P6tk7z8LbJeKSei3x+t23H1ITXvti
6vGBinBB1yhYY9022h64TnzpF8yfpfjiVPHlLmy9xn2F/zmNV/5ieXEtUr6t639ll2QQ
9pGqVn3oDo2hoRZnKSbE3nLJr49hvvNKjain3j4El6p10sEBtkCpBFJNXJMfesgNQGow
eKwKXs4Bfk3BC1yrRcoyrC6XQNfWulyLPCNX163FU+IP40PZ3APfx6mEcI8wjicPjFQ8
M9nXtctCm6I3bPQb2FTouXvv8uq4E4hwNjCKESBOKyu/1sIRsNVyeQL2120Z9C2NGpHx
kALg==
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=gmail.com; s=20230601; t=1752100968; x=1752705768; darn=gnusha.org;
h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
:list-id:mailing-list:precedence:x-original-sender:mime-version
:subject:message-id:to:from:date:from:to:cc:subject:date:message-id
:reply-to;
bh=+p/daLOEVS1h+BoMcJkpBlgzLeJ2MfTKJfWetBBUSYk=;
b=hsfxNTy865pJyDW4OfsdF758+3Gcg1LdqXCaI7KYnLk9Y3RHZ5reqFNaujPLD1c+HM
Mn8J6Roq9IF0/OIqf4IrIlkhdJfPqqflVZ25AsRr6ecPM6QacC9/kVuyj5eB1Pr/ZJrl
IdK723mKkLK14QYwSe7cFH3cSdTjJr/dUAA4YdPEB2DM5G8DzOzIptO4rjE8gpQHx+Px
MCblIu73lOu5JGvacevmKqHiZUKUzWHBBO6YLkGUByOm5SuQcIuNamxxh5YwYvxsFNa7
Lhk+w79Si79JWqgzQPm+6n86IOFZuq/P9CvuwYeJHoQTCWyJHUpO7zHEGXth8o/TKmEV
eSlA==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
d=1e100.net; s=20230601; t=1752100968; x=1752705768;
h=list-unsubscribe:list-subscribe:list-archive:list-help:list-post
:list-id:mailing-list:precedence:x-original-sender:mime-version
:subject:message-id:to:from:date:x-beenthere:x-gm-message-state
:sender:from:to:cc:subject:date:message-id:reply-to;
bh=+p/daLOEVS1h+BoMcJkpBlgzLeJ2MfTKJfWetBBUSYk=;
b=kC3kYPdi90Jt+oGwkfdTqrJbgebADYlaNMKMXQ1tmWBWOVV0wnX6GOoH0UHaLpAU0t
8E779sqUs2fYw+r8rokGB0DztfxYxhTGRQvF5tUxKLL/7HcukBZtsSJDPCahRrYdSwXJ
EbN7owkrrQkeROir4vsGH41Nu1n/JZpT3J7YNNdooGa69hmcx1lUOC+syc85UsoeAfvB
dKIKtA9MwTZiygpkZ4418vA3Y2tSuz5AKf0AXR51YpCGOJYaBxFpzKxRgFRbtSKBQw08
rZthG772Qn9trZb6SeVc1Ncon6+fLqbQhZtp2Siqi5O2LaW3UCPKO4Q3VVhaOLNiBVwh
WSAg==
Sender: bitcoindev@googlegroups.com
X-Forwarded-Encrypted: i=1; AJvYcCU9op5VZFY18Loa0fAwEuI5DDjFBoOPYDC9FCmACsDJqw0Vvynvj1gEZGlhYu1zJJEwZrrYKVdSddoN@gnusha.org
X-Gm-Message-State: AOJu0YwYa32m3HHIq8gPw0fD390zmTfcfAsap2pZN5uhLntbHocokeLr
zaWUWCfYdi2eRkh+OL+PIxTomzJx3jgP3pYSMu9HWxOp2iXTboMwfada
X-Google-Smtp-Source: AGHT+IGYIZy9c1dUUE4ZaLp5yvTu7UA80TuzU74mbatANSG6ZIgtHJ2yIROGWoPLnbLUeS8apxNaaA==
X-Received: by 2002:a05:6214:e4f:b0:704:7f0e:ca9d with SMTP id 6a1803df08f44-7048ba2e631mr59145546d6.24.1752100967545;
Wed, 09 Jul 2025 15:42:47 -0700 (PDT)
X-BeenThere: bitcoindev@googlegroups.com; h=AZMbMZfsOh1QYJ3Mq9SOWE/OP3E15jQuldk3cJ90U7U44P+hVw==
Received: by 2002:a05:6214:b68:b0:6fa:be38:256 with SMTP id
6a1803df08f44-7049559f6b5ls7087826d6.0.-pod-prod-02-us; Wed, 09 Jul 2025
15:42:44 -0700 (PDT)
X-Received: by 2002:ad4:5aa7:0:b0:702:d3c8:5c88 with SMTP id 6a1803df08f44-7048b99d922mr72317206d6.17.1752100964195;
Wed, 09 Jul 2025 15:42:44 -0700 (PDT)
Received: by 2002:a05:690c:d8b:b0:710:f35d:a3b2 with SMTP id 00721157ae682-7166a91b6ffms7b3;
Tue, 8 Jul 2025 07:45:32 -0700 (PDT)
X-Received: by 2002:a05:690c:9317:b0:712:de91:53d4 with SMTP id 00721157ae682-717ae0edb4dmr287567b3.24.1751985931512;
Tue, 08 Jul 2025 07:45:31 -0700 (PDT)
Date: Tue, 8 Jul 2025 07:45:30 -0700 (PDT)
From: "aaron.recompile" <aaron.recompile@gmail.com>
To: Bitcoin Development Mailing List <bitcoindev@googlegroups.com>
Message-Id: <d4f04a90-9842-4260-8e7b-79ed2bc00adan@googlegroups.com>
Subject: [bitcoindev] [taproot][script] 4-leaf Taproot Merkle Tree in Python:
testnet implementation + control block analysis
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_555562_1654744330.1751985930931"
X-Original-Sender: aaron.recompile@gmail.com
Precedence: list
Mailing-list: list bitcoindev@googlegroups.com; contact bitcoindev+owners@googlegroups.com
List-ID: <bitcoindev.googlegroups.com>
X-Google-Group-Id: 786775582512
List-Post: <https://groups.google.com/group/bitcoindev/post>, <mailto:bitcoindev@googlegroups.com>
List-Help: <https://groups.google.com/support/>, <mailto:bitcoindev+help@googlegroups.com>
List-Archive: <https://groups.google.com/group/bitcoindev
List-Subscribe: <https://groups.google.com/group/bitcoindev/subscribe>, <mailto:bitcoindev+subscribe@googlegroups.com>
List-Unsubscribe: <mailto:googlegroups-manage+786775582512+unsubscribe@googlegroups.com>,
<https://groups.google.com/group/bitcoindev/subscribe>
X-Spam-Score: -0.5 (/)
------=_Part_555562_1654744330.1751985930931
Content-Type: multipart/alternative;
boundary="----=_Part_555563_1234549647.1751985930931"
------=_Part_555563_1234549647.1751985930931
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi all,
I'm Aaron Zhang, an independent developer focused on Bitcoin script=20
engineering and Taproot experimentation.
I=E2=80=99d like to share a hands-on project involving a fully constructed =
4-leaf=20
Taproot Merkle tree in Python, with testnet-validated spending transactions=
=20
and in-depth analysis of control block internals.
This work features:
- Construction of a *Taproot address with 4 distinct script leaves*:
1. `OP_SHA256` + `OP_EQUAL` hashlock
2. 2-of-2 `OP_CHECKMULTISIG`
3. `OP_CSV` + `OP_CHECKSIG`
4. `OP_CHECKSIG`
- A total of *five spending paths*, including four script path spends and=
=20
one key path spend, all confirmed through on-chain transactions on Bitcoin=
=20
testnet.
- Merkle tree construction and Taproot output key tweaking (internal key +=
=20
script tree root), followed by a **byte-by-byte breakdown of the control=20
blocks**, including:
- Control byte (leaf version + parity)
- Internal public key
- Ordered Merkle sibling hashes
- *Code-level analysis and experimental validation of how these control=20
blocks* are constructed and verified against the Taproot output, based on=
=20
actual testnet spends.
- *Witness stack inspection and visualization of script execution*, showing=
=20
the actual runtime behavior for each script path.
Resources:
*- Part 1: 4-leaf tree construction and testnet validation * =20
https://medium.com/@aaron.recompile/building-a-4-leaf-taproot-tree-in-pytho=
n-the-first-complete-implementation-on-bitcoin-testnet-c8b66c331f29
*- Part 2: Control block structure and stack visualization * =20
https://medium.com/@aaron.recompile/taproot-control-block-deep-analysis-sta=
ck-execution-visualization-5ff10f98032c
- GitHub repo with code, testnet transactions, and diagrams =20
=20
https://github.com/btcstudy/btcstudy.github.io/tree/main/Not-Just-Hodling:b=
itcoin-script-Engineering/demo3_taproot_4leaf
This project aims to provide a fully verifiable and pedagogical example of=
=20
non-trivial Taproot path spends, helping developers better understand=20
script trees, control blocks, and Tapscript execution through practical=20
experimentation.
I=E2=80=99d be happy to receive any feedback or discussion around:
- Control block design and merkle path optimization
- Spend path visibility and privacy tradeoffs
- Tooling for visualizing script-path execution and verification
Thanks and best regards, =20
Aaron Zhang =20
[@aaron.recompile](https://medium.com/@aaron.recompile) =20
GitHub: https://github.com/btcstudy
--=20
You received this message because you are subscribed to the Google Groups "=
Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/=
d4f04a90-9842-4260-8e7b-79ed2bc00adan%40googlegroups.com.
------=_Part_555563_1234549647.1751985930931
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Hi all,<br /><br />I'm Aaron Zhang, an independent developer focused on Bit=
coin script engineering and Taproot experimentation.<br /><br />I=E2=80=99d=
like to share a hands-on project involving a fully constructed 4-leaf Tapr=
oot Merkle tree in Python, with testnet-validated spending transactions and=
in-depth analysis of control block internals.<br /><br />This work feature=
s:<br /><br />- Construction of a <b>Taproot address with 4 distinct script=
leaves</b>:<br />=C2=A0 =C2=A0 1. `OP_SHA256` + `OP_EQUAL` hashlock<br />=
=C2=A0 =C2=A0 2. 2-of-2 `OP_CHECKMULTISIG`<br />=C2=A0 =C2=A0 3. `OP_CSV` +=
`OP_CHECKSIG`<br />=C2=A0 =C2=A0 4. `OP_CHECKSIG`<br /><br />- A total of =
<b>five spending paths</b>, including four script path spends and one key p=
ath spend, all confirmed through on-chain transactions on Bitcoin testnet.<=
br /><br />- Merkle tree construction and Taproot output key tweaking (inte=
rnal key + script tree root), followed by a **byte-by-byte breakdown of the=
control blocks**, including:<br />=C2=A0 =C2=A0 - Control byte (leaf versi=
on + parity)<br />=C2=A0 =C2=A0 - Internal public key<br />=C2=A0 =C2=A0 - =
Ordered Merkle sibling hashes<br /><br />- <b>Code-level analysis and exper=
imental validation of how these control blocks</b> are constructed and veri=
fied against the Taproot output, based on actual testnet spends.<br /><br /=
>- <b>Witness stack inspection and visualization of script execution</b>, s=
howing the actual runtime behavior for each script path.<br /><br />Resourc=
es:<br /><br /><b>- Part 1: 4-leaf tree construction and testnet validation=
=C2=A0<br /></b>=C2=A0 https://medium.com/@aaron.recompile/building-a-4-le=
af-taproot-tree-in-python-the-first-complete-implementation-on-bitcoin-test=
net-c8b66c331f29<br /><br /><b>- Part 2: Control block structure and stack =
visualization =C2=A0<br /></b>=C2=A0 https://medium.com/@aaron.recompile/ta=
proot-control-block-deep-analysis-stack-execution-visualization-5ff10f98032=
c<br /><br />- GitHub repo with code, testnet transactions, and diagrams =
=C2=A0<br />=C2=A0 https://github.com/btcstudy/btcstudy.github.io/tree/main=
/Not-Just-Hodling:bitcoin-script-Engineering/demo3_taproot_4leaf<br /><br /=
>This project aims to provide a fully verifiable and pedagogical example of=
non-trivial Taproot path spends, helping developers better understand scri=
pt trees, control blocks, and Tapscript execution through practical experim=
entation.<br /><br />I=E2=80=99d be happy to receive any feedback or discus=
sion around:<br />- Control block design and merkle path optimization<br />=
- Spend path visibility and privacy tradeoffs<br />- Tooling for visualizin=
g script-path execution and verification<br /><br />Thanks and best regards=
, =C2=A0<br />Aaron Zhang =C2=A0<br />[@aaron.recompile](https://medium.com=
/@aaron.recompile) =C2=A0<br />GitHub: https://github.com/btcstudy
<p></p>
-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;Bitcoin Development Mailing List" group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:bitcoindev+unsubscribe@googlegroups.com">bitcoind=
ev+unsubscribe@googlegroups.com</a>.<br />
To view this discussion visit <a href=3D"https://groups.google.com/d/msgid/=
bitcoindev/d4f04a90-9842-4260-8e7b-79ed2bc00adan%40googlegroups.com?utm_med=
ium=3Demail&utm_source=3Dfooter">https://groups.google.com/d/msgid/bitcoind=
ev/d4f04a90-9842-4260-8e7b-79ed2bc00adan%40googlegroups.com</a>.<br />
------=_Part_555563_1234549647.1751985930931--
------=_Part_555562_1654744330.1751985930931--
|