mirror of
https://github.com/bitcoin/bips.git
synced 2025-03-18 05:42:12 +01:00
Specify BIP 386: Taproot descriptors
This commit is contained in:
parent
5403ff90d6
commit
761ef12782
@ -1092,6 +1092,13 @@ Those proposing changes should consider that ultimately consent may rest with th
|
||||
| Pieter Wuille, Andrew Chow
|
||||
| Informational
|
||||
| Draft
|
||||
|-
|
||||
| [[bip-0386.mediawiki|386]]
|
||||
| Applications
|
||||
| tr() Output Script Descriptors
|
||||
| Pieter Wuille, Andrew Chow
|
||||
| Informational
|
||||
| Draft
|
||||
|}
|
||||
|
||||
<!-- IMPORTANT! See the instructions at the top of this page, do NOT JUST add BIPs here! -->
|
||||
|
@ -227,6 +227,10 @@ All available expression types are listed in this table.
|
||||
| Key
|
||||
| <tt>KEY</tt>
|
||||
| 380
|
||||
|-
|
||||
| Tree
|
||||
| <tt>TREE</tt>
|
||||
| [[bip-0386.mediawiki|386]]
|
||||
|}
|
||||
|
||||
==Appendix B: Index of Script Expressions==
|
||||
@ -267,4 +271,7 @@ This Table lists all available Script expressions and the BIPs specifying them.
|
||||
|-
|
||||
| <tt>addr(ADDR)</tt>
|
||||
| [[bip-0385.mediawiki|385]]
|
||||
|-
|
||||
| <tt>tr(KEY)</tt>, <tt>tr(KEY, TREE)</tt>
|
||||
| [[bip-0386.mediawiki|386]]
|
||||
|}
|
||||
|
101
bip-0386.mediawiki
Normal file
101
bip-0386.mediawiki
Normal file
@ -0,0 +1,101 @@
|
||||
<pre>
|
||||
BIP: 386
|
||||
Layer: Applications
|
||||
Title: tr() Output Script Descriptors
|
||||
Author: Pieter Wuille <pieter@wuille.net>
|
||||
Andrew Chow <andrew@achow101.com>
|
||||
Comments-Summary: No comments yet.
|
||||
Comments-URI: https://github.com/bitcoin/bips/wiki/Comments:BIP-0386
|
||||
Status: Draft
|
||||
Type: Informational
|
||||
Created: 2021-06-27
|
||||
License: BSD-2-Clause
|
||||
</pre>
|
||||
|
||||
==Abstract==
|
||||
|
||||
This document specifies <tt>tr()</tt> output script descriptors.
|
||||
<tt>tr()</tt> descriptors take a key and optionally a tree of scripts and produces a P2TR output script.
|
||||
|
||||
==Copyright==
|
||||
|
||||
This BIP is licensed under the BSD 2-clause license.
|
||||
|
||||
==Motivation==
|
||||
|
||||
Taproot added one additional standard output script format: P2TR.
|
||||
These expressions allow specifying those formats as a descriptor.
|
||||
|
||||
==Specification==
|
||||
|
||||
A new script expression is defined: <tt>tr()</tt>.
|
||||
A new expression is defined: Tree Expressions
|
||||
|
||||
===Tree Expression===
|
||||
|
||||
A Tree Expression (denoted <tt>TREE</tt>) is an expression which represents a tree of scripts.
|
||||
The way the tree is represented in an output script is dependent on the higher level expressions.
|
||||
|
||||
A Tree Expression is:
|
||||
* Any Script Expression that is allowed at the level this Tree Expression is in.
|
||||
* A pair of Tree Expressions consisting of:
|
||||
** An open brace <tt>{</tt>
|
||||
** A Tree Expression
|
||||
** A comma <tt>,</tt>
|
||||
** A Tree Expression
|
||||
** A closing brace <tt>}</tt>
|
||||
|
||||
===<tt>tr()</tt>===
|
||||
|
||||
The <tt>tr(KEY)</tt> or <tt>tr(KEY, TREE)</tt> expression can only be used as a top level expression.
|
||||
All key expressions under any <tt>tr()</tt> expression must create x-only public keys.
|
||||
|
||||
<tt>tr(KEY)</tt> takes a single key expression as an argument and produces a P2TR output script which does not have a script path.
|
||||
Each key produced by the key expression is used as the internal key of a P2TR output as specified by [[bip-0341.mediawiki#cite_ref-22-0|BIP 341]].
|
||||
Specifically, "If the spending conditions do not require a script path, the output key should commit to an unspendable script path instead of having no script path.
|
||||
This can be achieved by computing the output key point as ''Q = P + int(hash<sub>TapTweak</sub>(bytes(P)))G''."
|
||||
|
||||
<pre>
|
||||
internal_key: lift_x(KEY)
|
||||
32_byte_output_key: internal_key + int(HashTapTweak(bytes(internal_key)))G
|
||||
scriptPubKey: OP_1 <32_byte_output_key>
|
||||
</pre>
|
||||
|
||||
<tt>tr(KEY, TREE)</tt> takes a key expression as the first argument, and a tree expression as the second argument and produces a P2TR output script which has a script path.
|
||||
The keys produced by the first key expression are used as the internal key as specified by [[bip-0341.mediawiki#Constructing_and_spending_Taproot_outputs|BIP 341]].
|
||||
The Tree expression becomes the Taproot script tree as described in BIP 341.
|
||||
A merkle root is computed from this tree and combined with the internal key to create the Taproot output key.
|
||||
|
||||
<pre>
|
||||
internal_key: lift_x(KEY)
|
||||
merkle_root: HashTapBranch(TREE)
|
||||
32_byte_output_key: internal_key + int(HashTapTweak(bytes(internal_key) || merkle_root))G
|
||||
scriptPubKey: OP_1 <32_byte_output_key>
|
||||
</pre>
|
||||
|
||||
===Modified Key Expression===
|
||||
|
||||
Key Expressions within a <tt>tr()</tt> expression must only create x-only public keys.
|
||||
Uncompressed public keys are not allowed, but compressed public keys would be implicitly converted to x-only public keys.
|
||||
The keys derived from extended keys must be serialized as x-only public keys.
|
||||
An additional key expression is defined only for use within a <tt>tr()</tt> descriptor:
|
||||
|
||||
* A 64 hex character string representing an x-only public key
|
||||
|
||||
==Test Vectors==
|
||||
|
||||
TBD
|
||||
|
||||
==Backwards Compatibility==
|
||||
|
||||
<tt>tr()</tt> descriptors use the format and general operation specified in [[bip-0380.mediawiki|380]].
|
||||
As these are a set of wholly new descriptors, they are not compatible with any implementation.
|
||||
However the scripts produced are standard scripts so existing software are likely to be familiar with them.
|
||||
|
||||
Tree Expressions are largely incompatible with existing script expressions due to the restrictions in those expressions.
|
||||
As of 2021-06-27, the only allowed script expression that can be used in a tree expression is <tt>pk()</tt>.
|
||||
However there will be future BIPs that specify script expressions that can be used in tree expressions.
|
||||
|
||||
==Reference Implementation==
|
||||
|
||||
<tt>tr()</tt> descriptors have been implemented in Bitcoin Core since version 22.0.
|
Loading…
x
Reference in New Issue
Block a user