Skip to content

Commit c0e248c

Browse files
committed
reference.html
1 parent 699f813 commit c0e248c

File tree

1 file changed

+0
-99
lines changed

1 file changed

+0
-99
lines changed

reference.html

Lines changed: 0 additions & 99 deletions
Original file line numberDiff line numberDiff line change
@@ -88,105 +88,6 @@ <h3 class="card-header">
8888

8989
</div>
9090

91-
<div class="card-block">
92-
<p>
93-
<em>Miniscript</em> is a language for writing (a subset of) Bitcoin Scripts in a structured way, enabling analysis, composition, generic signing and more.
94-
95-
<p>
96-
Bitcoin Script is an unusual stack-based language with many edge cases, designed for implementing spending conditions consisting of various combinations of
97-
signatures, hash locks, and time locks. Yet despite being limited in functionality it is still highly nontrivial to:<ul>
98-
<li>Given a combination of spending conditions, finding the most economical script to implement it.</li>
99-
<li>Given two scripts, construct a script that implements a composition of their spending conditions (e.g. a multisig where one of the "keys" is another multisig).</li>
100-
<li>Given a script, find out what spending conditions it permits.</li>
101-
<li>Given a script and access to a sufficient set of private keys, construct a general satisfying witness for it.</li>
102-
<li>Given a script, be able to predict the cost of spending an output.</li>
103-
<li>Given a script, know whether particular resource limitations like the ops limit might be hit when spending.</li>
104-
</ul>
105-
106-
<p>
107-
Miniscript functions as a representation for scripts that makes these sort of operations possible. It has a structure that allows composition. It is very easy to
108-
statically analyze for various properties (spending conditions, correctness, security properties, malleability, ...). It can be targeted by spending policy compilers
109-
(see below). Finally, compatible scripts can easily be converted to Miniscript form - avoiding the need for additional metadata for e.g. signing devices that support it.
110-
111-
<p>
112-
Miniscript is designed for (P2SH-)P2WSH and Tapscript (as defined in BIP342) embedded scripts. Most of its constructions
113-
work fine in P2SH as well, but some of the (optional) security properties rely on Segwit-specific rules. Furthermore,
114-
the implemented policy compilers assume a Segwit-specific cost model.
115-
116-
<p>
117-
Miniscript was designed and implemented by Pieter Wuille, Andrew Poelstra, and Sanket Kanjalkar at Blockstream Research, but is the result of discussions with several other people.
118-
119-
<p>
120-
Links:<ul>
121-
<li>This <a href="http://bitcoin.sipa.be/miniscript">website</a> and C++ compiler: <a href="https://github.com/sipa/miniscript">[code]</a></li>
122-
<li>Bitcoin Core compatible C++ implementation: <a href="https://github.com/sipa/miniscript/tree/master/bitcoin/script">[code]</a></li>
123-
<li>Rust-miniscript implementation: <a href="https://github.com/apoelstra/rust-miniscript">[code]</a></li>
124-
<li>Talk about (an early version of) Miniscript at <a href="https://cyber.stanford.edu/sbc19">SBC'19</a>: <a href="https://www.youtube.com/watch?v=XM1lzN4Zfks">[video]</a> <a href="http://diyhpl.us/wiki/transcripts/stanford-blockchain-conference/2019/miniscript/">[transcript]</a> <a href="https://prezi.com/view/KH7AXjnse7glXNoqCxPH/">[slides]</a></li>
125-
</ul>
126-
127-
</div>
128-
</div>
129-
130-
<div class="card mb-3 text-left">
131-
<h3 class="card-header">Policy to Miniscript compiler</h3>
132-
<div class="card-block">
133-
134-
<p>Here you can see a demonstration of the P2WSH Miniscript compiler. Write a spending policy according to the instructions below, and observe how it affects the constructed Miniscript.
135-
<form>
136-
<div class="form-group">
137-
<label for="source">Policy</label>
138-
<textarea class="form-control" id="source" rows="1">and(pk(A),or(pk(B),or(9@pk(C),older(1000))))</textarea>
139-
<div class="small form-text test-muted">Supported policies:
140-
<ul>
141-
<li><samp>pk(<em>NAME</em>)</samp>: Require public key named <em>NAME</em> to sign. <em>NAME</em> can be any string up to 16 characters.</li>
142-
<li><samp>after(<em>NUM</em>)</samp>, <samp>older(<em>NUM</em>)</samp>: Require that the <samp>nLockTime</samp>/<samp>nSequence</samp> value is at least <em>NUM</em>. <em>NUM</em> cannot be 0.</li>
143-
<li><samp>sha256(<em>HEX</em>)</samp>, <samp>hash256(<em>HEX</em>)</samp>: Require that the preimage of 64-character <em>HEX</em> is revealed. The special value <samp>H</samp> can be used as <em>HEX</em>.</li>
144-
<li><samp>ripemd160(<em>HEX</em>)</samp>, <samp>hash160(<em>HEX</em>)</samp>: Require that the preimage of 40-character <em>HEX</em> is revealed. The special value <samp>H</samp> can be used as <em>HEX</em>.</li>
145-
<li><samp>and(<em>POL</em>,<em>POL</em>)</samp>: Require that both subpolicies are satisfied.</li>
146-
<li><samp>or([<em>N</em>@]<em>POL</em>,[<em>N</em>@]<em>POL</em>)</samp>: Require that one of the subpolicies is satisfied. The numbers N indicate the relative probability of each of the subexpressions (so <samp>9@</samp> is 9 times more likely than the default).</li>
147-
<li><samp>thresh(<em>NUM</em>,<em>POL</em>,<em>POL</em>,...)</samp>: Require that NUM out of the following subpolicies are met (all combinations are assumed to be equally likely).</li>
148-
</ul></div>
149-
Fill field with:
150-
<ul>
151-
<li><a class="demo_link" href='javascript:load_policy("pk(key_1)")'>A single key</a>
152-
<li><a class="demo_link" href='javascript:load_policy("or(pk(key_1),pk(key_2))")'>One of two keys (equally likely)</a>
153-
<li><a class="demo_link" href='javascript:load_policy("or(99@pk(key_likely),pk(key_unlikely))")'>One of two keys (one likely, one unlikely)</a>
154-
<li><a class="demo_link" href='javascript:load_policy("and(pk(key_user),or(99@pk(key_service),older(12960)))")'>A user and a 2FA service need to sign off, but after 90 days the user alone is enough</a>
155-
<li><a class="demo_link" href='javascript:load_policy("thresh(3,pk(key_1),pk(key_2),pk(key_3),older(12960))")'>A 3-of-3 that turns into a 2-of-3 after 90 days</a>
156-
<li><a class="demo_link" href='javascript:load_policy("or(pk(key_revocation),and(pk(key_local),older(1008)))")'>The BOLT #3 to_local policy</a>
157-
<li><a class="demo_link" href='javascript:load_policy("or(pk(key_revocation),and(pk(key_remote),or(pk(key_local),hash160(H))))")'>The BOLT #3 offered HTLC policy</a>
158-
<li><a class="demo_link" href='javascript:load_policy("or(pk(key_revocation),and(pk(key_remote),or(and(pk(key_local),hash160(H)),older(1008))))")'>The BOLT #3 received HTLC policy</a>
159-
</ul>
160-
</div>
161-
<button type="button" class="btn btn-primary" onclick="miniscript_compile();">Compile</button>
162-
</form>
163-
164-
<div id="out"></div>
165-
166-
</div>
167-
</div>
168-
169-
<div class="card text-left mb-3">
170-
<h3 class="card-header">Analyze a Miniscript</h3>
171-
<div class="card-block">
172-
173-
<p>Here you can analyze the structure of a Miniscript expression and more.
174-
<form>
175-
<div class="form-group">
176-
<label for="analyze_ms">Miniscript</label>
177-
<textarea class="form-control" id="analyze_ms" rows="1">and_v(v:pk(K),pk(A))</textarea>
178-
<small class="form-text test-muted">Provide a well-typed miniscript expression of type "B".</small>
179-
</div>
180-
<button type="button" class="btn btn-primary" onclick="miniscript_analyze();">Analyze</button>
181-
</form>
182-
183-
<div id="analyze_out"></div>
184-
185-
</div>
186-
</div>
187-
188-
<div class="card mb-3 text-left">
189-
<h3 class="card-header">Miniscript reference</h3>
19091

19192
<div class="card-block">
19293
<h4>P2WSH or Tapscript?</h4>

0 commit comments

Comments
 (0)