Taproot is the Bitcoin soft fork that activated at block 709,632 in November 2021. It bundled three proposals: BIP-340 adds Schnorr signatures on secp256k1, BIP-341 defines a new SegWit version 1 output type (P2TR, addresses starting bc1p), and BIP-342 (Tapscript) updates the scripting rules. A Taproot output is a single 32-byte public key that can be spent either with one signature (the key path) or by revealing one script from a hidden Merkle tree of alternative spending conditions (the script path). Because Schnorr signatures can be combined, a multisig or complex contract that settles cooperatively looks on-chain exactly like a single-key payment: smaller, cheaper and more private.
Why Bitcoin wanted Schnorr signatures
Bitcoin launched with ECDSA, a signature scheme that works but has awkward properties. ECDSA signatures are DER-encoded and around 71 to 72 bytes, they are malleable in subtle ways, and their maths doesn't let several signers combine their keys and signatures into one.
Schnorr signatures fix this. On the same secp256k1 curve, with the same private keys, BIP-340 defines:
- 32-byte x-only public keys (the y-coordinate is implied to be even) and 64-byte signatures (
R.x || s). - A provable security reduction to the discrete logarithm problem, with fewer assumptions than ECDSA.
- Non-malleable signatures by construction.
- Batch verification: a node can check many signatures together faster than one at a time.
- Linearity, the property that matters most.
A Schnorr signature is s = k + e·d, where d is the private key, k a secret nonce with public point R = k·G, and e a hash of R, the public key and the message. Because s is linear in the key, signatures and keys add up. Several parties can combine their public keys into one aggregate key, and with an interactive protocol such as MuSig2 (BIP-327) produce a single 64-byte signature valid for that aggregate. A verifier can't tell it from an ordinary single-signer signature. Threshold schemes such as FROST build on the same property for t-of-n signing.
BIP-340 also introduces tagged hashes, used throughout Taproot so that a hash computed for one purpose can never be reused for another:
import hashlib
def tagged_hash(tag: str, msg: bytes) -> bytes:
t = hashlib.sha256(tag.encode()).digest()
return hashlib.sha256(t + t + msg).digest()
# e.g. the challenge hash e = tagged_hash("BIP0340/challenge", R_x + P_x + msg)
How a Taproot output works
A P2TR output script is OP_1 <32-byte key Q>. That key Q is not usually your raw public key. It is an internal key P tweaked by a commitment to a script tree:
t = tagged_hash("TapTweak", P || merkle_root)
Q = P + t·G
The script tree is a Merkle tree whose leaves are Tapscripts (each leaf is hashed with the tag TapLeaf, each branch with TapBranch). If you want no scripts at all, the tweak commits to an empty tree, which is what standard single-key wallets do under BIP-86, the derivation path m/86'/0'/0' mentioned in how seed phrases and derivation paths work. The Merkle tree mechanics are the same as in how Merkle trees and Merkle proofs work: one root commits to every leaf, and a short path proves a single leaf.
There are two ways to spend:
| Key path | Script path | |
|---|---|---|
| Witness | One 64-byte Schnorr signature (65 with a non-default sighash flag) | Script inputs, the script, and a control block |
| What it reveals | Nothing beyond "a key signed" | The one leaf used, plus the Merkle path to it |
| Typical use | Normal payments, cooperative closes, MuSig2 multisig | Fallbacks: timelocks, recovery keys, disputes |
The control block holds a leaf version byte (with the parity of Q), the 32-byte internal key and the sibling hashes up the tree, so the verifier can recompute Q and confirm that this script was committed to. The tree can be up to 128 levels deep, and unused branches are never published. If no party should be able to use the key path, the internal key is set to a provably unspendable "nothing up my sleeve" point given in BIP-341.
This structure is what makes contracts private. A 2-of-3 wallet with a timelocked recovery key can put the everyday 2-of-3 signers behind a MuSig2 or FROST aggregate key and the recovery condition in a leaf. As long as the signers cooperate, every spend is a single signature that reveals no policy at all.
What Tapscript changed
BIP-342 applies to scripts spent through the script path. The main differences from legacy and SegWit v0 script:
OP_CHECKMULTISIGis disabled. It verified signatures inefficiently and can't be batched. Tapscript replaces it withOP_CHECKSIGADD, which adds 1 to a counter for each valid signature:
<pubkey_A> OP_CHECKSIG <pubkey_B> OP_CHECKSIGADD <pubkey_C> OP_CHECKSIGADD 2 OP_NUMEQUAL
- Signature checks use Schnorr and x-only keys. Empty signatures mean "this key didn't sign"; invalid non-empty signatures fail the script.
- The 10,000-byte script size and 201-opcode limits are gone, replaced by a signature-operation budget tied to the witness size. That is why large inscriptions became possible, as described in how Ordinals and inscriptions use Taproot witnesses.
- Upgrade hooks. Unused opcodes became
OP_SUCCESSx, and leaves carry a version byte, so future soft forks can add opcodes cleanly.
Taproot also changed the signature hash. A Taproot signature commits to the amounts and scriptPubKeys of all inputs being spent. An offline signer such as a hardware wallet can therefore verify the fee it is signing without being fed every previous transaction, closing a class of fee-inflation attacks against cold storage.
What does it change for fees and privacy?
Smaller spends. A single-key Taproot input is about 57.5 vbytes, against about 68 for native SegWit (P2WPKH), because the signature is shorter and there is no separate public key in the witness. The output is slightly larger (43 bytes versus 31), so the saving shows up when you spend. The bigger gains are for multisig: a 2-of-3 that settles through an aggregate key costs the same as a single signature, instead of carrying several signatures, keys and a script. If you are trying to get a transaction confirmed rather than make it smaller, see how RBF and CPFP work.
Uniform outputs. Key-path spends from a personal wallet, a corporate multisig, a Lightning channel close and a team custody setup can all look identical on-chain. That breaks some chain-analysis heuristics, though not all: amounts, change patterns and address reuse are unchanged.
New protocols. Aggregate and threshold signatures underpin designs such as threshold-controlled bridge wallets (the sBTC signer set on Stacks uses threshold Schnorr signatures) and Taproot-based Lightning channels, which Lightning implementations have been rolling out.
What Taproot did not do: it did not add new covenant opcodes, hide amounts, or change block size. It made existing capabilities cheaper and more private, and left room for later upgrades.
Using Taproot as a developer
In Bitcoin Core, descriptor wallets support Taproot natively:
bitcoin-cli -regtest createwallet "taproot-test"
bitcoin-cli -regtest -rpcwallet=taproot-test getnewaddress "" bech32m
# bcrt1p...
# a key-path key plus a script tree with two alternative keys
bitcoin-cli -regtest getdescriptorinfo "tr(KEY_INTERNAL,{pk(KEY_A),pk(KEY_B)})"
In JavaScript, bitcoinjs-lib builds P2TR outputs once you initialise it with a secp256k1 library:
import * as bitcoin from "bitcoinjs-lib";
import * as ecc from "tiny-secp256k1";
import { BIP32Factory } from "bip32";
import * as bip39 from "bip39";
bitcoin.initEccLib(ecc);
const bip32 = BIP32Factory(ecc);
const network = bitcoin.networks.testnet;
const seed = await bip39.mnemonicToSeed(process.env.MNEMONIC!);
const node = bip32.fromSeed(seed, network).derivePath("m/86'/1'/0'/0/0");
const internalPubkey = node.publicKey.subarray(1, 33); // drop the prefix byte: x-only key
const { address } = bitcoin.payments.p2tr({ internalPubkey, network });
console.log(address); // tb1p...
Pitfalls to watch:
- bech32 vs bech32m. SegWit v1+ addresses use the bech32m checksum (BIP-350). Old libraries that validate with bech32 reject valid
bc1paddresses or, worse, generate invalid ones. Test address validation against BIP-350 vectors. - x-only keys and parity. Keys are 32 bytes and the even-y convention applies. Mixing 33-byte compressed keys into Taproot code is a common bug.
- The tweak. To spend via the key path you sign with the tweaked private key. Libraries do this when given the internal key and tree; hand-rolled signing often forgets it, producing signatures that fail.
- Nonce reuse is fatal. Reusing a Schnorr nonce, or mishandling MuSig2 nonce rounds, leaks the private key. Use maintained libraries (libsecp256k1 and its MuSig module), never your own nonce generation.
- Keep the tree. To use a script path you need the leaf script and the rest of the tree. Back up the full descriptor, not only the seed.
Summary
| Piece | What it does |
|---|---|
| BIP-340 Schnorr | 64-byte signatures, 32-byte x-only keys, batch verification, key and signature aggregation |
| BIP-341 Taproot | SegWit v1 P2TR outputs: one tweaked key, spendable by key path or by revealing one Merkle leaf |
| BIP-342 Tapscript | OP_CHECKSIGADD instead of OP_CHECKMULTISIG, no script size limit, OP_SUCCESSx upgrade hooks |
| BIP-350 bech32m | Checksum for bc1p... addresses |
| BIP-86 | Standard derivation for single-key Taproot wallets |
The specifications are in the BIPs repository, starting with BIP-340 and BIP-341.
Get the weekly commit
New blockchain deep dives every week.