|
| 1 | +# 17.1: Breaking Down Taproot |
| 2 | + |
| 3 | +Taproot was a Bitcoin upgrade that activated on November 14, 2021 and |
| 4 | +supports the new "Taproot" SegWit v1 address. However, it's much more |
| 5 | +than that due to its incorporation of multiple Bitcoin Improvement |
| 6 | +Proposals, which together create a complex network of new rules and |
| 7 | +new capabilities. |
| 8 | + |
| 9 | +## Learn about the Taproot Soft Fork |
| 10 | + |
| 11 | +The Taproot activation simultaneously deployed three Bitcoin |
| 12 | +Improvement Proposals: [BIP 340: Schnorr |
| 13 | +Signatures](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki), |
| 14 | +[BIP 341: |
| 15 | +Taproot](https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki), |
| 16 | +and [BIP 342: |
| 17 | +Tapscript](https://github.com/bitcoin/bips/blob/master/bip-0342.mediawiki). These |
| 18 | +BIPs also incorporated ideas from older BIPs that have since been |
| 19 | +closed, most notably [BIP 114: |
| 20 | +MAST](https://github.com/bitcoin/bips/blob/master/bip-0114.mediawiki) |
| 21 | +and its successors. Here's a bit more about what that all means. |
| 22 | + |
| 23 | +### Understand Schnorr Signatures (BIP 340) |
| 24 | + |
| 25 | +The first building block of Taproot is the Schnorr Signature. |
| 26 | + |
| 27 | +Signatures are, of course, what unlock Bitcoin transactions. P2PKH and |
| 28 | +PW2PKH UTXOs are locked with a public key, which is hashed to form the |
| 29 | +receiving address of a transaction. A signature from the linked |
| 30 | +private key then unlocks the transaction and allows it to be |
| 31 | +spent. That signature was traditionally an ECDSA signature. |
| 32 | + |
| 33 | +> 📖 ***What is ECDSA?** ECDSA is a version of the DSA signature |
| 34 | +algorithm that uses elliptic curves. DSA is a NIST standard that is |
| 35 | +secured with the discrete logarithm problem. |
| 36 | + |
| 37 | +Taproot addresses are instead locked and unlocked with Schnorr |
| 38 | +signatures. These signatures have long been seen as an improvement |
| 39 | +over ECDSA and other traditional signature schemes particularly |
| 40 | +because of their aggregatable signatures and their adapter signatures. |
| 41 | +However, they were still under patent in the United States when |
| 42 | +Bitcoin was released, and even afterward it took a while for their use |
| 43 | +to be fully regularized. The Taproot update finally brought them into |
| 44 | +Bitcoin. |
| 45 | + |
| 46 | +More on Schnorr Signatures can be found in [§18.1: Understanding |
| 47 | +Schnorr](18_1_Understanding_Schorr.md).] |
| 48 | + |
| 49 | +### Understanding Taproot (BIP 341) |
| 50 | + |
| 51 | +The Taproot BIP proper defines the Segwit v1 (P2TR) address. It uses |
| 52 | +the aggregatability of Schnorr signatures to allow addresses to be |
| 53 | +unlocked in one of two ways: via a key path (private key signature) or |
| 54 | +via a script path (scripted spending conditions). |
| 55 | + |
| 56 | +Script paths are embedded in a Merkle Tree, or a MAST, a concept that |
| 57 | +was previously described in [BIP |
| 58 | +114](https://github.com/bitcoin/bips/blob/master/bip-0114.mediawiki). A |
| 59 | +MAST contains different scripts within a binary hash tree: each leaf |
| 60 | +commits to a script with a hash. A Taproot address then commits to the |
| 61 | +root of the hash tree as a "tweak" that is added to the Taproot |
| 62 | +address thanks to the aggregatability of Schnorr. |
| 63 | + |
| 64 | +> 📖 ***What is a Commitment?** When you hash data, you create a |
| 65 | +representation of the data that doesn't reveal the data itself, but |
| 66 | +can later be used to prove what the data is (and that you know |
| 67 | +it). This is how P2SH and P2WSH work: the "Script Hash" is a |
| 68 | +commitment to the script that can unlock the UTXO. With Taproot, an |
| 69 | +address commits to a Merkle Tree of scripts using the Merkle Root |
| 70 | +hash--which is applied as a tweak to the public key to form the |
| 71 | +address. |
| 72 | + |
| 73 | +When a Taproot UTXO is spent, the address can be unlocked with just |
| 74 | +the private key, which checks the key path, or with multiple elements, |
| 75 | +one of which is the script and another of which is a "control block" |
| 76 | +(which combines the untweaked public key, a map to the script in the |
| 77 | +MAST [if there is a Merkle tree], and a few other bits of |
| 78 | +information), which allows spending through the script path. |
| 79 | + |
| 80 | +The bottom line? Taproot allows an address to be spent using a typical |
| 81 | +private key or one of a number of scripts. |
| 82 | + |
| 83 | +Any P2TR address (`bc1p` on mainnet or `tb1q` on testnet) is a Taproot |
| 84 | +address that is locked and unlocked with Schnorr signatures. More on Taproot addresses |
| 85 | +can be found in [§18.2: Understanding Taproot |
| 86 | +Addresses](18_2_Creating_Taproot_Addresses.md). |
| 87 | + |
| 88 | +More on MAST can be found in [§19.1: Understanding |
| 89 | +MAST](19_1_Understanding_MAST.md). |
| 90 | + |
| 91 | +### Understanding Tapscript (BIP 342) |
| 92 | + |
| 93 | +The final element of the Taproot upgrade, BIP 342, defines the script |
| 94 | +opcodes that can be used in the MAST. They are largely Bitcoin Script, |
| 95 | +but with a few changes to which opcodes are available and and how |
| 96 | +script execution and signature verification work. |
| 97 | + |
| 98 | +More on Tapscript can be found in [§19.2: Designing |
| 99 | +Tapscripts](19_2_Designing_Tapscripts.md). |
| 100 | + |
| 101 | +## Summary: Breaking Down Taproot |
| 102 | + |
| 103 | +The Taproot update comes in three parts: |
| 104 | + |
| 105 | +* Schnorr signatures offer a new way to sign Bitcoin transactions. |
| 106 | +* Taproot uses the power of Schnorr to merge key spends and script spends into a single address. |
| 107 | +* Tapscript slightly varies Bitcoin Script for use with Taproot. |
| 108 | + |
| 109 | +Each of these parts will receive additional discussion in later sections. |
| 110 | + |
| 111 | +> 🔥 ***What is the power of Taproot?*** Taproot allows keys and a |
| 112 | +huge multitude of scripts to be used interchangeably and privately |
| 113 | +with a single Bitcoin address. |
| 114 | + |
| 115 | +## What's Next? |
| 116 | + |
| 117 | +Continue "Introducing Taproot" with [§17.2: Updating to |
| 118 | +Taproot](17_2_Updating_to_Taproot.md). |
0 commit comments