Skip to content

Commit 28f17cb

Browse files
committed
chapter 17 added
1 parent cbcff7e commit 28f17cb

14 files changed

Lines changed: 483 additions & 2 deletions

docs/16_4_Using_BDK.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,4 +333,5 @@ import Miniscript containing private keys.
333333
334334
## What's Next?
335335
336-
The next section will be all new, on Taproot!
336+
Move on to "Using Taproot" with [Chapter Seventeen: Introducing
337+
Tapscript](17_0_Introducing_Taproot.md).

docs/17_0_Introducing_Taproot.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Chapter 17: Introducing Taproot
2+
3+
On June 12, 2021, the Bitcoin network reached consensus to activate
4+
the Taproot upgrade, which was then deployed on November 14 with block
5+
709,632. It was the biggest change to Bitcoin since the Segwit upgrade
6+
of 2017, but also a continuation of SegWit development. (The original
7+
SegWit was 'segwit v0' while Taproot is 'segwit v1').
8+
9+
The most fundamental expansion of Taproot is the ability to use a
10+
single address to combine rules for key paths (e.g., unlocking an
11+
address with a private key) and script paths (e.g., unlocking an
12+
address per the rules of a Bitcoin Script, or more properly, with
13+
Tapscript). Essentially, P2TR integrates both P2WPKH and P2WSH.
14+
15+
But the Taproot upgrade actually combines three different BIPs and
16+
most of its functionality isn't available in Bitcoin Core, which can
17+
leave it somewhat difficult to grasp. The following chapters attempt
18+
to make it more graspable.
19+
20+
## Objectives for This Chapter
21+
22+
After working through this chapter, a developer will be able to:
23+
24+
* Update Their Bitcoin Core Environment to Taproot
25+
26+
Supporting objectives include the ability to:
27+
28+
* Understand the Taproot Update
29+
* Understand the Components of the Taproot Update
30+
31+
## Table of Contents
32+
33+
* [Section One: Breaking Down Taproot](17_1_Breaking_Down_Taproot.md)
34+
* [Section Two: Updating to Taproot](17_2_Updating_To_Taproot.md)

docs/17_0_Introducing_Taproot.md~

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Chapter 17: Introducing Taproot
2+
3+
On June 12, 2021, the Bitcoin network reached consensus to activate
4+
the Taproot upgrade, which was then deployed on November 14 on block
5+
709,632. It was the biggest change to Bitcoin since the Segwit upgrade
6+
of 2017, but also a continuation of SegWit development. (The original
7+
SegWit was 'segwit v0' while Taproot is 'segwit v1').
8+
9+
The most fundamental feature of Taproot is the ability to combine
10+
rules for key paths (e.g., unlocking an address with a private key)
11+
and script paths (e.g., unlocking an address per the rules of a
12+
Bitcoin Script, or more properly, with Tapscript) into a single
13+
address. Essentially, P2TR integrates both P2WPKH and P2WSH.
14+
15+
But the Taproot upgrade actually combines three different
16+
BIPs and it's not fully supported by Bitcoin Core, which can leave it
17+
somewhat difficult to grasp. The following chapters attempt to make it
18+
more graspable.
19+
20+
## Objectives for This Chapter
21+
22+
After working through this chapter, a developer will be able to:
23+
24+
* Update Their Bitcoin Core Environment to Taproot
25+
26+
Supporting objectives include the ability to:
27+
28+
* Understand the Taproot Update
29+
* Understand the Components of the Taproot Update
30+
31+
## Table of Contents
32+
33+
* [Section One: Breaking Down Taproot](17_1_Breaking_Down_Taproot.md)
34+
* [Section Two: Updating to Taproot](17_2_Updating_To_Taproot.md)

docs/17_1_Breaking_Down_Taproot.md

Lines changed: 118 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
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).
Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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). Those
18+
BIPs also incorporated ideas from older BIPs that have since bene
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+
Taproot defines the Segwit v1 (P2TR) address. It uses the
52+
aggregatability of Schnorr signatures to allow addresses to be
53+
unlocked in one of two ways: via a keypath (private key signature) or
54+
via a scriptpath (scripted spending conditions).
55+
56+
Scriptpaths 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 at different levels of a binary, which
60+
is a binary hash tree: each leaf commits to a script with a hash. A
61+
Taproot address then commits to the root of the hash tree as a "tweak"
62+
that is added to the Taproot address thanks to the aggregatability of
63+
Schnorr.
64+
65+
> 📖 ***What is Commitment?** When you hash data, you create a
66+
representation of the data that doesn't reveal the data itself, but
67+
can later be used to prove what the data is (and that you know
68+
it). This is how P2SH and P2WSH work: the "Script Hash" is a
69+
commitment to the script that can unlock the UTXO. With Taproot, the
70+
Merkle Tree of scripts is commited to using the Merkle Root hash,
71+
which is applied as a tweak to the public key to form the address.
72+
73+
When a Taproot UTXO is spent, the address can be unlocked with just
74+
the private key, which checks the keypath, or with multiple elements,
75+
one of which is the public key and one of which is the script, which
76+
allows spending through the scriptpath. In the latter case, the
77+
"public key" can actually be a map to a specific node of the Merklee
78+
Tree.
79+
80+
The bottom line? Taproot allows an address to be spend using a typical
81+
private key or one of any of a number of scripts. More on Taproot
82+
addresses can be found in [§18.2: Understanding Taproot
83+
Addresses](18_2_Creating_Taproot_Addresses.md) and more on MAST can be
84+
found in [§19.1: Understanding MAST](19_1_Understanding_MAST.md).
85+
86+
Any P2TR address (`bc1p` on mainnet or `tb1q` on testnet) is
87+
a Taproot address that is locked and unlocked with Schnorr signatures..
88+
89+
### Understanding Tapscript (BIP 342)
90+
91+
The final element of the Taproot upgrade, BIP 342, defines the script
92+
opcodes that can be used in the MAST. They are largely Bitcoin Script,
93+
but with a few changes to which opcodes are usable and and how script
94+
execution and signature verification work.
95+
96+
More on Tapscript can be found in [§19.2: Designing
97+
Tapscripts](19_2_Designing_Tapscripts.md).
98+
99+
## Summary: Breaking Down Taproot
100+
101+
The Taproot update comes in three parts:
102+
103+
* Schnorr signatures offer a new way to sign Bitcoin transactions.
104+
* Taproot uses the power of Schnorr to merge key spends and script spends into a single address.
105+
* Tapscript slightly varies Bitcoin Script for use with Taproot.
106+
107+
Each of these parts will receive additional discussion in later sections.
108+
109+
> 🔥 ***What is the power of Taproot?*** Taproot allows keys and a
110+
huge multitude of scripts to be used interchangeably and privately
111+
with a single Bitcoin address.
112+
113+
## What's Next?
114+
115+
Continue "Introducing Taproot" with [§17.2: Updating to
116+
Taproot](17_2_Updating_to_Taproot.md).
117+
118+
119+
120+

0 commit comments

Comments
 (0)