百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
T

taproot-workshop

> 编程语言
开源

Taproot 和 Schnorr Python 库和文档。

400 stars0 点赞1 次浏览
访问官网GitHub

工具介绍

Taproot 和 Schnorr Python 库和文档。

taproot-workshop

This repo contains the Jupyter notebooks for Optech's Schnorr/Taproot workshops.

Introduction

For the purposes of demonstrating the features of schnorr and taproot to the Bitcoin developer community, we have developed an extended Python library on top of Bitcoin Core's function test framework, which provides Python classes and methods to build more sophisticated Taproot transactions and various schnorr signature schemes for preliminary evaluation.

Note: This Library is intended for demonstrative and educational purposes only.

Warning

Do not run test instances of bitcoind on the same machine that you store your Bitcoin private keys. These notebooks shouldn't interfere with your standard bitcoin data directory, but why risk it?

Background

It will be useful to have some background on schnorr and taproot before running through the exercises in this repository.

Schnorr

  • bip-0340: This technical document proposes a standard for 64-byte Schnorr signatures over the elliptic curve secp256k1.
  • Taproot, and Schnorr, and SIGHASH_NOINPUT, oh my!: video about Taproot, Schnorr, and SIGHASH_NOINPUT by Pieter Wuille, author of the Schnorr/Taproot proposal. (Note: since the video SIGHASH_NOINPUT is no longer grouped with the taproot/schnorr soft fork proposal) (transcript)
  • Optech Executive Briefing The Next Softfork: Optech's video presentation of the next proposed soft fork.

Taproot

  • bip-0341: This technical document proposes a new SegWit version 1 output type, with spending rules based on Taproot, Schnorr signatures, and Merkle branches.
  • bip-0342: This technical document specifies the semantics of the initial scripting system under bip-0341.
  • Bitcoin Optech’s Overview of the Taproot & Tapscript proposed BIPs: Summary of bip-341 and bip-342.

Output Descriptors

  • Support for Output Descriptors in Bitcoin Core: Since Bitcoin Core v0.17, there is support for output descriptors. This is a simple language which can be used to describe collections of output scripts.

Running the notebooks

The notebooks can either be run in the cloud or in a local Jupyter environment.

Google Colab cloud

Google Colab is a Jupyter notebook environment that requires no setup, is free to use and runs entirely in the Google cloud. Running the Optech Schnorr/Taproot workshop in Google Colab requires you to login with your Google account. The Colab environment disconnects your runtime after 30 minutes of inactivity and has a maximum session length of 12 hours. Don't forget to save your progress. You can have multiple runtimes and notebooks open at the same time.

The following notebooks are located in the Colab branch of this repository and are modified to run on Google Colab.

  • 0.1-test-notebook.ipynb on Colab
  • 0.2-elliptic-curve-math.ipynb on Colab
  • 0.3-tagged-hashes.ipynb on Colab
  • 1.1-schnorr-signatures.ipynb on Colab
  • 1.2-musig.ipynb on Colab
  • 2.0-taproot-introduction.ipynb on Colab
  • 2.1-segwit-version-1.ipynb on Colab
  • 2.2-taptweak.ipynb on Colab
  • 2.3-tapscript.ipynb on Colab
  • 2.4-taptree.ipynb on Colab
  • 2.5-huffman.ipynb on Colab
  • 3.1-degrading-multisig-case-study.ipynb on Colab

Local setup

The Optech Schnorr/Taproot workshop can be setup and run locally. This section lists the necessary steps and requirements.

Clone this (bitcoinops/taproot-workshop) repository

$ git clone https://github.com/bitcoinops/taproot-workshop.git

Build a taproot-supporting bitcoind

These workbooks require a bitcoind with version 0.21 or later which supports schnorr and taproot.

If you do not already have the Bitcoin Core repo on your local machine, then clone it with:

$ git clone https://github.com/bitcoin/bitcoin.git

Note the path where you cloned the bitcoin repository and add it to the config.ini file in your taproot-workshop repository. For example, set:

SOURCE_DIRECTORY=/Users/username/bitcoin

Build bitcoind locally. See the build documentation (build-xxxx.md) in the Bitcoin Core repository docs directory for additional documentation on building bitcoind on Unix, macOS, or Windows.

Note that these notebooks will make use of the bitcoind wallet and so when following the build instructions above, do not use the --disable-wallet flag. Be sure to build with berkeley-db support which is required for legacy wallets.

No need to run bitcoind or download the mainchain or testnet blockchain. We will run in regtest mode and spawn node instances via scripts.

Python 3

Verify you have python3 installed:

$ python3 --version

If not, you should install Python 3.

Linux:

$ sudo apt-get install python3

macOS (using homebrew):

$ brew install python3

Windows:

  • Install using binary from python.org as appropriate for your system

Python Dependencies

This workshop uses some Python dependencies, particularly jupyter-notebook. To keep dependencies local to the project, you should create and activate a virtual environment. You can skip this step if you're happy to install the dependencies globally.

Make sure you are in your taproot-workshop repository folder.

$ python3 -m venv .venv && source .venv/bin/activate

(if you're using the csh or fish shells, replace .venv/bin/activate with .venv/bin/activate.csh or .venv/bin/activate.fish)

Install dependencies:

$ python3 -m pip install -r requirements.txt

Ensure jupyter notebook is installed:

$ jupyter notebook --version

Jupyter notebook is a handy tool which allow us to run python code directly in an interactive document like this one. The workshop materials are built directly with jupyter .ipynb files, which you can open once you have jupyter installed.

Start jupyter notebook to see exercises:

$ jupyter notebook

Jupyter will start a notebook server in your terminal, and provide a link for your browser from which you can interact with notebook files. If your browser doesn't automatically open the notebook file explorer, click on the link provided by jupyter notebook server in the terminal.

  • Click on the 0.1-test-notebook.ipynb notebook.
  • Verify that 0.1-test-notebook.ipynb passes all checks.

After you have run the 0.1 example exercises, please also run through the 0.2-elliptic-curve-math.ipynb and 0.3-tagged-hashes.ipynb notebooks and exercises before the workshop.

Notebooks 1.x, 2.x, etc will be covered during the workshop. There is no need to run through those beforehand.

Stop the current running jupyter session using Control-C in the terminal.

After you have finished your jupyter session, you can deactivate the Python virtual environment with:

$ deactivate

Issues· 9 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Python

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言