-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminiscript.html
More file actions
129 lines (113 loc) · 6.38 KB
/
miniscript.html
File metadata and controls
129 lines (113 loc) · 6.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags -->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Miniscript</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="style.css">
<style>
.monospace {
font-family: Consolas,Monaco,Lucida Console,Liberation Mono,DejaVu Sans Mono,Bitstream Vera Sans Mono,Courier New, monospace;
}
a.demo_link {
text-decoration-style: dashed;
text-underline-position: under;
}
</style>
</head>
<body>
<script src="miniscript.js"></script>
<script>
function htmlEscape(str) {
return String(str)
.replace(/&/g, '&')
.replace(/"/g, '"')
.replace(/'/g, ''')
.replace(/</g, '<')
.replace(/>/g, '>');
}
em_miniscript_compile = Module.cwrap('miniscript_compile', 'none', ['string', 'number', 'number', 'number', 'number', 'number', 'number']);
em_miniscript_analyze = Module.cwrap('miniscript_analyze', 'none', ['string', 'number', 'number', 'number', 'number']);
function miniscript_compile() {
document.getElementById("out").innerHTML = "Compiling...";
window.setTimeout(function() {
src = document.getElementById("source").value;
var msout = Module._malloc(10000);
var costout = Module._malloc(500);
var asmout = Module._malloc(100000);
em_miniscript_compile(src, msout, 10000, costout, 500, asmout, 100000);
document.getElementById("analyze_ms").value = Module.UTF8ToString(msout);
document.getElementById("analyze_out").innerHTML = "";
document.getElementById("out").innerHTML =
"<p><p><b>Miniscript output:</b><p><code>" + htmlEscape(Module.UTF8ToString(msout)) + "</code>" +
"<p><b>Spending cost analysis</b><p>" + Module.UTF8ToString(costout) + "" +
"<p><b>Resulting script structure</b><p><samp><pre>" + htmlEscape(Module.UTF8ToString(asmout)) + "</pre></samp>";
Module._free(msout)
Module._free(costout)
Module._free(asmout)
});
}
function load_policy(pol) {
document.getElementById("source").value = pol;
miniscript_compile();
}
function miniscript_analyze() {
document.getElementById("analyze_out").innerHTML = "Analyzing...";
window.setTimeout(function() {
src = document.getElementById("analyze_ms").value;
var analyze_out = Module._malloc(50000);
var asmout = Module._malloc(100000);
em_miniscript_analyze(src, analyze_out, 50000, asmout, 100000);
document.getElementById("analyze_out").innerHTML =
"<p><p><b>Analysis</b><p>" + Module.UTF8ToString(analyze_out) + "<p><small>Hover over the tree elements for more details</small>" +
"<p><b>Resulting script structure</b><p><samp><pre>" + htmlEscape(Module.UTF8ToString(asmout)) + "</pre></samp>";
Module._free(analyze_out)
Module._free(asmout)
});
}
</script>
<div class="container" style="margin-top:50px">
<div class="card mb-3 text-left">
<h3 class="card-header">
<a href="miniscript.html">Miniscript</a>
<a href="index.html">Compiler</a>
<a href="reference.html">Reference</a>
</h3>
</div>
</div>
<div class="card-block">
<p>
<em>Miniscript</em> is a language for writing (a subset of) Bitcoin Scripts in a structured way, enabling analysis, composition, generic signing and more.
<p>
Bitcoin Script is an unusual stack-based language with many edge cases, designed for implementing spending conditions consisting of various combinations of
signatures, hash locks, and time locks. Yet despite being limited in functionality it is still highly nontrivial to:<ul>
<li>Given a combination of spending conditions, finding the most economical script to implement it.</li>
<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>
<li>Given a script, find out what spending conditions it permits.</li>
<li>Given a script and access to a sufficient set of private keys, construct a general satisfying witness for it.</li>
<li>Given a script, be able to predict the cost of spending an output.</li>
<li>Given a script, know whether particular resource limitations like the ops limit might be hit when spending.</li>
</ul>
<p>
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
statically analyze for various properties (spending conditions, correctness, security properties, malleability, ...). It can be targeted by spending policy compilers
(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.
<p>
Miniscript is designed for (P2SH-)P2WSH and Tapscript (as defined in BIP342) embedded scripts. Most of its constructions
work fine in P2SH as well, but some of the (optional) security properties rely on Segwit-specific rules. Furthermore,
the implemented policy compilers assume a Segwit-specific cost model.
<p>
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.
<p>
Links:<ul>
<li>This <a href="http://bitcoin.sipa.be/miniscript">website</a> and C++ compiler: <a href="https://github.com/sipa/miniscript">[code]</a></li>
<li>Bitcoin Core compatible C++ implementation: <a href="https://github.com/sipa/miniscript/tree/master/bitcoin/script">[code]</a></li>
<li>Rust-miniscript implementation: <a href="https://github.com/apoelstra/rust-miniscript">[code]</a></li>
<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>
</ul>
</div>
</body>
</html>