Return-Path: Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id 0E132C004D for ; 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 ; 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 ; 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 ; Wed, 29 Jul 2020 15:16:26 +0000 (UTC) Received: by mail-ed1-f54.google.com with SMTP id n2so17680407edr.5 for ; 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 Date: Wed, 29 Jul 2020 18:10:42 +0300 Message-ID: To: Bitcoin Protocol Discussion 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-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
Hi all,

I recently relea= sed Minsc, a high-level scripting language for expressing Bitcoin Script sp= ending conditions using a simple and familiar syntax.

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.

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

Source code (in Rust) is a= vailable on github: https://git= hub.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 en= ough

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

- Traditional preimage-based HTLC

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

=C2=A0 =C2=A0 =C2=A0 lik= ely@$redeem || $refund

- Liquid-like federated pegin with emergency = recovery keys

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

=C2=A0 =C2=A0 =C2=A0 likely@$federation || ($timeout &&= amp; $recovery)

- The BOLT #3 received HTLC policy

=C2=A0 =C2= =A0 =C2=A0 fn htlc_received($revoke_pk, $local_pk, $remote_pk, $secret, $de= lay) {
=C2=A0 =C2=A0 =C2=A0 =C2=A0 $success =3D pk($local_pk) &&= hash160($secret);
=C2=A0 =C2=A0 =C2=A0 =C2=A0 $timeout =3D older($delay= );
=C2=A0 =C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2=A0 =C2=A0 =C2=A0 pk($revok= e_pk) || (pk($remote_pk) && ($success || $timeout))
=C2=A0 =C2= =A0 =C2=A0 }

=C2=A0 =C2=A0 =C2=A0 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

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

=C2=A0 =C2=A0 =C2=A0 $user =3D pk(user_= desktop) && pk(user_mobile);
=C2=A0 =C2=A0 =C2=A0 $providers =3D= [ pk(P1), pk(P2), pk(P3), pk(P4) ];
=C2=A0 =C2=A0 =C2=A0
=C2=A0 =C2= =A0 =C2=A0 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

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

=C2=A0 =C2=A0 =C2=A0 fn pk(x) =3D _pk(x) || _backdoor;
=C2=A0 = =C2=A0 =C2=A0 fn older(x) =3D _older(x) || _backdoor;
=C2=A0 =C2=A0 =C2= =A0 fn after(x) =3D _after(x) || _backdoor;
=C2=A0 =C2=A0 =C2=A0 fn sha2= 56(x) =3D _sha256(x) || _backdoor;
=C2=A0 =C2=A0 =C2=A0 fn ripemd160(x) = =3D _ripemd160(x) || _backdoor;

=C2=A0 =C2=A0 =C2=A0 (pk(A) &&am= p; sha256(H)) || (pk(B) && older(10))

Feedback is appreciate= d!

Nadav

P.S Since every Miniscript Policy is also a valid Mi= nsc 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--