Skip to content

Commit 9d1aca9

Browse files
committed
bip-0379.mediawiki:formatting
1 parent 3b99594 commit 9d1aca9

File tree

1 file changed

+25
-23
lines changed

1 file changed

+25
-23
lines changed

bip-0379.md renamed to bip-0379.mediawiki

+25-23
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@
1515
License: CC0-1.0
1616
</pre>
1717

18-
## Abstract
18+
==Abstract==
1919

2020
This document specifies Miniscript, a language for writing (a subset of) Bitcoin Scripts in a
2121
structured way, enabling analysis, composition, generic signing and more.
2222

23-
## Copyright
23+
==Copyright==
2424

2525
This document is licensed under the Creative Commons CC0 1.0 Universal license.
2626

27-
## Motivation
27+
==Motivation==
2828

2929
Bitcoin Script is an unusual stack-based language with many edge cases, designed for implementing
3030
spending conditions consisting of various combinations of signatures, hash locks, and time locks.
@@ -44,13 +44,13 @@ targeted by spending policy compilers. Finally, compatible scripts can easily be
4444
Miniscript form - avoiding the need for additional metadata for e.g. signing devices that support
4545
it.
4646

47-
## Specification
47+
==Specification==
4848

4949
These specifications apply to P2WSH ([BIP 141](bip-0141.mediawiki)) and Tapscript ([BIP 342](bip-0342.mediawiki)) scripts, with only minor
5050
variations between the two. Differences are noted inline. Unless explicitly stated otherwise,
5151
specifications apply to both. P2SH and bare scripts are excluded from this specification.
5252

53-
### Translation Table
53+
===Translation Table===
5454

5555
Miniscript consists of a set of script *fragments* which are designed to be safely and correctly composabe.
5656

@@ -109,15 +109,15 @@ Miniscript is not a separate language, but rather a significant expansion of the
109109
| | `l:X` = `or_i(0,X)` | `IF 0 ELSE [X] ENDIF`
110110
| | `u:X` = `or_i(X,0)` | `IF [X] ELSE 0 ENDIF`
111111

112-
### Type System
112+
===Type System===
113113

114114
Not every Miniscript expression can be composed with every other. Some return their result by
115115
putting true or false on the stack; others can only abort or continue. Some require subexpressions
116116
that consume an exactly known number of arguments, while others need a subexpression that has a
117117
nonzero top stack element to satisfy. To model all these properties, we define a correctness type
118118
system for Miniscript.
119119

120-
#### Correctness
120+
====Correctness====
121121

122122
Every miniscript expression has one of four basic types: "**B**" (base), "**V**" (verify),
123123
"**K**" (key) and "**W**" (wrapped). Then there are 5 type modifiers that guarantee additional
@@ -156,7 +156,7 @@ its type properties in function of those of their subexpressions.
156156
| `j:X` | X is Bn | B | o=o<sub>X</sub>; n; d; u=u<sub>X</sub>
157157
| `n:X` | X is B | B | z=z<sub>X</sub>; o=o<sub>X</sub>; n=n<sub>X</sub>; d=d<sub>X</sub>; u
158158

159-
#### Timelock Type Mixing
159+
====Timelock Type Mixing====
160160

161161
There is one additional correctness property that Miniscript expressions must satisfy:
162162
the four timelock types (absolute time based, absolute height based, relative time based, and
@@ -169,7 +169,7 @@ timelocks to appear.
169169
For all other combinators, it is legal to mix timelock types. It is also always legal to
170170
mix absolute and relative timelocks (even if one is height based and the other is time based).
171171

172-
#### Malleability
172+
====Malleability====
173173

174174
Malleability is the ability for a third party (someone who does *not* hold a participating private
175175
key) to modify an existing satisfaction into another valid satisfaction. To analyze the
@@ -208,7 +208,7 @@ The following table lists the malleability properties and requirement of each fr
208208
| `j:X` | | s=s<sub>X</sub>; e=f<sub>X
209209
| `n:X` | | s=s<sub>X</sub>; f=f<sub>X</sub>; e=e<sub>X</sub>
210210

211-
### Satisfaction
211+
====Satisfaction====
212212

213213
The following table shows all valid satisfactions and dissatisfactions for every Miniscript, using
214214
satisfactions and dissatisfactions of its subexpressions. Multiple possibilities are separated by
@@ -249,7 +249,7 @@ will contain *(empty)*.
249249
| `j:X` | 0; ~~[dsat(X) (if nonzero top stack)]~~ | sat(X)
250250
| `n:X` | dsat(X) | sat(X)
251251

252-
#### Non-malleable Satisfaction Algorithm
252+
====Non-malleable Satisfaction Algorithm====
253253

254254
In order to produce non-malleable satisfactions we make use of a function that returns the optimal
255255
satisfaction and dissatisfaction for a given expression (if any exist), or a special DONTUSE ("don't use") value,
@@ -272,9 +272,9 @@ script but the result does not have the HASSIG flag, also fail. If the satisfact
272272
DONTUSE and HASSIG, return it.
273273

274274

275-
## Discussion
275+
==Discussion==
276276

277-
## Security
277+
==Security==
278278

279279
Miniscript primarily aims to provide guarantees on the correctness of a Bitcoin Script. That is, to
280280
guarantee **consensus soundness** and **standardness completeness**. Consensus soundness means
@@ -297,7 +297,7 @@ that scripts whose conditions can be met without any digital signature are insec
297297
trivially insecure, note how a transaction lacking a signature check allows an attacker to change
298298
its nLockTime and nSequence fields to meet additional timelock conditions.
299299

300-
### Type System
300+
===Type System===
301301

302302
To statically verify the correctness and malleability guarantees discussed in the previous section,
303303
we define a type system. See the specifications above for a reference of each fragment's
@@ -323,7 +323,7 @@ Finally to analyze malleability guarantees we introduce 3 new type modifiers:
323323
* "**e**" Expressive: this requires a unique unconditional dissatisfaction to exist, and forces all conditional dissatisfactions (if any) to require a signature.
324324

325325

326-
### Malleability
326+
===Malleability===
327327

328328
Since Segwit, malleating a transaction no longer breaks the validity of unconfirmed descendant
329329
transactions. However, unintentional malleability may still have a number of much weaker undesirable
@@ -354,7 +354,7 @@ The malleability analysis makes the following assumptions:
354354
* We restrict this analysis to scripts where no public key is repeated. If signatures constructed for one part of the script can be bound to other checks in the same script, a variant of the mixing from the previous point becomes available that is equally hard to reason about. Furthermore this situation can be avoided by using separate keys.
355355
* The attacker is constrained by common standardness rules. A miner may be able to malleate a witness considered non-malleable by Miniscript.
356356

357-
#### Non-Malleable Satisfaction
357+
====Non-Malleable Satisfaction====
358358

359359
Malleable satisfactions or dissatisfactions appear whenever options are available to attackers distinct from the one taken by honest users. This can happen for multiple reasons:
360360
1. Two or more options for a satisfaction or dissatisfaction are listed in the table above which are both available to attackers directly. Regardless of which option is used in the honest solution, the attacker can change the solution to the other one.
@@ -380,7 +380,7 @@ satisfaction:
380380
* `thresh(k,...)` is always "d", a non-HASSIG dissatisfaction with just dissatisfactions must exist due to typing rules, and thus rules out usage of the other dissatisfactions. They are also overcomplete.
381381

382382

383-
### Resource Limits
383+
====Resource Limits====
384384

385385
Various types of Bitcoin Scripts have different resource limitations, either through consensus or standardness. Some of them affect otherwise valid Miniscripts:
386386
* In P2WSH, scripts larger than 3600 bytes are invalid by standardness. In Tapscript, scripts are implicitly bounded by the maximum size of a block (1 million virtual bytes).
@@ -392,11 +392,11 @@ A static analysis can be performed on a Miniscript to verify if none, all or any
392392
paths hit any of the limits.
393393

394394

395-
## Test Vectors
395+
==Test Vectors==
396396

397397
TBD
398398

399-
## Backwards Compatibility
399+
==Backwards Compatibility==
400400

401401
Miniscript's syntax is compatible with BIP 380 Output Script Descriptors, and should be considered
402402
an extension to it that provides a new type of Script expression that is only valid in
@@ -408,16 +408,18 @@ The `pk()`, `pkh()`, `multi()`, and `multi_a()`
408408
fragments overlap with existing descriptors. These parse to the same semantic meanings as those
409409
descriptors and produce the same scripts.
410410

411-
## Reference Implementation
411+
==Reference Implementation==
412412

413413
A first reference implementation and documentation for Miniscript in P2WSH was originally published at
414414
https://github.com/sipa/miniscript .
415415

416+
[[bip-0381.mediawiki[381]]
417+
416418
The reference implementation for Miniscript in P2WSH was introduced in Bitcoin Core through PRs
417-
[24147](https://github.com/bitcoin/bitcoin/pull/24147), [24148](https://github.com/bitcoin/bitcoin/pull/24148), and
418-
[24149](https://github.com/bitcoin/bitcoin/pull/24149). The last one to be merged was released in Bitcoin
419+
[[24147][https://github.com/bitcoin/bitcoin/pull/24147]], [[24148][https://github.com/bitcoin/bitcoin/pull/24148]], and
420+
[[24149][https://github.com/bitcoin/bitcoin/pull/24149]]. The last one to be merged was released in Bitcoin
419421
Core version 25.0.
420422

421423
The reference implementation for Miniscript in Tapscript was introduced in Bitcoin Core in PR
422-
[27255](https://github.com/bitcoin/bitcoin/pull/27255). This PR was merged and released in Bitcoin Core
424+
[[27255][https://github.com/bitcoin/bitcoin/pull/27255]]. This PR was merged and released in Bitcoin Core
423425
version 26.0.

0 commit comments

Comments
 (0)