summaryrefslogtreecommitdiff
path: root/df/e1d500c83066aeac538e4a3ac5043047eb7f35
blob: 34411d2217119bfc2453328f14ccaf531fd417e2 (plain)
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
Return-Path: <nadav@shesek.info>
Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136])
 by lists.linuxfoundation.org (Postfix) with ESMTP id 0E132C004D
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Jul 2020 15:16:29 +0000 (UTC)
Received: from localhost (localhost [127.0.0.1])
 by silver.osuosl.org (Postfix) with ESMTP id EC68F2052C
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Jul 2020 15:16:28 +0000 (UTC)
X-Virus-Scanned: amavisd-new at osuosl.org
Received: from silver.osuosl.org ([127.0.0.1])
 by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024)
 with ESMTP id Pvc5T7Pb4T0E
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Jul 2020 15:16:26 +0000 (UTC)
X-Greylist: from auto-whitelisted by SQLgrey-1.7.6
Received: from mail-ed1-f54.google.com (mail-ed1-f54.google.com
 [209.85.208.54])
 by silver.osuosl.org (Postfix) with ESMTPS id 62F2120368
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Jul 2020 15:16:26 +0000 (UTC)
Received: by mail-ed1-f54.google.com with SMTP id n2so17680407edr.5
 for <bitcoin-dev@lists.linuxfoundation.org>;
 Wed, 29 Jul 2020 08:16:26 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=shesek.info; s=shesek;
 h=mime-version:from:date:message-id:subject:to;
 bh=pFK71+TLfCsnRuDim0fORb+4ZmjtLVZjy/xiFwt+DEw=;
 b=m5eTkiotol7IBFo3/n9J1xkyzLIbfuYLlu9FbOWgw55jr8S6JHwk/iF6P0VzU1SCU8
 B3fV5ziZWaRpVeCnKnCzXBcr/YNMWG4CCpQrCyWj4Xjxo2Gfc9xHbrKZlCEZ7ftXBMNE
 6pZy+jGlAkLY61ICXoZZlk0LkzJV4ylF/KklE=
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:mime-version:from:date:message-id:subject:to;
 bh=pFK71+TLfCsnRuDim0fORb+4ZmjtLVZjy/xiFwt+DEw=;
 b=eWaX0TITtZmWM7UqJ4M767tWnA31ne0f4MgXLPp8XT9HKM6ACTz3+W4gnFXXSlBY44
 IadMq/BQYXZAZIyPe1Z98368lreiDevHmzASfUTIZKPM1EB8KzDtX5QPlD5/XISUW30O
 RniiH1lqS85matQRude2dlZay9WxSdrTo529T7oQkcq3eT6o3siZkX+YQtlUbLytOZEA
 uSfIhYsQvqQfFpXWzi+Htabcbyf0JPOYRUeJr6f1ECht5++stSR2J5xNGqatUL7Z/OYr
 qiD9PTHwm8mi/vKMrE3qQCxFeVRia5DlKOzgwYDdX6j9Q/P6RzsRYpKiiogHDoYx7f48
 Ddcg==
X-Gm-Message-State: AOAM533IQFzyb54r+l9wvLJ1lPw+UUhl+0+rTMHNsQEtQW1rlFV+/1Pg
 EcoHyeLYWp5XHjdeII8w1r5hcHEgIqJExI02b9mUs2SjkHE=
X-Google-Smtp-Source: ABdhPJyolBjNJBB6J9WkkQPYovgbCU4vkAUFuRYnUAcWeGNSH9HJRgLsCtbiJacEvLfomTny8M7gUN0QuSAZv+HQuHo=
X-Received: by 2002:a05:6512:358c:: with SMTP id
 m12mr17220626lfr.18.1596035454709; 
 Wed, 29 Jul 2020 08:10:54 -0700 (PDT)
MIME-Version: 1.0
From: Nadav Ivgi <nadav@shesek.info>
Date: Wed, 29 Jul 2020 18:10:42 +0300
Message-ID: <CAGXD5f3SiXHOmjSVxUQWOLT5SocQ62qTNGJOmTUtW7kDeduFjA@mail.gmail.com>
To: Bitcoin Protocol Discussion <bitcoin-dev@lists.linuxfoundation.org>
Content-Type: multipart/alternative; boundary="00000000000053ca9f05ab95f628"
X-Mailman-Approved-At: Wed, 29 Jul 2020 15:17:39 +0000
Subject: [bitcoin-dev] Minsc, a Miniscript-based scripting language
X-BeenThere: bitcoin-dev@lists.linuxfoundation.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: Bitcoin Protocol Discussion <bitcoin-dev.lists.linuxfoundation.org>
List-Unsubscribe: <https://lists.linuxfoundation.org/mailman/options/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=unsubscribe>
List-Archive: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/>
List-Post: <mailto:bitcoin-dev@lists.linuxfoundation.org>
List-Help: <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=help>
List-Subscribe: <https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev>, 
 <mailto:bitcoin-dev-request@lists.linuxfoundation.org?subject=subscribe>
X-List-Received-Date: Wed, 29 Jul 2020 15:16:29 -0000

--00000000000053ca9f05ab95f628
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi all,

I recently released Minsc, a high-level scripting language for expressing
Bitcoin Script spending conditions using a simple and familiar syntax.

Minsc is based on the Miniscript Policy language, with additional features
and syntactic sugar sprinkled on top, including variables, functions, infix
notation, human-readable times and more.

A live compiler (Minsc->Policy->Miniscript->Script) and documentation are
available on the website: https://min.sc

Source code (in Rust) is available on github:
https://github.com/shesek/minsc

Some example Minsc scripts:

- A user and a 2FA service need to sign off, but after 90 days the user
alone is enough

      pk(user_pk) && (9@pk(service_pk) || older(90 days))

- Traditional preimage-based HTLC

      $redeem =3D pk(A) && sha256(H);
      $refund =3D pk(B) && older(10);

      likely@$redeem || $refund

- Liquid-like federated pegin with emergency recovery keys

      $federation =3D 4 of [ pk(A), pk(B), pk(C), pk(D), pk(E) ];
      $recovery =3D 2 of [ pk(F), pk(G), pk(H) ];
      $timeout =3D older(heightwise 2 weeks);

      likely@$federation || ($timeout && $recovery)

- The BOLT #3 received HTLC policy

      fn htlc_received($revoke_pk, $local_pk, $remote_pk, $secret, $delay) =
{
        $success =3D pk($local_pk) && hash160($secret);
        $timeout =3D older($delay);

        pk($revoke_pk) || (pk($remote_pk) && ($success || $timeout))
      }

      htlc_received(A, B, C, H, 3 hours)

- 2FA where the user has a 2-of-2 setup and the service provider is a
3-of-4 federation

      fn two_factor($user, $provider, $delay) =3D
        $user && (likely@$provider || older($delay));

      $user =3D pk(user_desktop) && pk(user_mobile);
      $providers =3D [ pk(P1), pk(P2), pk(P3), pk(P4) ];

      two_factor($user, 3 of $providers, 4 months)

- Easily add NSA backdoors to everything =F0=9F=95=B5=EF=B8=8F=F0=9F=9A=AA

      _backdoor=3Dpk(usgovt), _pk=3Dpk, _older=3Dolder, _after=3Dafter,
      _sha256=3Dsha256, _ripemd160=3Dripemd160;

      fn pk(x) =3D _pk(x) || _backdoor;
      fn older(x) =3D _older(x) || _backdoor;
      fn after(x) =3D _after(x) || _backdoor;
      fn sha256(x) =3D _sha256(x) || _backdoor;
      fn ripemd160(x) =3D _ripemd160(x) || _backdoor;

      (pk(A) && sha256(H)) || (pk(B) && older(10))

Feedback is appreciated!

Nadav

P.S Since every Miniscript Policy is also a valid Minsc expression, the
min.sc web code editor UI could also be useful for experimenting with bare
policies. You'll get syntax highlighting, parentheses matching, real-time
compilation (in a web worker so the browser doesn't freeze) and syntax
error reporting.

--00000000000053ca9f05ab95f628
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi all,<br></div><div><br></div><div>I recently relea=
sed Minsc, a high-level scripting language for expressing Bitcoin Script sp=
ending conditions using a simple and familiar syntax.</div><br>Minsc is bas=
ed on the Miniscript Policy language, with additional features and syntacti=
c sugar sprinkled on top, including variables, functions, infix notation, h=
uman-readable times and more.<br><br>A live compiler (Minsc-&gt;Policy-&gt;=
Miniscript-&gt;Script) and documentation are available on the website: <a h=
ref=3D"https://min.sc">https://min.sc</a><br><br>Source code (in Rust) is a=
vailable on github: <a href=3D"https://github.com/shesek/minsc">https://git=
hub.com/shesek/minsc</a><br><br>Some example Minsc scripts:<br><br>- A user=
 and a 2FA service need to sign off, but after 90 days the user alone is en=
ough<br><br>=C2=A0 =C2=A0 =C2=A0 pk(user_pk) &amp;&amp; (9@pk(service_pk) |=
| older(90 days))<br><br>- Traditional preimage-based HTLC<br><br>=C2=A0 =
=C2=A0 =C2=A0 $redeem =3D pk(A) &amp;&amp; sha256(H);<br>=C2=A0 =C2=A0 =C2=
=A0 $refund =3D pk(B) &amp;&amp; older(10);<br><br>=C2=A0 =C2=A0 =C2=A0 lik=
ely@$redeem || $refund<br><br>- Liquid-like federated pegin with emergency =
recovery keys<br><br>=C2=A0 =C2=A0 =C2=A0 $federation =3D 4 of [ pk(A), pk(=
B), pk(C), pk(D), pk(E) ];<br>=C2=A0 =C2=A0 =C2=A0 $recovery =3D 2 of [ pk(=
F), pk(G), pk(H) ];<br>=C2=A0 =C2=A0 =C2=A0 $timeout =3D older(heightwise 2=
 weeks);<br><br>=C2=A0 =C2=A0 =C2=A0 likely@$federation || ($timeout &amp;&=
amp; $recovery)<br><br>- The BOLT #3 received HTLC policy<br><br>=C2=A0 =C2=
=A0 =C2=A0 fn htlc_received($revoke_pk, $local_pk, $remote_pk, $secret, $de=
lay) {<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 $success =3D pk($local_pk) &amp;&amp;=
 hash160($secret);<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 $timeout =3D older($delay=
);<br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 pk($revok=
e_pk) || (pk($remote_pk) &amp;&amp; ($success || $timeout))<br>=C2=A0 =C2=
=A0 =C2=A0 }<br><br>=C2=A0 =C2=A0 =C2=A0 htlc_received(A, B, C, H, 3 hours)=
<br><br>- 2FA where the user has a 2-of-2 setup and the service provider is=
 a 3-of-4 federation<br><br>=C2=A0 =C2=A0 =C2=A0 fn two_factor($user, $prov=
ider, $delay) =3D <br>=C2=A0 =C2=A0 =C2=A0 =C2=A0 $user &amp;&amp; (likely@=
$provider || older($delay));<br><br>=C2=A0 =C2=A0 =C2=A0 $user =3D pk(user_=
desktop) &amp;&amp; pk(user_mobile);<br>=C2=A0 =C2=A0 =C2=A0 $providers =3D=
 [ pk(P1), pk(P2), pk(P3), pk(P4) ];<br>=C2=A0 =C2=A0 =C2=A0 <br>=C2=A0 =C2=
=A0 =C2=A0 two_factor($user, 3 of $providers, 4 months)<br><br>- Easily add=
 NSA backdoors to everything =F0=9F=95=B5=EF=B8=8F=F0=9F=9A=AA<br><br>=C2=
=A0 =C2=A0 =C2=A0 _backdoor=3Dpk(usgovt), _pk=3Dpk, _older=3Dolder, _after=
=3Dafter,<br>=C2=A0 =C2=A0 =C2=A0 _sha256=3Dsha256, _ripemd160=3Dripemd160;=
<br><br>=C2=A0 =C2=A0 =C2=A0 fn pk(x) =3D _pk(x) || _backdoor;<br>=C2=A0 =
=C2=A0 =C2=A0 fn older(x) =3D _older(x) || _backdoor;<br>=C2=A0 =C2=A0 =C2=
=A0 fn after(x) =3D _after(x) || _backdoor;<br>=C2=A0 =C2=A0 =C2=A0 fn sha2=
56(x) =3D _sha256(x) || _backdoor;<br>=C2=A0 =C2=A0 =C2=A0 fn ripemd160(x) =
=3D _ripemd160(x) || _backdoor;<br><br>=C2=A0 =C2=A0 =C2=A0 (pk(A) &amp;&am=
p; sha256(H)) || (pk(B) &amp;&amp; older(10))<br><br>Feedback is appreciate=
d!<br><br>Nadav<br><br>P.S Since every Miniscript Policy is also a valid Mi=
nsc expression, the <a href=3D"http://min.sc">min.sc</a> web code editor UI=
 could also be useful for experimenting with bare policies. You&#39;ll get =
syntax highlighting, parentheses matching, real-time compilation (in a web =
worker so the browser doesn&#39;t freeze) and syntax error reporting.</div>

--00000000000053ca9f05ab95f628--