public inbox for bitcoindev@googlegroups.com
 help / color / mirror / Atom feed
From: "aaron.recompile" <aaron.recompile@gmail.com>
To: Bitcoin Development Mailing List <bitcoindev@googlegroups.com>
Subject: [bitcoindev] [taproot][script] 4-leaf Taproot Merkle Tree in Python: testnet implementation + control block analysis
Date: Tue, 8 Jul 2025 07:45:30 -0700 (PDT)	[thread overview]
Message-ID: <d4f04a90-9842-4260-8e7b-79ed2bc00adan@googlegroups.com> (raw)


[-- Attachment #1.1: Type: text/plain, Size: 2914 bytes --]

Hi all,

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

I’d like to share a hands-on project involving a fully constructed 4-leaf 
Taproot Merkle tree in Python, with testnet-validated spending transactions 
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 
one key path spend, all confirmed through on-chain transactions on Bitcoin 
testnet.

- Merkle tree construction and Taproot output key tweaking (internal key + 
script tree root), followed by a **byte-by-byte breakdown of the control 
blocks**, including:
    - Control byte (leaf version + parity)
    - Internal public key
    - Ordered Merkle sibling hashes

- *Code-level analysis and experimental validation of how these control 
blocks* are constructed and verified against the Taproot output, based on 
actual testnet spends.

- *Witness stack inspection and visualization of script execution*, showing 
the actual runtime behavior for each script path.

Resources:


*- Part 1: 4-leaf tree construction and testnet validation  *  
https://medium.com/@aaron.recompile/building-a-4-leaf-taproot-tree-in-python-the-first-complete-implementation-on-bitcoin-testnet-c8b66c331f29


*- Part 2: Control block structure and stack visualization  *  
https://medium.com/@aaron.recompile/taproot-control-block-deep-analysis-stack-execution-visualization-5ff10f98032c

- GitHub repo with code, testnet transactions, and diagrams  
  
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 
script trees, control blocks, and Tapscript execution through practical 
experimentation.

I’d 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,  
Aaron Zhang  
[@aaron.recompile](https://medium.com/@aaron.recompile)  
GitHub: https://github.com/btcstudy

-- 
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 email to bitcoindev+unsubscribe@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/bitcoindev/d4f04a90-9842-4260-8e7b-79ed2bc00adan%40googlegroups.com.

[-- Attachment #1.2: Type: text/html, Size: 3376 bytes --]

                 reply	other threads:[~2025-07-09 22:42 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=d4f04a90-9842-4260-8e7b-79ed2bc00adan@googlegroups.com \
    --to=aaron.recompile@gmail.com \
    --cc=bitcoindev@googlegroups.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox