You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Merge bitcoin#27255: MiniTapscript: port Miniscript to Tapscript
ec0fc14 miniscript: remove P2WSH-specific part of GetStackSize doc comment (Antoine Poinsot)
128bc10 qa: bound testing for TapMiniscript (Antoine Poinsot)
117927b miniscript: have a custom Node destructor (Antoine Poinsot)
b917c71 qa: Tapscript Miniscript signing functional tests (Antoine Poinsot)
5dc341d qa: list descriptors in Miniscript signing functional tests (Antoine Poinsot)
4f473ea script/sign: Miniscript support in Tapscript (Antoine Poinsot)
febe2ab MOVEONLY: script/sign: move Satisfier declaration above Tapscript signing (Antoine Poinsot)
bd4b11e qa: functional test Miniscript inside Taproot descriptors (Antoine Poinsot)
8571b89 descriptor: parse Miniscript expressions within Taproot descriptors (Antoine Poinsot)
8ff9489 descriptor: Tapscript-specific Miniscript key serialization / parsing (Antoine Poinsot)
5e76f3f fuzz: miniscript: higher sensitivity for max stack size limit under Tapscript (Antoine Poinsot)
6f529cb qa: test Miniscript max stack size tracking (Antoine Poinsot)
770ba5b miniscript: check maximum stack size during execution (Antoine Poinsot)
574523d fuzz: adapt Miniscript targets to Tapscript (Antoine Poinsot)
8462372 qa: Tapscript-Miniscript unit tests (Antoine Poinsot)
fcb6f13 pubkey: introduce a GetEvenCorrespondingCPubKey helper (Antoine Poinsot)
ce8845f miniscript: account for keys as being 32 bytes under Taproot context (Antoine Poinsot)
f4f978d miniscript: adapt resources checks depending on context (Antoine Poinsot)
9cb4c68 serialize: make GetSizeOfCompactSize constexpr (Antoine Poinsot)
892436c miniscript: sanity asserts context in ComputeType (Antoine Poinsot)
e5aaa3d miniscript: make 'd:' have the 'u' property under Tapscript context (Antoine Poinsot)
687a0b0 miniscript: introduce a multi_a fragment (Antoine Poinsot)
9164c2e miniscript: restrict multi() usage to P2WSH context (Antoine Poinsot)
91b4db8 miniscript: store the script context within the Node structure (Antoine Poinsot)
c3738d0 miniscript: introduce a MsContext() helper to contexts (Antoine Poinsot)
bba9340 miniscript: don't anticipate signature presence in CalcStackSize() (Antoine Poinsot)
a3793f2 miniscript: add a missing dup key check bypass in Parse() (Antoine Poinsot)
Pull request description:
Miniscript was targeting P2WSH, and as such can currently only be used in `wsh()` descriptors. This pull request introduces support for Tapscript in Miniscript and makes Miniscript available inside `tr()` descriptors. It adds support for both watching *and* signing TapMiniscript descriptors.
The main changes to Miniscript for Tapscript are the following:
- A new `multi_a` fragment is introduced with the same semantics as `multi`. Like in other descriptors `multi` and `multi_a` can exclusively be used in respectively P2WSH and Tapscript.
- The `d:` fragment has the `u` property under Tapscript, since the `MINIMALIF` rule is now consensus. See also bitcoin#24906.
- Keys are now serialized as 32 bytes. (Note this affects the key hashes.)
- The resource consumption checks and calculation changed. Some limits were lifted in Tapscript, and signatures are now 64 bytes long.
The largest amount of complexity probably lies in the last item. Scripts under Taproot can now run into the maximum stack size while executing a fragment. For instance if you've got a stack size of `999` due to the initial witness plus some execution that happened before and try to execute a `hash256` it would `DUP` (increasing the stack size `1000`), `HASH160` and then push the hash on the stack making the script fail.
To make sure this does not happen on any of the spending paths of a sane Miniscript, we introduce a tracking of the maximum stack size during execution of a fragment. See the commits messages for details. Those commits were separated from the resource consumption change, and the fuzz target was tweaked to sometimes pad the witness so the script runs on the brink of the stack size limit to make sure the stack size was not underestimated.
Existing Miniscript unit, functional and fuzz tests are extended with Tapscript logic and test cases. Care was taken for seed stability in the fuzz targets where we cared more about them.
The design of Miniscript for Tapscript is the result of discussions between various people over the past year(s). To the extent of my knowledge at least Pieter Wuille, Sanket Kanjalkar, Andrew Poelstra and Andrew Chow contributed thoughts and ideas.
ACKs for top commit:
sipa:
ACK ec0fc14
achow101:
ACK ec0fc14
Tree-SHA512: f3cf98a3ec8e565650ccf51b7ee7e4b4c2b3949a1168bee16ec03d2942b4d9f20dedc2820457f67a3216161022263573d08419c8346d807a693169ad3a436e07
Copy file name to clipboardExpand all lines: src/script/miniscript.cpp
+26-8Lines changed: 26 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,7 @@
6
6
#include<vector>
7
7
#include<script/script.h>
8
8
#include<script/miniscript.h>
9
+
#include<serialize.h>
9
10
10
11
#include<assert.h>
11
12
@@ -32,7 +33,8 @@ Type SanitizeType(Type e) {
32
33
return e;
33
34
}
34
35
35
-
Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Type>& sub_types, uint32_t k, size_t data_size, size_t n_subs, size_t n_keys) {
36
+
Type ComputeType(Fragment fragment, Type x, Type y, Type z, const std::vector<Type>& sub_types, uint32_t k,
0 commit comments