Skip to content

Commit c583f4d

Browse files
committed
Specify BIP 371 Taproot Fields for PSBT
Add bip-0371.mediawiki, update readme, and update BIP 174 with new field types.
1 parent ad745f2 commit c583f4d

File tree

3 files changed

+296
-0
lines changed

3 files changed

+296
-0
lines changed

README.mediawiki

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1036,6 +1036,13 @@ Those proposing changes should consider that ultimately consent may rest with th
10361036
| Andrew Chow
10371037
| Standard
10381038
| Draft
1039+
|-
1040+
| [[bip-0371.mediawiki|371]]
1041+
| Applications
1042+
| Taproot Fields for PSBT
1043+
| Andrew Chow
1044+
| Standard
1045+
| Draft
10391046
|}
10401047

10411048
<!-- IMPORTANT! See the instructions at the top of this page, do NOT JUST add BIPs here! -->

bip-0174.mediawiki

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,6 +428,72 @@ The currently defined per-input types are defined as follows:
428428
| 2
429429
| [[bip-psb2.mediawiki|psbt2]]
430430
|-
431+
| Taproot Key Spend Signature
432+
| <tt>PSBT_IN_TAP_KEY_SIG = 0x13</tt>
433+
| None
434+
| No key data
435+
| <tt><signature></tt>
436+
| The 64 or 65 byte Schnorr signature for key path spending a Taproot output. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
437+
|
438+
|
439+
| 0, 2
440+
| [[bip-0371.mediawiki|371]]
441+
|-
442+
| Taproot Script Spend Signature
443+
| <tt>PSBT_IN_TAP_SCRIPT_SIG = 0x14</tt>
444+
| <tt><xonlypubkey> <leafhash></tt>
445+
| A 32 byte X-only public key involved in a leaf script concatenated with the 32 byte hash of the leaf it is part of.
446+
| <tt><signature></tt>
447+
| The 64 or 65 byte Schnorr signature for this pubkey and leaf combination. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
448+
|
449+
|
450+
| 0, 2
451+
| [[bip-0371.mediawiki|371]]
452+
|-
453+
| Taproot Leaf Script
454+
| <tt>PSBT_IN_TAP_LEAF_SCRIPT = 0x15</tt>
455+
| <tt><control block></tt>
456+
| The control block for this leaf as specified in BIP 341. The control block contains the merkle tree path to this leaf.
457+
| <tt><script> <8-bit uint></tt>
458+
| The script for this leaf as would be provided in the witness stack followed by the single byte leaf version. Note that the leaves included in this field should be those that the signers of this input are expected to be able to sign for. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
459+
|
460+
|
461+
| 0, 2
462+
| [[bip-0371.mediawiki|371]]
463+
|-
464+
| Taproot Key BIP 32 Derivation Path
465+
| <tt>PSBT_IN_TAP_BIP32_DERIVATION = 0x16</tt>
466+
| <tt><xonlypubkey></tt>
467+
| A 32 byte X-only public key involved in this input. It may be the internal key, or a key present in a leaf script.
468+
| <tt><hashes len> <leaf hash>* <4 byte fingerprint> <32-bit uint>*</tt>
469+
| A compact size unsigned integer representing the number of leaf hashes, followed by a list of leaf hashes, followed by the 4 byte master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. The leaf hashes are of the leaves which involve this public key. The internal key does not have leaf hashes, so can be indicated with a <tt>hashes len</tt> of 0. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
470+
|
471+
|
472+
| 0, 2
473+
| [[bip-0371.mediawiki|371]]
474+
|-
475+
| Taproot Internal Key
476+
| <tt>PSBT_IN_TAP_INTERNAL_KEY = 0x17</tt>
477+
| None
478+
| No key data
479+
| <tt><pubkey></tt>
480+
| The X-only pubkey used as the internal key in this output. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
481+
|
482+
|
483+
| 0, 2
484+
| [[bip-0371.mediawiki|371]]
485+
|-
486+
| Taproot Merkle Root
487+
| <tt>PSBT_IN_TAP_MERKLE_ROOT = 0x18</tt>
488+
| None
489+
| No key data
490+
| <tt><pubkey></tt>
491+
| The 32 byte Merkle root hash. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
492+
|
493+
|
494+
| 0, 2
495+
| [[bip-0371.mediawiki|371]]
496+
|-
431497
| Proprietary Use Type
432498
| <tt>PSBT_IN_PROPRIETARY = 0xFC</tt>
433499
| <tt><identifierlen> <identifier> <subtype> <subkeydata></tt>
@@ -511,6 +577,50 @@ determine which outputs are change outputs and verify that the change is returni
511577
| 2
512578
| [[bip-psb2.mediawiki|psbt2]]
513579
|-
580+
| Taproot Internal Key
581+
| <tt>PSBT_OUT_TAP_INTERNAL_KEY = 0x05</tt>
582+
| None
583+
| No key data
584+
| <tt><pubkey></tt>
585+
| The X-only pubkey used as the internal key in this output.
586+
|
587+
|
588+
| 0, 2
589+
| [[bip-0371.mediawiki|371]]
590+
|-
591+
| Taproot Tree
592+
| <tt>PSBT_OUT_TAP_TREE = 0x06</tt>
593+
| None
594+
| No key data
595+
| <tt>{<8-bit uint depth> <8-bit uint leaf version> <scriptlen> <script>}*</tt>
596+
| One or more tuples representing the depth, leaf version, and script for a leaf in the Taproot tree, allowing the entire tree to be reconstructed. The tuples must be in depth first search order so that the tree is correctly reconstructed. Each tuple is an 8-bit unsigned integer representing the depth in the Taproot tree for this script, an 8-bit unsigned integer representing the leaf version, the length of the script as a compact size unsigned integer, and the script itself.
597+
|
598+
|
599+
| 0, 2
600+
| [[bip-0371.mediawiki|371]]
601+
|-
602+
| Taproot Leaf Script
603+
| <tt>PSBT_OUT_TAP_LEAF_SCRIPT = 0x06</tt>
604+
| <tt><control block></tt>
605+
| The control block for this leaf as specified in BIP 341. The control block contains the merkle tree path to this leaf.
606+
| <tt><script></tt>
607+
| The script for this leaf as would be provided in the witness stack.
608+
|
609+
|
610+
| 0, 2
611+
| [[bip-0371.mediawiki|371]]
612+
|-
613+
| Taproot Key BIP 32 Derivation Path
614+
| <tt>PSBT_OUT_TAP_BIP32_DERIVATION = 0x07</tt>
615+
| <tt><xonlypubkey></tt>
616+
| A 32 byte X-only public key involved in this output. It may be the internal key, or a key present in a leaf script.
617+
| <tt><hashes len> <leaf hash>* <4 byte fingerprint> <32-bit uint>*</tt>
618+
| A compact size unsigned integer representing the number of leaf hashes, followed by a list of leaf hashes, followed by the 4 byte master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. The leaf hashes are of the leaves which involve this public key. The internal key does not have leaf hashes, so can be indicated with a <tt>hashes len</tt> of 0. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
619+
|
620+
|
621+
| 0, 2
622+
| [[bip-0371.mediawiki|371]]
623+
|-
514624
| Proprietary Use Type
515625
| <tt>PSBT_OUT_PROPRIETARY = 0xFC</tt>
516626
| <tt><identifierlen> <identifier> <subtype> <subkeydata></tt>

bip-0371.mediawiki

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
<pre>
2+
BIP: 371
3+
Layer: Applications
4+
Title: Taproot Fields for PSBT
5+
Author: Andrew Chow <[email protected]>
6+
Comments-Summary: No comments yet.
7+
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0371
8+
Status: Draft
9+
Type: Standards Track
10+
Created: 2021-06-21
11+
License: BSD-2-Clause
12+
</pre>
13+
14+
==Introduction==
15+
16+
===Abstract===
17+
18+
This document proposes additional fields for BIP 174 PSBTv0 and BIP 370 PSBTv2 that allow for
19+
BIP 340/341/342 Taproot data to be included in a PSBT of any version. These will be fields for
20+
signatures and scripts that are relevant to the creation of Taproot inputs.
21+
22+
===Copyright===
23+
24+
This BIP is licensed under the 2-clause BSD license.
25+
26+
===Motivation===
27+
28+
BIPs 340, 341, and 342 specify Taproot which provides a wholly new way to create and spend Bitcoin outputs.
29+
The existing PSBT fields are unable to support Taproot due to the new signature algorithm and the method
30+
by which scripts are embedded inside of a Taproot output. Therefore new fields must be defined to allow
31+
PSBTs to carry the information necessary for signing Taproot inputs.
32+
33+
==Specification==
34+
35+
The new per-input types are defined as follows:
36+
37+
{|
38+
! Name
39+
! <tt><keytype></tt>
40+
! <tt><keydata></tt>
41+
! <tt><keydata></tt> Description
42+
! <tt><valuedata></tt>
43+
! <tt><valuedata></tt> Description
44+
! Versions Requiring Inclusion
45+
! Versions Requiring Exclusion
46+
! Versions Allowing Inclusion
47+
|-
48+
| Taproot Key Spend Signature
49+
| <tt>PSBT_IN_TAP_KEY_SIG = 0x13</tt>
50+
| None
51+
| No key data <ref>'''Why is there no key data for <tt>PSBT_IN_TAP_KEY_SIG</tt>'''The signature in a key path spend corresponds directly with the pubkey provided in the output script. Thus it is not necessary to provide any metadata that attaches the key path spend signature to a particular pubkey.</ref>
52+
| <tt><signature></tt>
53+
| The 64 or 65 byte Schnorr signature for key path spending a Taproot output. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
54+
|
55+
|
56+
| 0, 2
57+
|-
58+
| Taproot Script Spend Signature
59+
| <tt>PSBT_IN_TAP_SCRIPT_SIG = 0x14</tt>
60+
| <tt><xonlypubkey> <leafhash></tt>
61+
| A 32 byte X-only public key involved in a leaf script concatenated with the 32 byte hash of the leaf it is part of.
62+
| <tt><signature></tt>
63+
| The 64 or 65 byte Schnorr signature for this pubkey and leaf combination. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
64+
|
65+
|
66+
| 0, 2
67+
|-
68+
| Taproot Leaf Script
69+
| <tt>PSBT_IN_TAP_LEAF_SCRIPT = 0x15</tt>
70+
| <tt><control block></tt>
71+
| The control block for this leaf as specified in BIP 341. The control block contains the merkle tree path to this leaf.
72+
| <tt><script> <8-bit uint></tt>
73+
| The script for this leaf as would be provided in the witness stack followed by the single byte leaf version. Note that the leaves included in this field should be those that the signers of this input are expected to be able to sign for. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
74+
|
75+
|
76+
| 0, 2
77+
|-
78+
| Taproot Key BIP 32 Derivation Path
79+
| <tt>PSBT_IN_TAP_BIP32_DERIVATION = 0x16</tt>
80+
| <tt><xonlypubkey></tt>
81+
| A 32 byte X-only public key involved in this input. It may be the internal key, or a key present in a leaf script.
82+
| <tt><hashes len> <leaf hash>* <4 byte fingerprint> <32-bit uint>*</tt>
83+
| A compact size unsigned integer representing the number of leaf hashes, followed by a list of leaf hashes, followed by the 4 byte master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. The leaf hashes are of the leaves which involve this public key. The internal key does not have leaf hashes, so can be indicated with a <tt>hashes len</tt> of 0. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
84+
|
85+
|
86+
| 0, 2
87+
|-
88+
| Taproot Internal Key
89+
| <tt>PSBT_IN_TAP_INTERNAL_KEY = 0x17</tt>
90+
| None
91+
| No key data
92+
| <tt><pubkey></tt>
93+
| The X-only pubkey used as the internal key in this output.<ref>'''Why is the internal key provided?'''The internal key is not necessarily the same key as in the Taproot output script. BIP 341 recommends tweaking the key with the hash of itself. It may be necessary for signers to know what the internal key actually is so that they are able to determine whether an input can be signed by it.</ref> Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
94+
|
95+
|
96+
| 0, 2
97+
|-
98+
| Taproot Merkle Root
99+
| <tt>PSBT_IN_TAP_MERKLE_ROOT = 0x18</tt>
100+
| None
101+
| No key data
102+
| <tt><pubkey></tt>
103+
| The 32 byte Merkle root hash. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
104+
|
105+
|
106+
| 0, 2
107+
|}
108+
109+
The new per-output types are defined as follows:
110+
111+
{|
112+
! Name
113+
! <tt><keytype></tt>
114+
! <tt><keydata></tt>
115+
! <tt><keydata></tt> Description
116+
! <tt><valuedata></tt>
117+
! <tt><valuedata></tt> Description
118+
! Versions Requiring Inclusion
119+
! Versions Requiring Exclusion
120+
! Versions Allowing Inclusion
121+
|-
122+
| Taproot Internal Key
123+
| <tt>PSBT_OUT_TAP_INTERNAL_KEY = 0x05</tt>
124+
| None
125+
| No key data
126+
| <tt><pubkey></tt>
127+
| The X-only pubkey used as the internal key in this output.
128+
|
129+
|
130+
| 0, 2
131+
|-
132+
| Taproot Tree
133+
| <tt>PSBT_OUT_TAP_TREE = 0x06</tt>
134+
| None
135+
| No key data
136+
| <tt>{<8-bit uint depth> <8-bit uint leaf version> <scriptlen> <script>}*</tt>
137+
| One or more tuples representing the depth, leaf version, and script for a leaf in the Taproot tree, allowing the entire tree to be reconstructed. The tuples must be in depth first search order so that the tree is correctly reconstructed. Each tuple is an 8-bit unsigned integer representing the depth in the Taproot tree for this script, an 8-bit unsigned integer representing the leaf version, the length of the script as a compact size unsigned integer, and the script itself.
138+
|
139+
|
140+
| 0, 2
141+
|-
142+
| Taproot Key BIP 32 Derivation Path
143+
| <tt>PSBT_OUT_TAP_BIP32_DERIVATION = 0x07</tt>
144+
| <tt><xonlypubkey></tt>
145+
| A 32 byte X-only public key involved in this output. It may be the internal key, or a key present in a leaf script.
146+
| <tt><hashes len> <leaf hash>* <4 byte fingerprint> <32-bit uint>*</tt>
147+
| A compact size unsigned integer representing the number of leaf hashes, followed by a list of leaf hashes, followed by the 4 byte master key fingerprint concatenated with the derivation path of the public key. The derivation path is represented as 32-bit little endian unsigned integer indexes concatenated with each other. Public keys are those needed to spend this output. The leaf hashes are of the leaves which involve this public key. The internal key does not have leaf hashes, so can be indicated with a <tt>hashes len</tt> of 0. Finalizers should remove this field after <tt>PSBT_IN_FINAL_SCRIPTWITNESS</tt> is constructed.
148+
|
149+
|
150+
| 0, 2
151+
|}
152+
153+
===UTXO Types===
154+
155+
BIP 174 recommends using <tt>PSBT_IN_NON_WITNESS_UTXO</tt> for all inputs because of potential attacks involving
156+
an updater lying about the amounts in an output. Because a Taproot signature will commit to all of the amounts
157+
and output scripts spent by the inputs of the transaction, such attacks are prevented as any such lying would
158+
result in an invalid signature. Thus Taproot inputs can use just <tt>PSBT_IN_WITNESS_UTXO</tt>.
159+
160+
==Compatibility==
161+
162+
These are simply new fields added to the existing PSBT format. Because PSBT is designed to be extensible, old
163+
software will ignore the new fields.
164+
165+
==Test Vectors==
166+
167+
TBD
168+
169+
==Rationale==
170+
171+
<references/>
172+
173+
==Reference implementation==
174+
175+
The reference implementation of the PSBT format is available at TBD.
176+
177+
==Acknowledgements==
178+
179+
TBD

0 commit comments

Comments
 (0)