Path: blob/main/frontier/09-commitments-sigma-protocols/connect/schnorr-bitcoin-taproot.ipynb
483 views
Connect: Schnorr Signatures in Bitcoin Taproot
Module 09 | Real-World Connections
The Schnorr protocol from this module became Bitcoin's signature scheme via BIP 340. Here is exactly how.
Introduction
In November 2021, Bitcoin activated the Taproot upgrade (BIPs 340/341/342), the most significant protocol change since SegWit. At its core, Taproot replaced ECDSA with Schnorr signatures, the non-interactive version of the Schnorr protocol we studied in 09d and 09e.
The connection is direct:
| Module 09 concept | Bitcoin Taproot (BIP 340) |
|---|---|
| Schnorr identification protocol | Schnorr signature scheme |
| Fiat-Shamir transform | Non-interactive signatures via hashing |
| Sigma protocol (commit-challenge-respond) | Sign = commit + hash + respond |
| Proof of knowledge of discrete log | Proof of knowledge of secret key |
In this notebook, we will implement a toy version of BIP 340 Schnorr signatures and explore why Bitcoin chose Schnorr over ECDSA.
BIP 340 Schnorr Signatures
BIP 340 specifies Schnorr signatures on the secp256k1 elliptic curve (the same curve Bitcoin has always used). The signature scheme is the Fiat-Shamir transform of the Schnorr protocol:
Key generation:
Secret key: where is the curve order
Public key: (only the x-coordinate is published)
Signing message :
Choose nonce (deterministically from and )
Compute
Compute challenge: (Fiat-Shamir)
Compute
Signature is
Verification of on message :
Compute
Check:
This is exactly the Schnorr protocol from 09d, made non-interactive via Fiat-Shamir from 09e, instantiated on an elliptic curve.
Let's implement it on a small curve.
Why Schnorr over ECDSA?
Bitcoin used ECDSA for its first 12 years. Why switch to Schnorr? The answer comes from a single algebraic property: linearity.
The Schnorr response equation is linear in both and . ECDSA's equation involves a multiplicative inverse of , destroying linearity.
Linearity enables:
| Feature | Schnorr | ECDSA |
|---|---|---|
| Key aggregation | Add public keys, add partial signatures | Requires complex MPC protocols |
| Batch verification | Verify signatures faster than individual checks | Not possible |
| Adapter signatures | Atomic swaps without hash-time-lock contracts | Not possible |
| Provable security | Tight reduction to DLP in ROM | Loose reduction, relies on generic group model |
Why Key Aggregation Works: Linearity
Let's trace the algebra. Alice computes and Bob computes . The aggregate is:
Verification checks :
Everything is linear, addition in keys maps to addition in signatures. ECDSA's has no such property because the inverse breaks the linear structure.
Taproot: Hiding Scripts Behind Keys
Taproot (BIP 341) uses Schnorr signatures for an additional trick: key tweaking.
A Taproot output commits to both a public key and a script tree via a tweaked key:
Key path spend: If all parties agree, they sign with the tweaked key using . The transaction looks like any ordinary single-signature payment. Nobody can tell there was a script at all.
Script path spend: If parties disagree, reveal , , and a Merkle proof. Execute the script.
This is possible because of Schnorr's linearity: tweaking the key by adding simply adds to the secret key. ECDSA has no such clean tweaking mechanism.
Concept Map
| Module 09 Concept | Bitcoin Taproot Application |
|---|---|
| Schnorr protocol (09d) | BIP 340 signature scheme |
| Fiat-Shamir transform (09e) | Non-interactive signatures: |
| Sigma protocol structure | Sign = commit () + challenge () + respond () |
| Proof of knowledge of DL | Proof of knowledge of secret key |
| Linearity of | Key aggregation (MuSig2), batch verification |
| Nonce reuse vulnerability | RFC 6979 deterministic nonces in BIP 340 |
| Soundness (cannot forge without ) | Unforgeability of signatures (EUF-CMA) |
Summary
| Concept | Key idea |
|---|---|
| BIP 340 | Schnorr signatures on secp256k1, the Fiat-Shamir transform of the Schnorr identification protocol |
| Key aggregation | MuSig2 enables -of- multisig that looks like a single signature on-chain, thanks to the linearity of |
| Batch verification | Multiple signatures can be checked faster than individual verification, again exploiting linearity |
| Key tweaking | Script trees are hidden behind ordinary-looking public keys, enabling privacy-preserving smart contracts |
| Why not ECDSA | The equation is not linear, so none of these features are possible with ECDSA |
The journey from a three-message interactive proof (commit, challenge, respond) to a deployed signature scheme signing billions of dollars in transactions is remarkably direct. Every concept from Module 09, including sigma protocols, Fiat-Shamir, and nonce discipline, is load-bearing in Bitcoin's cryptographic infrastructure.