From mboxrd@z Thu Jan 1 00:00:00 1970 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 ) 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 ; 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" To: Bitcoin Development Mailing List Message-Id: 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: X-Google-Group-Id: 786775582512 List-Post: , List-Help: , List-Archive: , List-Unsubscribe: , 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,

I'm Aaron Zhang, an independent developer focused on Bit= coin script engineering and Taproot experimentation.

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.

This work feature= s:

- Construction of a Taproot address with 4 distinct script= leaves:
=C2=A0 =C2=A0 1. `OP_SHA256` + `OP_EQUAL` hashlock
= =C2=A0 =C2=A0 2. 2-of-2 `OP_CHECKMULTISIG`
=C2=A0 =C2=A0 3. `OP_CSV` += `OP_CHECKSIG`
=C2=A0 =C2=A0 4. `OP_CHECKSIG`

- A total of = five spending paths, including four script path spends and one key p= ath spend, all confirmed through on-chain transactions on Bitcoin testnet.<= 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:
=C2=A0 =C2=A0 - Control byte (leaf versi= on + parity)
=C2=A0 =C2=A0 - Internal public key
=C2=A0 =C2=A0 - = Ordered Merkle sibling hashes

- Code-level analysis and exper= imental validation of how these control blocks are constructed and veri= fied against the Taproot output, based on actual testnet spends.

- Witness stack inspection and visualization of script execution, s= howing the actual runtime behavior for each script path.

Resourc= es:

- Part 1: 4-leaf tree construction and testnet validation= =C2=A0
=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

- Part 2: Control block structure and stack = visualization =C2=A0
=C2=A0 https://medium.com/@aaron.recompile/ta= proot-control-block-deep-analysis-stack-execution-visualization-5ff10f98032= c

- GitHub repo with code, testnet transactions, and diagrams = =C2=A0
=C2=A0 https://github.com/btcstudy/btcstudy.github.io/tree/main= /Not-Just-Hodling:bitcoin-script-Engineering/demo3_taproot_4leaf

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.

I=E2=80=99d be happy to receive any feedback or discus= sion around:
- Control block design and merkle path optimization
= - Spend path visibility and privacy tradeoffs
- Tooling for visualizin= g script-path execution and verification

Thanks and best regards= , =C2=A0
Aaron Zhang =C2=A0
[@aaron.recompile](https://medium.com= /@aaron.recompile) =C2=A0
GitHub: https://github.com/btcstudy

--
You received this message because you are subscribed to the Google Groups &= quot;Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an e= mail to bitcoind= ev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoind= ev/d4f04a90-9842-4260-8e7b-79ed2bc00adan%40googlegroups.com.
------=_Part_555563_1234549647.1751985930931-- ------=_Part_555562_1654744330.1751985930931--