What is Nostr?
Nadav Ivgi [ARCHIVE] /
npub1f2w…dpll
2023-06-07 18:26:04
in reply to nevent1q…nzy3

Nadav Ivgi [ARCHIVE] on Nostr: 📅 Original date posted:2020-07-29 📝 Original message:Hi all, I recently ...

📅 Original date posted:2020-07-29
📝 Original message: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 at pk(service_pk) || older(90 days))

- Traditional preimage-based HTLC

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

likely@$redeem || $refund

- Liquid-like federated pegin with emergency recovery keys

$federation = 4 of [ pk(A), pk(B), pk(C), pk(D), pk(E) ];
$recovery = 2 of [ pk(F), pk(G), pk(H) ];
$timeout = 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 = pk($local_pk) && hash160($secret);
$timeout = 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) =
$user && (likely@$provider || older($delay));

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

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

- Easily add NSA backdoors to everything 🕵️🚪

_backdoor=pk(usgovt), _pk=pk, _older=older, _after=after,
_sha256=sha256, _ripemd160=ripemd160;

fn pk(x) = _pk(x) || _backdoor;
fn older(x) = _older(x) || _backdoor;
fn after(x) = _after(x) || _backdoor;
fn sha256(x) = _sha256(x) || _backdoor;
fn ripemd160(x) = _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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.linuxfoundation.org/pipermail/bitcoin-dev/attachments/20200729/97272a76/attachment.html>;
Author Public Key
npub1f2w9pm06c4k9ay8rst7757thahg2tfrtd0n645zxrtsqwhvaysrswydpll