WEBVTT - Automatic transcript; recognition may contain errors. Reviewed for technical wording and speaker labels. Times match the published episode.

00:00:07.660 --> 00:00:10.780
<v Aaron van Wirdum>Live from Utrecht, this is the Van Wirdum Sjorsnado.

00:00:11.580 --> 00:00:11.900
<v Sjors Provoost>Hello.

00:00:12.320 --> 00:00:13.940
<v Aaron van Wirdum>Episode 4, we're back.

00:00:14.440 --> 00:00:15.680
<v Sjors Provoost>Yes, we made it.

00:00:15.800 --> 00:00:17.340
<v Aaron van Wirdum>Sjors, so far so good?

00:00:17.640 --> 00:00:19.000
<v Sjors Provoost>I think I'm still alive.

00:00:19.140 --> 00:00:20.780
<v Aaron van Wirdum>Do you think this is going to be a one-taker?

00:00:21.660 --> 00:00:22.560
<v Sjors Provoost>I hope so.

00:00:23.040 --> 00:00:27.420
<v Aaron van Wirdum>Let's hope so. This would be a miracle if we can get this one right at once.

00:00:27.640 --> 00:00:28.900
<v Sjors Provoost>Yeah, let's see.

00:00:29.640 --> 00:00:31.620
<v Aaron van Wirdum>What are we going to be discussing today, Sjors?

00:00:31.800 --> 00:00:33.920
<v Sjors Provoost>I think you wanted to talk about script.

00:00:34.760 --> 00:00:37.520
<v Aaron van Wirdum>I want to talk about Miniscript to be more specific.

00:00:37.900 --> 00:00:38.120
<v Sjors Provoost>In fact,

00:00:38.280 --> 00:00:41.600
<v Aaron van Wirdum>yes. That's what I want to know everything about, Sjors. So you're going to help me.

00:00:41.900 --> 00:00:42.320
<v Sjors Provoost>Okay.

00:00:42.660 --> 00:00:43.300
<v Aaron van Wirdum>Is that the deal?

00:00:43.580 --> 00:00:44.260
<v Sjors Provoost>Sounds good.

00:00:45.080 --> 00:00:50.930
<v Aaron van Wirdum>Yes, Miniscript. It's a project, I guess that's how I would describe it.

00:00:50.950 --> 00:00:55.790
<v Aaron van Wirdum>It's a project by a couple of Blockstream engineers, even though it's not an

00:00:55.790 --> 00:01:00.870
<v Aaron van Wirdum>official Blockstream project. But it's Peter Wuille, Andrew Poelstra.

00:01:02.650 --> 00:01:08.010
<v Aaron van Wirdum>And then there was a third name that wasn't as well known, Sanket

00:01:08.010 --> 00:01:08.930
<v Aaron van Wirdum>Kanyalkar.

00:01:09.010 --> 00:01:11.250
<v Sjors Provoost>Yeah, I believe he was an intern at Blockstream at the time.

00:01:11.270 --> 00:01:15.430
<v Aaron van Wirdum>He may have been an intern, yes. So they developed this idea called Miniscript.

00:01:16.490 --> 00:01:21.810
<v Aaron van Wirdum>Um, so let's just get into what it is. It's... Okay, so to sort of spoil what it

00:01:21.810 --> 00:01:27.090
<v Aaron van Wirdum>is a little bit before we get into that, it's sort of a simplified, stripped down

00:01:27.090 --> 00:01:30.950
<v Aaron van Wirdum>version of Bitcoin script which is the programming language used in Bitcoin.

00:01:30.950 --> 00:01:32.230
<v Aaron van Wirdum>Yeah, so far so good.

00:01:32.230 --> 00:01:36.270
<v Sjors Provoost>Yeah, or it's a template. Basically, it's a template of Bitcoin scripts that you

00:01:36.270 --> 00:01:36.750
<v Sjors Provoost>can use.

00:01:36.750 --> 00:01:41.030
<v Aaron van Wirdum>A template of Bitcoin script is how you would describe it? Yeah. Okay, so let's

00:01:41.030 --> 00:01:45.610
<v Aaron van Wirdum>get started. First things first: Scripts, Bitcoin scripts.

00:01:45.930 --> 00:01:50.990
<v Sjors Provoost>Yeah, I think two episodes ago, we explained that it was actually good to add

00:01:50.990 --> 00:01:52.010
<v Sjors Provoost>constraints to money.

00:01:52.640 --> 00:01:58.260
<v Aaron van Wirdum>Right, yes. This was in that Taproot episode. You explained how actually putting

00:01:58.260 --> 00:02:02.240
<v Aaron van Wirdum>some restraints to money would be a good thing in the context of Bitcoin.

00:02:02.480 --> 00:02:07.460
<v Sjors Provoost>Right. If you're sending me money, everybody can see that Bitcoin transaction, so

00:02:07.460 --> 00:02:11.340
<v Sjors Provoost>you want to make sure, or in particular, I want to make sure that I'm the only

00:02:11.340 --> 00:02:16.340
<v Sjors Provoost>one who can spend it. So I'm telling you, make this transaction such that it can

00:02:16.340 --> 00:02:22.110
<v Sjors Provoost>only be spent by my public key. And the way that's done is using a script. Even

00:02:22.110 --> 00:02:25.970
<v Sjors Provoost>though it's a very simple script and most people use the same script, it is

00:02:25.970 --> 00:02:26.710
<v Sjors Provoost>actually a script.

00:02:27.320 --> 00:02:31.440
<v Aaron van Wirdum>Yeah, and script is actually a programming language.

00:02:31.680 --> 00:02:32.240
<v Sjors Provoost>Yes.

00:02:32.360 --> 00:02:36.860
<v Aaron van Wirdum>It's a new programming language. It was introduced in Bitcoin, like it didn't

00:02:36.860 --> 00:02:42.160
<v Aaron van Wirdum>exist before, although it resembles something that did exist before, which is

00:02:42.160 --> 00:02:42.760
<v Aaron van Wirdum>called Forth.

00:02:43.240 --> 00:02:49.160
<v Sjors Provoost>Yes. Basically, it's pretty horrible. I mean, it looks

00:02:49.160 --> 00:02:49.940
<v Sjors Provoost>like it was just

00:02:49.940 --> 00:02:52.020
<v Aaron van Wirdum>It's a horrible programming language.

00:02:52.300 --> 00:02:57.280
<v Sjors Provoost>I think so. It seems to be coupled together as an afterthought. But I think it

00:02:57.280 --> 00:03:01.080
<v Sjors Provoost>was only later that people realized that you can only change Bitcoin through very

00:03:01.080 --> 00:03:05.340
<v Sjors Provoost>carefully crafted soft forks. So you can't just say, oh, let's just start with a

00:03:05.340 --> 00:03:09.240
<v Sjors Provoost>draft language and then clean it up later. So it's been a complete nightmare to

00:03:09.240 --> 00:03:13.860
<v Sjors Provoost>make sure that language doesn't do anything surprising, anything bad. So a lot of

00:03:13.860 --> 00:03:17.460
<v Sjors Provoost>the... operations that were part of the language have been removed almost

00:03:17.460 --> 00:03:20.520
<v Sjors Provoost>immediately because there were all sorts of ways that you could just crash a node

00:03:20.520 --> 00:03:22.260
<v Sjors Provoost>or do other things.

00:03:22.900 --> 00:03:25.020
<v Aaron van Wirdum>Right, these were removed early on.

00:03:25.490 --> 00:03:30.630
<v Sjors Provoost>Yes. I mean, Ethereum had a similar experience in 2015, right, where complex

00:03:30.630 --> 00:03:34.090
<v Sjors Provoost>programs could do all sorts of unexpected things. But Bitcoin had that in the

00:03:34.090 --> 00:03:34.550
<v Sjors Provoost>beginning too.

00:03:34.950 --> 00:03:40.710
<v Aaron van Wirdum>Yeah. So just to remind our listeners, like what kind of restrictions can you put

00:03:40.710 --> 00:03:43.950
<v Aaron van Wirdum>on a transaction? Like what kind of restrictions are we talking about here?

00:03:44.030 --> 00:03:47.230
<v Sjors Provoost>Yeah. So the main restriction would be that only the owner of a specific public

00:03:47.230 --> 00:03:52.550
<v Sjors Provoost>key can spend this transaction. I think that's the typical pay-to-public key hash

00:03:52.550 --> 00:03:57.500
<v Sjors Provoost>transaction. And maybe we want to demonstrate how that works.

00:03:58.300 --> 00:03:59.040
<v Aaron van Wirdum>Go for it.

00:03:59.240 --> 00:04:05.140
<v Sjors Provoost>Yeah. So it's a stack-based language, and a stack is like a stack of plates. You

00:04:05.140 --> 00:04:10.100
<v Sjors Provoost>can put plates on it, and you can take the top plate off, but generally you don't

00:04:10.100 --> 00:04:13.040
<v Sjors Provoost>want to just take a plate out of the middle. And this is just easy to implement

00:04:13.040 --> 00:04:17.340
<v Sjors Provoost>as a programming language in general. So when people make early computer

00:04:17.340 --> 00:04:22.000
<v Sjors Provoost>processors, it was just easier to have a memory where you could only put things

00:04:22.000 --> 00:04:26.220
<v Sjors Provoost>on top of it and take the top element off. You didn't have addresses. Like with

00:04:26.220 --> 00:04:29.340
<v Sjors Provoost>memory, you have to say, which part of the memory do you want? With a stack, you

00:04:29.340 --> 00:04:32.920
<v Sjors Provoost>just say, put something on it, take something away from it. So the standard

00:04:32.920 --> 00:04:38.820
<v Sjors Provoost>Bitcoin script reads as follows. It's very beautiful. It's OP_DUP, as in double,

00:04:39.120 --> 00:04:44.820
<v Sjors Provoost>duplicate. Then OP_HASH160, as in take the 160 SHA hash

00:04:44.820 --> 00:04:50.820
<v Sjors Provoost>and RIPEMD hash. Then the public key. And

00:04:50.820 --> 00:04:56.560
<v Sjors Provoost>then OP_EQUALVERIFY. So it's four elements, duplicate, hash,

00:04:57.080 --> 00:04:59.540
<v Sjors Provoost>pub key, and then equal verify.

00:05:01.110 --> 00:05:06.990
<v Sjors Provoost>And if you kind of walk through what that does, let me see

00:05:06.990 --> 00:05:12.930
<v Sjors Provoost>where I have it. So what happens when the blockchain encounters this script,

00:05:12.930 --> 00:05:16.330
<v Sjors Provoost>it's going to be in the output of a transaction. So the output of a transaction

00:05:16.330 --> 00:05:21.280
<v Sjors Provoost>shows the script that it's locked with and the amount. Now, if you want to spend

00:05:21.280 --> 00:05:24.520
<v Sjors Provoost>that, what you do is you first publish

00:05:26.810 --> 00:05:29.150
<v Sjors Provoost>You publish what you want to put on the stack,

00:05:30.430 --> 00:05:35.850
<v Sjors Provoost>and then you sign it, essentially. Well, actually, you just publish what

00:05:35.850 --> 00:05:39.010
<v Sjors Provoost>you want to put in the stack, and that probably includes a signature.

00:05:41.250 --> 00:05:45.390
<v Aaron van Wirdum>By publish, you mean generate a new transaction?

00:05:45.630 --> 00:05:49.210
<v Sjors Provoost>Yeah, so the input of your transaction, what that actually looks like is

00:05:49.210 --> 00:05:53.610
<v Sjors Provoost>basically... a couple of things that you're putting on the stack. And what the

00:05:53.610 --> 00:05:58.570
<v Sjors Provoost>Bitcoin interpreter will do is it will see the stuff you put on the stack, and

00:05:58.570 --> 00:06:02.610
<v Sjors Provoost>then it starts running the program from the output. So given your stack, it

00:06:02.610 --> 00:06:06.750
<v Sjors Provoost>starts running the program from the output. So in this case, what you put on the

00:06:06.750 --> 00:06:10.380
<v Sjors Provoost>stack is your signature and your public key.

00:06:12.160 --> 00:06:15.080
<v Sjors Provoost>Because the original script did not have your public key, it had the hash of your

00:06:15.080 --> 00:06:19.280
<v Sjors Provoost>public key. Okay, so we start with a stack that has two plates. Plate one at the

00:06:19.280 --> 00:06:23.800
<v Sjors Provoost>bottom is your signature, and on top of that is a plate with your public key. And

00:06:23.800 --> 00:06:28.680
<v Sjors Provoost>then the script says OP_DUP. And what OP_DUP does is it takes the top element of

00:06:28.680 --> 00:06:32.580
<v Sjors Provoost>the stack, takes the top plate, the public key, and duplicates it. So now you

00:06:32.580 --> 00:06:36.380
<v Sjors Provoost>have two plates with a public key at the top of the stack, and your signature is

00:06:36.380 --> 00:06:42.050
<v Sjors Provoost>still at the bottom. Then the next code, the next instruction, is OP_HASH 160. So

00:06:42.050 --> 00:06:45.850
<v Sjors Provoost>what this does is it takes the top thing from the stack, which is one of those

00:06:45.850 --> 00:06:50.450
<v Sjors Provoost>public keys. It hashes it and then puts the hash on the stack. So now the stack

00:06:50.450 --> 00:06:51.310
<v Sjors Provoost>is...

00:06:53.660 --> 00:06:55.140
<v Sjors Provoost>I'm trying to interrogate you here.

00:06:55.860 --> 00:07:01.740
<v Aaron van Wirdum>Apparently. Now the stack is a hash and the public key... I didn't keep up.

00:07:01.740 --> 00:07:05.220
<v Sjors Provoost>Yeah, so at the bottom is still the signature. Then there's a public key and then

00:07:05.220 --> 00:07:07.980
<v Sjors Provoost>there's the hash of the public key. That's what's on the stack. So the next

00:07:07.980 --> 00:07:10.340
<v Sjors Provoost>operation is pubkey hash.

00:07:11.980 --> 00:07:17.480
<v Sjors Provoost>So that is the hash of your public key again. So now the top of the stack is two

00:07:17.480 --> 00:07:21.320
<v Sjors Provoost>times the hash of your public key. And then the next operation is op equal

00:07:21.320 --> 00:07:25.320
<v Sjors Provoost>verify. So that basically takes the two things off the top of the stack, says,

00:07:25.440 --> 00:07:29.280
<v Sjors Provoost>hey, are they the same? So indeed, did you put the hash of your public key?

00:07:31.580 --> 00:07:36.740
<v Sjors Provoost>And then the last thing that's left on the stack is only,

00:07:37.080 --> 00:07:41.940
<v Sjors Provoost>again, your signature and your public key. And it calls OP_CHECKSIG. So it checks

00:07:41.940 --> 00:07:43.920
<v Sjors Provoost>the signature using your public key.

00:07:45.220 --> 00:07:49.620
<v Sjors Provoost>And then the stack is empty and everything is happy. That's how the Bitcoin

00:07:49.620 --> 00:07:54.480
<v Sjors Provoost>program is run, and you can do arbitrarily complicated things that way.

00:07:54.800 --> 00:07:58.780
<v Aaron van Wirdum>So, yeah, so basically this stuff is telling your computer what to do, what to

00:07:58.780 --> 00:08:02.520
<v Aaron van Wirdum>check, see if stuff matches. If it matches, it's okay. If it doesn't match, it's

00:08:02.520 --> 00:08:06.840
<v Aaron van Wirdum>not, depending on whether it should match or not, and that's defined by the code.

00:08:07.640 --> 00:08:08.940
<v Aaron van Wirdum>That's what we're doing here, right?

00:08:09.100 --> 00:08:11.200
<v Sjors Provoost>Yeah, but notice that you don't have to check a signature.

00:08:11.340 --> 00:08:11.660
<v Aaron van Wirdum>Exactly.

00:08:11.880 --> 00:08:15.320
<v Sjors Provoost>You could just have a script that says, yeah, it's fine, just take it.

00:08:15.580 --> 00:08:21.250
<v Aaron van Wirdum>Yes. Or you could have a script that says you either need a valid

00:08:21.250 --> 00:08:26.930
<v Aaron van Wirdum>signature or you need 34 invalid signatures.

00:08:27.710 --> 00:08:31.090
<v Sjors Provoost>Yeah, you can do weird things. Yes, very strange things.

00:08:31.210 --> 00:08:33.950
<v Aaron van Wirdum>Okay, so that's kind of the point we're getting at here, I think, right?

00:08:34.250 --> 00:08:34.470
<v Sjors Provoost>Yes.

00:08:35.010 --> 00:08:40.990
<v Aaron van Wirdum>The script's language is diverse enough to allow for weird

00:08:40.990 --> 00:08:41.410
<v Aaron van Wirdum>stuff.

00:08:41.920 --> 00:08:46.620
<v Sjors Provoost>Yeah. And now the question is, if you're just sending money to yourself, you only

00:08:46.620 --> 00:08:50.440
<v Sjors Provoost>need this very simple standard script that everybody's seen a million times. But

00:08:50.440 --> 00:08:53.440
<v Sjors Provoost>let's say you're collaborating. You want to do a multisig. Now, there's actually

00:08:53.440 --> 00:08:57.760
<v Sjors Provoost>an instruction to do multisig, but let's say that didn't exist. So one way you

00:08:57.760 --> 00:09:03.720
<v Sjors Provoost>could do multisig is, say, the script we just explained with my public key in it

00:09:03.720 --> 00:09:08.380
<v Sjors Provoost>or my public key hash, and then the script we just explained with your public key

00:09:08.380 --> 00:09:13.920
<v Sjors Provoost>hash. Just in sequence. So if that's executed, I will not repeat the process we

00:09:13.920 --> 00:09:18.220
<v Sjors Provoost>did before, but you essentially start with those two public keys and two

00:09:18.220 --> 00:09:21.200
<v Sjors Provoost>signatures on the stack, and you run both of these scripts in sequence, and then

00:09:21.200 --> 00:09:25.990
<v Sjors Provoost>if both people signed, it's all good. So you have a poor man's... multisig.

00:09:26.130 --> 00:09:26.310
<v Aaron van Wirdum>Right.

00:09:26.810 --> 00:09:31.910
<v Sjors Provoost>But if I'm evil or stupid, I could make this a rekt-man multisig. Sorry for the

00:09:31.910 --> 00:09:37.370
<v Sjors Provoost>joke. And that is achieved by, in the middle, inserting an opcode called

00:09:37.370 --> 00:09:38.110
<v Sjors Provoost>OP_RETURN.

00:09:38.250 --> 00:09:38.590
<v Aaron van Wirdum>Right.

00:09:38.930 --> 00:09:43.430
<v Sjors Provoost>And the OP_RETURN code basically says, all right, stop evaluating this program.

00:09:43.430 --> 00:09:47.810
<v Sjors Provoost>You're done. Now, if I had an electronic lawyer that wanted to check that this

00:09:47.810 --> 00:09:52.490
<v Sjors Provoost>multisig... is what it says it does, or in fact, if you have that lawyer, your

00:09:52.490 --> 00:09:57.300
<v Sjors Provoost>lawyer might say, well, I see that my signature is being checked, and whatever

00:09:57.300 --> 00:10:00.380
<v Sjors Provoost>the rest of the script does, I don't care, but my signature is being checked, so

00:10:00.380 --> 00:10:04.950
<v Sjors Provoost>I'm happy with this. But of course, you shouldn't be happy with this, so your

00:10:04.950 --> 00:10:08.720
<v Sjors Provoost>electronic lawyer should see that OP_RETURN statement and warn you. But the

00:10:08.720 --> 00:10:13.660
<v Sjors Provoost>problem is there's a trillion ways in which scripts can go wrong, and that is why

00:10:13.660 --> 00:10:17.680
<v Sjors Provoost>you need a standardized... way of dealing with these scripts and that's where

00:10:17.680 --> 00:10:18.620
<v Sjors Provoost>Miniscript really comes in.

00:10:18.640 --> 00:10:23.780
<v Aaron van Wirdum>I'll read a little fragment from Andrew Poelstra who I interviewed a long time

00:10:23.780 --> 00:10:28.220
<v Aaron van Wirdum>ago when I wrote an article on this. So the example he gave was, and I'm not

00:10:28.220 --> 00:10:31.540
<v Aaron van Wirdum>going to pretend like I understand everything he said in this quote, but that was

00:10:31.540 --> 00:10:37.480
<v Aaron van Wirdum>sort of the point of the quote for me, that it was you know, exemplifying the

00:10:37.480 --> 00:10:42.080
<v Aaron van Wirdum>complexity of potential ways to mess around with script. Anyways, so the quote

00:10:42.080 --> 00:10:47.340
<v Aaron van Wirdum>was: "There are opcodes in Bitcoin script which do really absurd things like

00:10:47.340 --> 00:10:51.900
<v Aaron van Wirdum>interpret the signature as a true false value, branch on that, convert that

00:10:51.900 --> 00:10:56.300
<v Aaron van Wirdum>Boolean to a number, and then index into the stack and rearrange the stack based

00:10:56.300 --> 00:11:00.990
<v Aaron van Wirdum>on that number. And the specific rules for how it does this are super nuts." You

00:11:00.990 --> 00:11:02.670
<v Aaron van Wirdum>probably actually follow that perfectly.

00:11:02.950 --> 00:11:03.010
<v Sjors Provoost>No.

00:11:03.450 --> 00:11:04.410
<v Aaron van Wirdum>Oh, you don't either.

00:11:04.570 --> 00:11:09.730
<v Sjors Provoost>I kind of do, but the analogy would be you have this stack of plates and you take

00:11:09.730 --> 00:11:13.210
<v Sjors Provoost>a hammer and you smash one and then you confuse two and you paint one red and

00:11:13.210 --> 00:11:16.870
<v Sjors Provoost>then it still works if you do it correctly. It's completely absurd.

00:11:17.070 --> 00:11:22.470
<v Aaron van Wirdum>Right. Or another analogy I think you gave before this recording, correct me if

00:11:22.470 --> 00:11:27.030
<v Aaron van Wirdum>this is not the right way of explaining this analogy, but it's like you have a

00:11:27.030 --> 00:11:31.560
<v Aaron van Wirdum>contract. And it says, you know, you're buying this house and these are all the

00:11:31.560 --> 00:11:35.420
<v Aaron van Wirdum>conditions. And then there's a small letter which says, unless there's like two

00:11:35.420 --> 00:11:38.640
<v Aaron van Wirdum>commas in a row somewhere in this contract, in which case all your base are

00:11:38.640 --> 00:11:39.300
<v Aaron van Wirdum>belong to us.

00:11:39.520 --> 00:11:42.740
<v Sjors Provoost>Exactly. Except that this will be like the law, right? So the contract doesn't

00:11:42.740 --> 00:11:47.320
<v Sjors Provoost>say that at all. It's just that the law that's in this country has that stupid

00:11:47.320 --> 00:11:51.120
<v Sjors Provoost>rule. Like if there are two commas in a contract, you're giving away your money.

00:11:51.540 --> 00:11:54.480
<v Sjors Provoost>That's the script interpreter of all the consensus rules, which are quite

00:11:54.480 --> 00:11:55.000
<v Sjors Provoost>complicated.

00:11:55.280 --> 00:12:00.970
<v Aaron van Wirdum>Yes. Okay, so I think we've now broken down the problem with Script. It's... It's

00:12:00.970 --> 00:12:06.730
<v Aaron van Wirdum>a shitty programming language, or at least it's easy to make mistakes or hide

00:12:06.730 --> 00:12:11.450
<v Aaron van Wirdum>bugs in there and make all sorts of complex arrangements that people might or

00:12:11.450 --> 00:12:15.590
<v Aaron van Wirdum>might not notice, and then your money goes to places where you don't want it to

00:12:15.590 --> 00:12:18.390
<v Aaron van Wirdum>go. Is that the best way? That's the summary, right?

00:12:18.570 --> 00:12:24.190
<v Sjors Provoost>Yeah, and we've seen in other projects how bad things can go if you have a very

00:12:24.190 --> 00:12:26.730
<v Sjors Provoost>complicated language that does things you're not completely expecting.

00:12:27.740 --> 00:12:32.480
<v Aaron van Wirdum>Are you referring to a project that rhymes on Metherium?

00:12:35.230 --> 00:12:40.070
<v Aaron van Wirdum>I think we're on the same page. Okay, so solutions. We're getting to the solution

00:12:40.070 --> 00:12:40.870
<v Aaron van Wirdum>part of the story.

00:12:40.950 --> 00:12:45.530
<v Sjors Provoost>So what you're basically doing, what Miniscript is doing, is it's taking certain

00:12:45.530 --> 00:12:50.690
<v Sjors Provoost>example scripts, so a sequence of opcodes, and it lists, I think, about 20 of

00:12:50.690 --> 00:12:52.720
<v Sjors Provoost>them. 20 templates.

00:12:53.040 --> 00:12:53.720
<v Aaron van Wirdum>This is Miniscript.

00:12:53.840 --> 00:12:59.800
<v Sjors Provoost>Yes. It lists a few dozen templates. It does not use all of the available Bitcoin

00:12:59.800 --> 00:13:01.320
<v Sjors Provoost>script. It uses a subset of it.

00:13:01.440 --> 00:13:06.780
<v Aaron van Wirdum>Right. So let's say Bitcoin script has 100 tools. I have no idea if it's close to

00:13:06.780 --> 00:13:10.350
<v Aaron van Wirdum>100. I'm just throwing out a number. The Miniscript. It says, okay, let's throw

00:13:10.350 --> 00:13:13.810
<v Aaron van Wirdum>out 80 of these because these are just going to cause a mess. And let's keep 20.

00:13:13.990 --> 00:13:17.670
<v Aaron van Wirdum>And that way it's going to be a little bit simpler for everyone. Right. Is that right?

00:13:17.730 --> 00:13:22.810
<v Sjors Provoost>Well, so if Bitcoin script uses an alphabet, essentially, and

00:13:22.810 --> 00:13:27.630
<v Sjors Provoost>Miniscript has a set of words. So it's not a subset of the alphabet, but it's a

00:13:27.630 --> 00:13:28.390
<v Sjors Provoost>subset of words.

00:13:28.650 --> 00:13:30.750
<v Aaron van Wirdum>I see. Okay. That's a better analogy.

00:13:30.750 --> 00:13:35.110
<v Sjors Provoost>So there's certain patterns of opcodes that you're allowed to use. And if you use

00:13:35.110 --> 00:13:37.270
<v Sjors Provoost>those patterns in the way they describe.

00:13:37.710 --> 00:13:41.070
<v Aaron van Wirdum>So this double comma is removed now.

00:13:41.330 --> 00:13:46.090
<v Sjors Provoost>Yeah, there's no double comma. Or there is, but it is used in a very precise way.

00:13:46.790 --> 00:13:52.390
<v Sjors Provoost>So basically Miniscript, yeah, it removes some of the foot guns, but it

00:13:52.390 --> 00:13:57.290
<v Sjors Provoost>also allows you to do very cool stuff safely. In particular, it lets you do

00:13:57.290 --> 00:14:03.080
<v Sjors Provoost>things like and. So you can say condition A must be true and condition B must be

00:14:03.080 --> 00:14:07.830
<v Sjors Provoost>true. And you can do things like or. And whatever is inside the or or inside the

00:14:07.830 --> 00:14:12.800
<v Sjors Provoost>and can be arbitrarily complex. So with Bitcoin script, you have if and else type

00:14:12.800 --> 00:14:16.900
<v Sjors Provoost>of statements. But if you're not careful, those if and else statements will not

00:14:16.900 --> 00:14:18.100
<v Sjors Provoost>do what you think they're going to do.

00:14:19.480 --> 00:14:21.120
<v Sjors Provoost>Because there's

00:14:21.120 --> 00:14:23.320
<v Aaron van Wirdum>more complexity hidden after the if.

00:14:23.600 --> 00:14:27.400
<v Sjors Provoost>Yes, exactly. And the mini script, basically, the templates make sure that you're

00:14:27.400 --> 00:14:32.160
<v Sjors Provoost>only doing things that are actually doing what you think they're doing. So they

00:14:32.160 --> 00:14:37.880
<v Sjors Provoost>really contain it. And that allows you to do nice things. So let's say you're...

00:14:37.900 --> 00:14:43.500
<v Sjors Provoost>You're a company and you offer a semi-custodial wallet solution where you have

00:14:43.500 --> 00:14:47.760
<v Sjors Provoost>one of the keys of the user. And the user has the other, has two keys, for

00:14:47.760 --> 00:14:51.580
<v Sjors Provoost>example. So you don't have a majority of the keys. And maybe there's a five-year

00:14:51.580 --> 00:14:56.530
<v Sjors Provoost>timeout where you do have control in case the user dies. Something like that, right?

00:14:56.830 --> 00:14:58.350
<v Aaron van Wirdum>Yeah, like a multisig kind of setup.

00:14:58.690 --> 00:15:02.390
<v Sjors Provoost>And so normally when you set up a multisig, the way you kind of set it up is

00:15:02.390 --> 00:15:07.510
<v Sjors Provoost>everybody gives their key, their master key, their XPUB, for example, and you

00:15:07.510 --> 00:15:11.550
<v Sjors Provoost>create a very simple script that has three keys and three people sign. But the

00:15:11.550 --> 00:15:15.390
<v Sjors Provoost>problem is because you're a big business that offers a service, you have some

00:15:15.390 --> 00:15:18.790
<v Sjors Provoost>really complicated internal accounting department, and you maybe want to have

00:15:18.790 --> 00:15:23.610
<v Sjors Provoost>five different signatures by specific people in God knows what complexity. But

00:15:23.610 --> 00:15:24.670
<v Sjors Provoost>you don't want to...

00:15:24.670 --> 00:15:29.410
<v Aaron van Wirdum>Yeah, you have like five members on the board and you want three of them to sign.

00:15:29.630 --> 00:15:35.330
<v Aaron van Wirdum>Yeah. Unless maybe the CEO gets some sort of special right

00:15:35.330 --> 00:15:38.320
<v Aaron van Wirdum>from... two of the board members, and there's

00:15:38.320 --> 00:15:42.060
<v Sjors Provoost>a code hidden in an envelope inside the nuclear suitcase that has an override. Exactly.

00:15:42.060 --> 00:15:45.740
<v Aaron van Wirdum>Exactly. There's like all sorts of complex stuff you can do with it. And that

00:15:45.740 --> 00:15:49.720
<v Aaron van Wirdum>should... all the complex stuff should count as one key. Like, you... right,

00:15:49.720 --> 00:15:53.380
<v Aaron van Wirdum>that's where you're getting at. Like, you don't really care how the complex stuff

00:15:53.380 --> 00:15:53.920
<v Aaron van Wirdum>is solved.

00:15:53.920 --> 00:15:54.260
<v Sjors Provoost>Yeah.

00:15:54.260 --> 00:15:56.980
<v Aaron van Wirdum>That's up to the company. You figure it out company.

00:15:56.980 --> 00:15:57.460
<v Sjors Provoost>Yeah.

00:15:57.460 --> 00:16:02.620
<v Aaron van Wirdum>As long as it's just... it's clear to us that it's only one key, however you do it.

00:16:02.840 --> 00:16:07.460
<v Sjors Provoost>Exactly. Now, the problem with that is if I gave you... You can do that with

00:16:07.460 --> 00:16:13.440
<v Sjors Provoost>script or with taproot, but how do I, as a customer, know... Like I would

00:16:13.440 --> 00:16:16.580
<v Sjors Provoost>have to hire my own electronic lawyer to check that script of yours that it

00:16:16.580 --> 00:16:22.460
<v Sjors Provoost>doesn't have any of these double comma little gimmicks in it. And if only there

00:16:22.460 --> 00:16:26.240
<v Sjors Provoost>was a way you could check that. And Miniscript is done such that you can check

00:16:26.240 --> 00:16:29.260
<v Sjors Provoost>that as long as the script that you're getting is compatible with Miniscript.

00:16:29.820 --> 00:16:33.520
<v Sjors Provoost>Because Miniscript to normal script is two ways. So you can take any Miniscript,

00:16:33.800 --> 00:16:37.420
<v Sjors Provoost>turn it into a normal script. You can take any normal script. and turn it into a

00:16:37.420 --> 00:16:42.000
<v Sjors Provoost>mini script. Well, unless it doesn't match, right? If there's codes in it that

00:16:42.000 --> 00:16:45.000
<v Sjors Provoost>don't apply, then it just doesn't compile or doesn't translate.

00:16:45.340 --> 00:16:45.500
<v Aaron van Wirdum>Sure.

00:16:46.480 --> 00:16:50.760
<v Sjors Provoost>So, and if you can turn something into a mini script, then you can analyze it

00:16:50.760 --> 00:16:54.480
<v Sjors Provoost>using all sorts of tools. that can analyze any miniscript.

00:16:54.840 --> 00:16:55.000
<v Aaron van Wirdum>Right.

00:16:55.200 --> 00:16:58.300
<v Sjors Provoost>So what you would have is every wallet out there could have a Miniscript

00:16:58.300 --> 00:17:02.060
<v Sjors Provoost>interpreter and the interpreter could show you a little pie chart and saying, you

00:17:02.060 --> 00:17:06.620
<v Sjors Provoost>are this one piece of the pie and there's this other piece of the pie that is

00:17:06.620 --> 00:17:09.440
<v Sjors Provoost>really complicated, but you don't have to worry about it. It's not going to do

00:17:09.440 --> 00:17:10.040
<v Sjors Provoost>anything sneaky.

00:17:10.380 --> 00:17:12.040
<v Aaron van Wirdum>Right. That's good.

00:17:12.420 --> 00:17:12.940
<v Sjors Provoost>That's excellent.

00:17:13.220 --> 00:17:17.400
<v Aaron van Wirdum>Yeah. One of the things that I... So, I mean, we're making a podcast, so we can't

00:17:17.400 --> 00:17:22.840
<v Aaron van Wirdum>actually show this, unfortunately. But Poelstra, for example, he's drawn this

00:17:22.840 --> 00:17:26.560
<v Aaron van Wirdum>out. You can actually draw out what a contract would look like. Apparently,

00:17:26.560 --> 00:17:30.140
<v Aaron van Wirdum>that's not really possible with a script. All of this was news to me.

00:17:30.300 --> 00:17:36.220
<v Sjors Provoost>You can. It's just horrible, manual, tedious... Yeah. I mean, imagine the

00:17:36.220 --> 00:17:40.930
<v Sjors Provoost>people from Liquid, for example, that have a 13 of five multi-sig with all sorts

00:17:40.930 --> 00:17:41.490
<v Sjors Provoost>of fallbacks.

00:17:41.970 --> 00:17:45.230
<v Aaron van Wirdum>Yeah. Okay. So that's probably drawn out at some point. Yeah. But with

00:17:45.230 --> 00:17:49.730
<v Aaron van Wirdum>miniscript, it's actually fairly simple to draw it out. Yeah. And you can show

00:17:49.730 --> 00:17:55.430
<v Aaron van Wirdum>this to a CEO who has no idea about scripts or miniscripts. You can just look at

00:17:55.430 --> 00:18:00.830
<v Aaron van Wirdum>the picture and figure, hey, I, yep, that's sort of what I want the blue and red

00:18:00.830 --> 00:18:05.330
<v Aaron van Wirdum>squares to be. And if these keys work out like this, then it seems like a good

00:18:05.330 --> 00:18:05.910
<v Aaron van Wirdum>idea to me.

00:18:06.270 --> 00:18:06.530
<v Sjors Provoost>Exactly.

00:18:07.090 --> 00:18:08.590
<v Aaron van Wirdum>So that's actually possible now.

00:18:09.010 --> 00:18:12.420
<v Sjors Provoost>Yeah, with Miniscript. But wait, there's more.

00:18:12.560 --> 00:18:13.040
<v Aaron van Wirdum>There's more.

00:18:13.780 --> 00:18:15.540
<v Sjors Provoost>And that's called the policy language.

00:18:16.000 --> 00:18:19.580
<v Aaron van Wirdum>No, I want to ask you something else first.

00:18:19.780 --> 00:18:19.940
<v Sjors Provoost>Okay.

00:18:20.180 --> 00:18:25.960
<v Aaron van Wirdum>With Miniscript, I do think there are, strictly technically speaking, there are

00:18:25.960 --> 00:18:30.460
<v Aaron van Wirdum>some limitations. Like there is stuff you can't do with Miniscript, right?

00:18:30.700 --> 00:18:30.920
<v Sjors Provoost>Yes.

00:18:32.070 --> 00:18:35.330
<v Aaron van Wirdum>But as far as I understand, these are stuff no one actually does anyways.

00:18:35.550 --> 00:18:41.310
<v Sjors Provoost>Well, that's not necessarily true. So the thing is, but we have to go to

00:18:41.310 --> 00:18:42.890
<v Sjors Provoost>policy language before I can explain that.

00:18:43.010 --> 00:18:43.470
<v Aaron van Wirdum>Oh, we do?

00:18:43.730 --> 00:18:44.030
<v Sjors Provoost>Yes.

00:18:44.290 --> 00:18:45.650
<v Aaron van Wirdum>Did you have this in mind already?

00:18:46.530 --> 00:18:49.030
<v Sjors Provoost>So, yeah. So let me just quickly explain.

00:18:49.050 --> 00:18:50.730
<v Aaron van Wirdum>You've got this episode planned out way better than I do.

00:18:50.790 --> 00:18:54.290
<v Sjors Provoost>Well, to understand why you might want to do really complicated stuff, I need to

00:18:54.290 --> 00:18:55.690
<v Sjors Provoost>explain what the policy language is.

00:18:55.690 --> 00:18:56.650
<v Aaron van Wirdum>Yes. Okay, go for it.

00:18:56.970 --> 00:19:02.700
<v Sjors Provoost>So a policy language. poorly named, or maybe not poorly named, is a way

00:19:02.700 --> 00:19:06.420
<v Sjors Provoost>to express your intentions. So for example, say I want two signatures.

00:19:08.100 --> 00:19:12.340
<v Sjors Provoost>And this can be translated or compiled, I think is the better term, to

00:19:12.340 --> 00:19:12.900
<v Sjors Provoost>Miniscript.

00:19:14.240 --> 00:19:16.080
<v Sjors Provoost>And the nice thing is...

00:19:16.080 --> 00:19:20.360
<v Aaron van Wirdum>Okay, so to be clear, the policy language is the stuff, like if someone like you,

00:19:20.460 --> 00:19:25.280
<v Aaron van Wirdum>Sjors, you're building a wallet, I don't know, you're doing something on your

00:19:25.280 --> 00:19:29.520
<v Aaron van Wirdum>computer, improving Bitcoin, then you're typing and the stuff that comes out of

00:19:29.520 --> 00:19:33.960
<v Aaron van Wirdum>your fingers is policy language. And then you actually compile that to script

00:19:33.960 --> 00:19:34.500
<v Aaron van Wirdum>later on.

00:19:34.830 --> 00:19:38.030
<v Sjors Provoost>Yeah. I mean, you could just write the script directly or you could write the

00:19:38.030 --> 00:19:40.870
<v Sjors Provoost>mini script directly. But the nice thing about writing the policy language is

00:19:40.870 --> 00:19:45.330
<v Sjors Provoost>that you can have a compiler that can be very smart. So a simple policy language

00:19:45.330 --> 00:19:51.210
<v Sjors Provoost>might be just give me two of two signatures and the

00:19:51.210 --> 00:19:56.920
<v Sjors Provoost>policy language will probably convert that to op multisig. Or we'll convert that

00:19:56.920 --> 00:20:01.420
<v Sjors Provoost>to multisig in Miniscript. And multisig in Miniscript is just op multisig. So

00:20:01.420 --> 00:20:02.280
<v Sjors Provoost>that's super trivial.

00:20:02.680 --> 00:20:06.740
<v Aaron van Wirdum>Yeah. Okay. So whoever wrote the policy language, and now Peter Wuille, for

00:20:06.740 --> 00:20:08.540
<v Aaron van Wirdum>example, wrote the policy language for this.

00:20:10.160 --> 00:20:14.360
<v Aaron van Wirdum>It was him. It was his brain, basically. He figured out all the best ways to

00:20:14.360 --> 00:20:20.080
<v Aaron van Wirdum>compile this policy language into Miniscript, right? Like he must have somehow

00:20:20.080 --> 00:20:20.700
<v Aaron van Wirdum>figured it out.

00:20:20.800 --> 00:20:21.520
<v Sjors Provoost>Yeah, he wrote a compiler.

00:20:22.550 --> 00:20:24.890
<v Aaron van Wirdum>See, I don't know anything about this stuff.

00:20:24.990 --> 00:20:30.030
<v Sjors Provoost>That's okay. So basically, you write a policy language. It's like a higher-level

00:20:30.030 --> 00:20:33.610
<v Sjors Provoost>programming language. So if you have a higher-level programming language, like, I

00:20:33.610 --> 00:20:38.250
<v Sjors Provoost>don't know, BASIC, you can say go to five. I don't know if you've ever worked

00:20:38.250 --> 00:20:38.770
<v Sjors Provoost>with BASIC.

00:20:39.670 --> 00:20:44.090
<v Aaron van Wirdum>Sjors, I can't code Hello World. Isn't that clear to you right now?

00:20:44.230 --> 00:20:45.430
<v Sjors Provoost>Well, I mean, Hello World.

00:20:45.430 --> 00:20:48.550
<v Aaron van Wirdum>I've coded Hello World once, but that's pretty much how limited I am.

00:20:48.550 --> 00:20:50.410
<v Sjors Provoost>Okay, but what language did you code Hello World in?

00:20:50.940 --> 00:20:51.840
<v Aaron van Wirdum>I don't remember.

00:20:52.100 --> 00:20:57.060
<v Sjors Provoost>That's amazing. Anyway, so what happens is usually when you see a programmer

00:20:57.060 --> 00:21:01.060
<v Sjors Provoost>looking at a screen, you see something that looks like English, like with words

00:21:01.060 --> 00:21:05.240
<v Sjors Provoost>like for and next and yadda yadda. But eventually the machine is just reading

00:21:05.240 --> 00:21:05.940
<v Sjors Provoost>bits and bytes.

00:21:06.080 --> 00:21:07.760
<v Aaron van Wirdum>Sure. No, I understand that part.

00:21:07.920 --> 00:21:12.040
<v Sjors Provoost>So the bits and bytes are very close to what Bitcoin opcodes look like. They're

00:21:12.040 --> 00:21:15.500
<v Sjors Provoost>very low level. They're very instructions like put this on the stack, take that

00:21:15.500 --> 00:21:16.180
<v Sjors Provoost>away from the stack.

00:21:18.560 --> 00:21:23.920
<v Sjors Provoost>And the mini script is essentially the same. It's just only a subset of it. But

00:21:23.920 --> 00:21:27.280
<v Sjors Provoost>it's slightly more readable, but it's still extremely low level. The policy

00:21:27.280 --> 00:21:30.460
<v Sjors Provoost>language is slightly higher level. So what you do is you start at the higher

00:21:30.460 --> 00:21:34.220
<v Sjors Provoost>level, which is easier for a programmer to write. And then a computer looks at

00:21:34.220 --> 00:21:38.020
<v Sjors Provoost>that high level language and says, how can I write this into low level machine

00:21:38.020 --> 00:21:39.960
<v Sjors Provoost>readable stuff as efficiently as possible?

00:21:40.180 --> 00:21:40.440
<v Aaron van Wirdum>Sure.

00:21:41.690 --> 00:21:44.910
<v Sjors Provoost>In the case of the multisig thing, I might say, I just want two out of two

00:21:44.910 --> 00:21:48.890
<v Sjors Provoost>signatures. I don't care how you do that. Then the compiler knows that there are

00:21:48.890 --> 00:21:49.910
<v Sjors Provoost>multiple ways to do that.

00:21:50.150 --> 00:21:54.620
<v Aaron van Wirdum>Okay, but how does the compiler know this? I hope there's listeners out there

00:21:54.620 --> 00:21:58.360
<v Aaron van Wirdum>that know as little about this as I do, so they might learn something. How does

00:21:58.360 --> 00:21:59.240
<v Aaron van Wirdum>the compiler know this?

00:21:59.320 --> 00:22:04.360
<v Sjors Provoost>So disclaimer, I don't think I've ever written a compiler. I'm not that cool. But

00:22:04.360 --> 00:22:07.260
<v Sjors Provoost>generally, compilers know because somebody wrote the compiler.

00:22:07.500 --> 00:22:11.820
<v Aaron van Wirdum>But that was my point. It must have come from Peter Wuille's brain in this case.

00:22:11.860 --> 00:22:13.800
<v Sjors Provoost>Of course, yes. Everything comes out of Peter Wuille's brain.

00:22:13.840 --> 00:22:14.460
<v Aaron van Wirdum>There we go.

00:22:15.300 --> 00:22:18.720
<v Sjors Provoost>But basically, the compiler knows, okay, there's maybe two or three ways to do

00:22:18.720 --> 00:22:23.200
<v Sjors Provoost>this, to execute this intention. And then the question is, which of the three am

00:22:23.200 --> 00:22:28.860
<v Sjors Provoost>I going to pick? Well, then it depends on the transaction weight and the fees

00:22:28.860 --> 00:22:32.960
<v Sjors Provoost>that you might be involved. But also you can tell it, okay, I think most of the

00:22:32.960 --> 00:22:37.500
<v Sjors Provoost>time it's condition A, but only 10% of the time it's condition B. And then the

00:22:37.500 --> 00:22:42.560
<v Sjors Provoost>compiler can try. condition A nine times and condition B one time, and then

00:22:42.560 --> 00:22:47.200
<v Sjors Provoost>figure out what the expected fee is. So it can optimize for typical use cases,

00:22:47.360 --> 00:22:50.880
<v Sjors Provoost>worst case scenarios, all these things. And it can then spit out a Bitcoin script

00:22:50.880 --> 00:22:53.100
<v Sjors Provoost>or a mini script that then becomes a Bitcoin script.

00:22:53.340 --> 00:22:55.960
<v Aaron van Wirdum>Yes, the compiler figures out the best way to do something.

00:22:56.060 --> 00:22:58.880
<v Sjors Provoost>And in very practical terms, another thing it could do, I don't know if it can

00:22:58.880 --> 00:23:03.720
<v Sjors Provoost>already do that, is you have SegWit scripts now, but we'll hopefully have

00:23:03.720 --> 00:23:07.750
<v Sjors Provoost>Taproot, which can put things in a Merkle tree. So your compiler could figure out

00:23:07.750 --> 00:23:11.010
<v Sjors Provoost>where to put stuff in the Merkle tree. You don't have to worry about how to build

00:23:11.010 --> 00:23:11.550
<v Sjors Provoost>the Merkle tree.

00:23:11.750 --> 00:23:12.530
<v Aaron van Wirdum>Right, yes.

00:23:12.930 --> 00:23:15.930
<v Sjors Provoost>So it can do all sorts of things. So you start at the policy language, and then

00:23:15.930 --> 00:23:18.870
<v Sjors Provoost>you write Miniscript, and that goes into...

00:23:19.850 --> 00:23:21.330
<v Aaron van Wirdum>Okay, so that's what a compiler is.

00:23:22.910 --> 00:23:26.970
<v Aaron van Wirdum>The policy language you use, you put it into the compiler, and then Miniscript

00:23:26.970 --> 00:23:29.110
<v Aaron van Wirdum>comes out of it, which is, in a way, script.

00:23:29.770 --> 00:23:33.410
<v Sjors Provoost>Yes, I think the technical term for going from Miniscript to script is

00:23:33.410 --> 00:23:37.550
<v Sjors Provoost>transpiling, which basically is like a one-on-one thing. You can do it in two

00:23:37.550 --> 00:23:41.010
<v Sjors Provoost>directions. So you can go from Miniscript to script, from script to miniscript,

00:23:41.130 --> 00:23:44.570
<v Sjors Provoost>but you cannot go back to a policy language. Well, you can guess the policy

00:23:44.570 --> 00:23:45.010
<v Sjors Provoost>language.

00:23:46.360 --> 00:23:52.120
<v Aaron van Wirdum>Okay, you can. Yeah, I guess so, yes. I understand that. And then getting

00:23:52.120 --> 00:23:55.100
<v Aaron van Wirdum>back to... Are we ready to get back to my question about the limitations?

00:23:55.560 --> 00:23:55.980
<v Sjors Provoost>Absolutely.

00:23:56.260 --> 00:24:01.040
<v Aaron van Wirdum>Okay, so now there are some limitations. when you're using, I guess, this policy

00:24:01.040 --> 00:24:02.640
<v Aaron van Wirdum>language or miniscripts in general?

00:24:02.840 --> 00:24:03.140
<v Sjors Provoost>Yes.

00:24:03.550 --> 00:24:08.970
<v Aaron van Wirdum>But these are limitations that no one actually suffers from, is how I understood it.

00:24:09.190 --> 00:24:14.230
<v Sjors Provoost>Not necessarily. I mean, ideally, yes. But in practice, some scripts or some

00:24:14.230 --> 00:24:18.430
<v Sjors Provoost>policies might be very complicated. And there would be infinite ways to execute

00:24:18.430 --> 00:24:22.550
<v Sjors Provoost>these in Bitcoin script. And because of all these weird double comma foot guns

00:24:22.550 --> 00:24:26.430
<v Sjors Provoost>that are in Bitcoin script, sometimes that's an advantage. Sometimes you can

00:24:26.430 --> 00:24:30.190
<v Sjors Provoost>write something really efficiently in Bitcoin script. that is just really

00:24:30.190 --> 00:24:33.590
<v Sjors Provoost>horrible if you objectively look at it, but it is really fast or really fee

00:24:33.590 --> 00:24:38.190
<v Sjors Provoost>efficient. And in fact, I believe Lightning uses that, the way they sometimes

00:24:38.190 --> 00:24:44.190
<v Sjors Provoost>deal with time locks or with hashes. Or nonces. There

00:24:44.190 --> 00:24:47.530
<v Sjors Provoost>are some tricks in Lightning, I believe, that you cannot do a miniscript, or at

00:24:47.530 --> 00:24:49.810
<v Sjors Provoost>least you could not do a miniscript. Maybe you can now.

00:24:50.170 --> 00:24:50.390
<v Aaron van Wirdum>Okay.

00:24:50.830 --> 00:24:55.030
<v Sjors Provoost>So there are some optimizations where, like what Poelstra said, like, oh, you do

00:24:55.030 --> 00:24:58.650
<v Sjors Provoost>some weird switching of the stack and you interpret things not the way they were,

00:24:58.770 --> 00:25:01.630
<v Sjors Provoost>you know, you put a public key on it, but you interpret it as a number. Those

00:25:01.630 --> 00:25:02.310
<v Sjors Provoost>kind of weird tricks.

00:25:03.690 --> 00:25:07.310
<v Sjors Provoost>Those might be very hard to reason about, but a human might be able to do it. But

00:25:07.310 --> 00:25:11.210
<v Sjors Provoost>the Miniscript compiler would not do it, which means you end up with longer.

00:25:12.130 --> 00:25:16.670
<v Sjors Provoost>potentially longer Lightning scripts if you do not have all the whistles and

00:25:16.670 --> 00:25:21.850
<v Sjors Provoost>bells in it. So it's possible that Miniscript would be expanded if there is some

00:25:21.850 --> 00:25:26.730
<v Sjors Provoost>other optimal way to do it. But you have to be careful because you really want to

00:25:26.730 --> 00:25:30.210
<v Sjors Provoost>make sure there's nothing in Miniscript that brings back those scary properties

00:25:30.210 --> 00:25:32.110
<v Sjors Provoost>of the underlying language.

00:25:33.120 --> 00:25:37.520
<v Aaron van Wirdum>Well, to be clear, in case this isn't clear to anyone, miniscripts is an addition

00:25:37.520 --> 00:25:41.680
<v Aaron van Wirdum>to what there is already. Like, script is going nowhere. Bitcoin still uses

00:25:41.680 --> 00:25:45.840
<v Aaron van Wirdum>script, and that's the way it's going to be. It's just this is an extra tool for

00:25:45.840 --> 00:25:46.840
<v Aaron van Wirdum>people who want to use that.

00:25:47.000 --> 00:25:49.200
<v Sjors Provoost>And in fact, it's not a consensus change at all.

00:25:49.540 --> 00:25:50.360
<v Aaron van Wirdum>No, it's nothing in that.

00:25:50.360 --> 00:25:54.220
<v Sjors Provoost>It's a tool that you can use or not use. Like, don't worry. It's not Blockstream

00:25:54.220 --> 00:25:56.820
<v Sjors Provoost>dominating the script here.

00:25:57.000 --> 00:26:02.420
<v Aaron van Wirdum>Yes. Okay, so we mentioned Peter Wuille has this policy language. I know this is

00:26:02.420 --> 00:26:07.840
<v Aaron van Wirdum>very fresh and you probably haven't looked at it very much, but Nadav Ivgi also

00:26:07.840 --> 00:26:10.710
<v Aaron van Wirdum>wrote a policy language. You haven't studied that yet.

00:26:10.830 --> 00:26:11.530
<v Sjors Provoost>I have not yet.

00:26:11.550 --> 00:26:13.230
<v Aaron van Wirdum>So I thought that would be a cliffhanger.

00:26:13.230 --> 00:26:14.090
<v Sjors Provoost>That would be a cliffhanger.

00:26:14.210 --> 00:26:17.130
<v Aaron van Wirdum>You like the cliffhanger. So that will be a cliffhanger for another episode.

00:26:17.410 --> 00:26:17.770
<v Sjors Provoost>Or never.

00:26:18.210 --> 00:26:21.250
<v Aaron van Wirdum>Or maybe we'll have one of those Lost...

00:26:21.410 --> 00:26:25.630
<v Sjors Provoost>But I can tell you from what I know about the policy language is that... And

00:26:25.630 --> 00:26:29.390
<v Sjors Provoost>you're still some steps away from having a practical tool where you and I can set

00:26:29.390 --> 00:26:33.070
<v Sjors Provoost>up a very complicated multisig wallet. There's all sorts of questions you want to

00:26:33.070 --> 00:26:37.210
<v Sjors Provoost>answer, like how exactly do you do this setup? What are you emailing to each

00:26:37.210 --> 00:26:41.210
<v Sjors Provoost>other? Are you emailing your keys or are you emailing something a little bit more

00:26:41.210 --> 00:26:45.490
<v Sjors Provoost>abstract that you agree on first and then you exchange keys? Those very practical

00:26:45.490 --> 00:26:48.150
<v Sjors Provoost>things are not solved inside a miniscript.

00:26:49.210 --> 00:26:51.330
<v Aaron van Wirdum>Let me at least mention...

00:26:53.590 --> 00:26:56.390
<v Aaron van Wirdum>It's called Minsc. So his policy language is called Minsc.

00:26:56.550 --> 00:26:56.830
<v Sjors Provoost>Okay.

00:26:57.070 --> 00:27:01.090
<v Aaron van Wirdum>Okay. I'm afraid we can't give you any more info about Minsc yet.

00:27:01.230 --> 00:27:04.590
<v Sjors Provoost>Well, I know Minsk with a K is a city, but I think it's with a C.

00:27:05.190 --> 00:27:07.550
<v Aaron van Wirdum>Minsc with a C. Yeah, that's some extra info.

00:27:09.300 --> 00:27:15.240
<v Aaron van Wirdum>All right. Is this the end of our episode? Did we cover everything we needed

00:27:15.240 --> 00:27:16.200
<v Aaron van Wirdum>to cover from Miniscript?

00:27:16.420 --> 00:27:17.060
<v Sjors Provoost>I hope so.

00:27:17.200 --> 00:27:21.600
<v Aaron van Wirdum>It was maybe slightly messy, so let's sum it up. Miniscript is a subsection. No,

00:27:21.680 --> 00:27:22.600
<v Aaron van Wirdum>you called it a template?

00:27:23.020 --> 00:27:25.680
<v Sjors Provoost>Yes, it's a template of script pieces.

00:27:25.740 --> 00:27:27.220
<v Aaron van Wirdum>Even the summary is getting messy now.

00:27:27.380 --> 00:27:31.000
<v Sjors Provoost>So basically, Bitcoin script is like an alphabet, essentially, just different

00:27:31.000 --> 00:27:35.240
<v Sjors Provoost>letters that have different meanings. And you could see Miniscript is a set of

00:27:35.240 --> 00:27:39.380
<v Sjors Provoost>words. Not really words, because you can put things between the words. maybe

00:27:39.380 --> 00:27:41.120
<v Sjors Provoost>words and brackets and commas.

00:27:42.340 --> 00:27:45.580
<v Sjors Provoost>That's what Miniscript is. And then the policy language is the thing that can be

00:27:45.580 --> 00:27:47.980
<v Sjors Provoost>converted to Miniscript. It's a bit more high level.

00:27:48.220 --> 00:27:50.480
<v Aaron van Wirdum>And there are several of those apparently by now.

00:27:51.060 --> 00:27:56.380
<v Sjors Provoost>Yes, exactly. Because Miniscript, it has to be set in stone, I guess, sort of,

00:27:56.440 --> 00:28:00.960
<v Sjors Provoost>because you want to do all the safety checks on it. But then just like you can

00:28:00.960 --> 00:28:04.080
<v Sjors Provoost>have different programming language, you can have different policy languages.

00:28:04.260 --> 00:28:10.090
<v Aaron van Wirdum>Yes. So if you're into Bitcoin programming, This is what you want to study. This

00:28:10.090 --> 00:28:10.830
<v Aaron van Wirdum>is what you want to look at.

00:28:10.890 --> 00:28:14.770
<v Sjors Provoost>If you're into Bitcoin programming, the rabbit hole is massive and pick

00:28:14.770 --> 00:28:17.210
<v Sjors Provoost>something. There's a talk by Andrew Poelstra.

00:28:17.210 --> 00:28:18.690
<v Aaron van Wirdum>This one is probably pretty good though, right?

00:28:20.090 --> 00:28:23.670
<v Sjors Provoost>Yeah. So there's a talk by Andrew Poelstra from Advancing Bitcoin, not the

00:28:23.670 --> 00:28:28.010
<v Sjors Provoost>conference, but the meetup before it, the BitDevs London, where he talks for two

00:28:28.010 --> 00:28:32.930
<v Sjors Provoost>hours about all the problems with regular script and why he hates things. And

00:28:32.930 --> 00:28:38.070
<v Sjors Provoost>that's just... He said he was going to do it in 20 minutes, and I think he still

00:28:38.070 --> 00:28:40.910
<v Sjors Provoost>didn't cover everything. I don't think that's the best place to start.

00:28:41.050 --> 00:28:41.910
<v Aaron van Wirdum>He's still on stage.

00:28:42.170 --> 00:28:44.430
<v Sjors Provoost>He's still on stage out there, just going through it.

00:28:46.010 --> 00:28:48.350
<v Aaron van Wirdum>All right, this was our episode of Miniscript, I think.

00:28:48.650 --> 00:28:51.650
<v Sjors Provoost>Yep, so thank you. Should I say thank you?

00:28:51.790 --> 00:28:54.650
<v Aaron van Wirdum>I forgot how we closed our episode.

00:28:54.890 --> 00:28:58.170
<v Sjors Provoost>I think I say thank you for listening to the Van Wirdum Sjorsnado.

00:28:58.470 --> 00:28:59.050
<v Aaron van Wirdum>There we go.

