BIP-341 (Taproot Spending Rules)

The Taproot output and spending rules, combining a key path with a Merkle tree of script alternatives.

Basically

BIP-341 sets the rules for Taproot outputs. You can spend with a key or reveal one saved spending rule, while the unused rules stay hidden.

Key Takeaways

  • BIP-341 defines Pay-to-Taproot (P2TR) outputs, a new SegWit version 1 output type. You can spend them with a single Schnorr signature through the key path or reveal a script from the committed Merkle tree through the script path.
  • Key-path spends look like simple payments. An observer cannot tell whether complex spending conditions existed, so multisig, timelocks and other constructions look identical to single-signature transactions on-chain.
  • Script-path spends reveal only the executed branch. Only that leaf and its Merkle proof are disclosed, while all other possible spending paths stay hidden.

What Is BIP-341?

BIP-341 is the Bitcoin Improvement Proposal that defines Taproot spending rules. Pieter Wuille, Jonas Nick and Anthony Towns authored it, specifying how Pay-to-Taproot (P2TR) outputs are constructed and spent on the Bitcoin network. BIP-341 activated at block 709,632 on 14 November 2021 and introduced SegWit version 1, the most significant upgrade to Bitcoin since Segregated Witness in 2017.

The core insight behind BIP-341 is that most transactions settle cooperatively. Complex contracts involving multiple signers, timelocks or conditional logic typically end with all parties agreeing on the outcome. Taproot optimises for this common case: cooperative settlements produce a single signature that looks identical to any ordinary payment, while the full script machinery is only revealed when cooperation breaks down.

BIP-341 works alongside two companion proposals. BIP-340 defines the Schnorr signature scheme and x-only public keys, while BIP-342 defines the Tapscript rules for executing scripts inside Taproot outputs. Together, these three BIPs form the complete Taproot upgrade.

How It Works

Every P2TR output locks funds to a 32-byte output key Q. The key comes from an internal public key P, which represents the key-path owner, and an optional Merkle tree of scripts for alternative spending conditions. You can unlock the output through either path.

Output Key Construction

The output key Q is computed by tweaking the internal key P with a commitment to the script tree. The tweak connects the key and any scripts to the same output.

A key-path-only output has no script tree, so the tweak simplifies to t = hashTapTweak(P) with no Merkle root appended. The resulting output key Q is encoded in a 34-byte scriptPubKey: OP_1 OP_PUSHBYTES_32 <Q>. Its on-chain address uses bech32m and starts with bc1p.

The hashTapTweak function uses the tagged hash scheme defined in BIP-340: SHA256(SHA256("TapTweak") // SHA256("TapTweak") // data). Tagged hashes provide domain separation. Hashes for different purposes, including tweaks, leaf nodes, branches and signature messages, can never collide.

Key-Path Spending

Key-path spending is the simplest and most private way to spend a P2TR output. The owner of the internal key produces a single Schnorr signature for the tweaked output key Q. The witness contains exactly one element: a 64-byte signature using the implicit SIGHASH_DEFAULT, or a 65-byte signature with an explicit sighash type byte appended.

A key-path spend is indistinguishable on-chain from a simple single-signature payment. It reveals nothing about whether a script tree existed, how many alternative spending paths were available or how many parties were involved. Key aggregation protocols like MuSig2 allow even a 5-of-7 multisig to produce a single aggregated key and signature, appearing identical to a solo spender.

Script-Path Spending

A spender who cannot use cooperative key-path spending can reveal and execute one script from the committed Merkle tree. The witness stack for a script-path spend contains three parts, ordered from bottom to top.

The control block is 33 + 32m bytes, where m is the number of Merkle path hashes. The value of m ranges from 0 to a maximum depth of 128.

The verifier reconstructs the Merkle root from the leaf script and path hashes, then computes the expected output key using the internal key and tweak. It checks that the expected key matches the actual output key and, if valid, executes the leaf script under the rules defined by its leaf version. Leaf version 0xc0 uses BIP-342 Tapscript rules.

The Merkle Script Tree

BIP-341 organises spending conditions into a binary Merkle tree. Each leaf contains a script and a leaf version byte, and the tree is built by hashing pairs of nodes using lexicographic ordering.

The design allows the most likely script paths to sit near the root, reducing the Merkle proof size for common spending scenarios. Rarely used fallback conditions can sit deeper in the tree with minimal cost to the common case.

Privacy Benefits

BIP-341 significantly improves privacy compared with previous output types. Its design minimises how much information about spending conditions appears on-chain.

The research article on Taproot and Schnorr signatures provides a deeper technical analysis of these privacy properties. It examines the cryptographic detail behind them.

Efficient Multisig

A 3-of-5 multisig before Taproot required all five public keys and three signatures on-chain, consuming significant block space and identifying the transaction as multisig. BIP-341 and MuSig2 key aggregation can collapse the same 3-of-5 setup into a single aggregated key, producing one 64-byte signature in the cooperative case that is indistinguishable from any other payment. The script path serves as a fallback if some signers become unresponsive.

Lightning Network Channels

Lightning channels benefit from Taproot in multiple ways. Cooperative channel closes use the key path for a single-signature close that looks like an ordinary transfer, while complex HTLC scripts and timelock conditions stay in the script tree and are only revealed during force closes. These changes improve both the privacy and the on-chain efficiency of the Lightning Network.

Advanced Contracts

BIP-341 enables more complex smart contract constructions on Bitcoin. Miniscript policies, covenants, threshold signatures and time-locked inheritance schemes can all be encoded in the Merkle tree while maintaining a clean key path for the common case. Protocols like Discreet Log Contracts and Ark use Taproot to keep contract complexity off-chain.

Layer 2 Protocols

Layer 2 solutions like Spark use Taproot outputs for their on-chain commitments. Complex exit conditions can sit in a script tree while cooperative operations remain simple key-path spends, making Taproot well suited to scaling protocols that need both efficiency and trustless fallback guarantees.

The Annex Field

BIP-341 reserves an optional witness element called the annex, identified by a first byte of 0x50. The annex is committed in the signature hash when present, preventing malleability, but is otherwise ignored during validation. Future soft fork extensions may use it to attach additional data to transactions.

The specification recommends that you do not include an annex until a future upgrade defines its semantics. Including one earlier could result in fund loss if consensus rules change.

Adoption and Wallet Support

Taproot activated in November 2021, but adoption has been gradual. Wallets and services must update to support P2TR address generation, signing and spending, while sending to bc1p addresses requires bech32m encoding support that not all platforms implemented immediately. You should verify that your wallet and any receiving services support Taproot before migrating funds to P2TR outputs.

Script-Path Privacy Leakage

Script-path spends reveal information even though key-path spends offer strong privacy. The executed script and the depth of the Merkle tree are visible on-chain. The tree depth can leak information about the wallet software or the number of spending conditions, partially reducing the privacy benefits.

NUMS Point Complexity

A P2TR output that should only be spendable through the script path needs an internal key set to a Nothing Up My Sleeve (NUMS) point with no known private key, so no key path is available. Constructing and verifying NUMS points correctly requires care. The wrong internal key could make the output unspendable or allow unauthorised key-path spending.

Backwards Compatibility

BIP-341 was deployed as a soft fork, so older nodes still validate blocks containing Taproot transactions. Older nodes treat SegWit version 1 outputs as "anyone-can-spend" and rely on miners to enforce the new rules. The same standard Bitcoin soft fork security model was used by previous upgrades like SegWit.

BIP-341 and Related Proposals

BIP-341 sits at the centre of the Taproot upgrade trio. Its role becomes clear through its connection to BIP-340 and BIP-342.

These proposals together deliver smaller transactions, stronger privacy and more expressive scripting for Bitcoin. The research article on Bitcoin address types from P2PKH to Taproot provides a comprehensive overview.

The glossary entry is for informational purposes only and does not constitute financial or investment advice. Always do your own research before using any protocol or technology.

0

← All 1876 glossary terms