Episode 4: What is Miniscript
Ep. 04

Episode 4: What is Miniscript

•

Episode description

In this episode of the Van Wirdum Sjorsnado, Aaron and Sjors dive into Miniscript and how it makes using Bitcoin Script much easier.

Helpful Links:

Chapters

00:00:00 Miniscript and Bitcoin spending conditions
00:03:34 A stack-based Script example
00:08:41 Why combining arbitrary scripts is dangerous
00:12:35 Miniscript templates and safe composition
00:14:23 Analyzing complex wallet policies
00:18:09 Policy languages express spending intentions
00:22:15 Compilers optimize transaction costs
00:23:46 Miniscript limitations and optional adoption
00:25:57 Minsc and practical wallet integration

Support the Show!

Follow Bitcoin Magazine on Twitter @BitcoinMagazine

Follow Aaron van Wirdum @AaronvanW

Follow Sjors Provoost @provoost

Music:

Song Title: Segwit Sounds

By: The NakamoTones

Album: Citadel Music

Produced by: Bitcoin Audio

Transcript

Download transcript (.vtt)
0:07

Aaron van Wirdum Live from Utrecht, this is the Van Wirdum Sjorsnado.

0:11

Sjors Provoost Hello.

0:12

Aaron van Wirdum Episode 4, we're back.

0:14

Sjors Provoost Yes, we made it.

0:15

Aaron van Wirdum Sjors, so far so good?

0:17

Sjors Provoost I think I'm still alive.

0:19

Aaron van Wirdum Do you think this is going to be a one-taker?

0:21

Sjors Provoost I hope so.

0:23

Aaron van Wirdum Let's hope so. This would be a miracle if we can get this one right at once.

0:27

Sjors Provoost Yeah, let's see.

0:29

Aaron van Wirdum What are we going to be discussing today, Sjors?

0:31

Sjors Provoost I think you wanted to talk about script.

0:34

Aaron van Wirdum I want to talk about Miniscript to be more specific.

0:37

Sjors Provoost In fact,

0:38

Aaron van Wirdum yes. That's what I want to know everything about, Sjors. So you're going to help me.

0:41

Sjors Provoost Okay.

0:42

Aaron van Wirdum Is that the deal?

0:43

Sjors Provoost Sounds good.

0:45

Aaron van Wirdum Yes, Miniscript. It's a project, I guess that's how I would describe it. It's a project by a couple of Blockstream engineers, even though it's not an official Blockstream project. But it's Peter Wuille, Andrew Poelstra. And then there was a third name that wasn't as well known, Sanket Kanyalkar.

1:09

Sjors Provoost Yeah, I believe he was an intern at Blockstream at the time.

1:11

Aaron van Wirdum He may have been an intern, yes. So they developed this idea called Miniscript. Um, so let's just get into what it is. It's... Okay, so to sort of spoil what it is a little bit before we get into that, it's sort of a simplified, stripped down version of Bitcoin script which is the programming language used in Bitcoin. Yeah, so far so good.

1:32

Sjors Provoost Yeah, or it's a template. Basically, it's a template of Bitcoin scripts that you can use.

1:36

Aaron van Wirdum A template of Bitcoin script is how you would describe it? Yeah. Okay, so let's get started. First things first: Scripts, Bitcoin scripts.

1:45

Sjors Provoost Yeah, I think two episodes ago, we explained that it was actually good to add constraints to money.

1:52

Aaron van Wirdum Right, yes. This was in that Taproot episode. You explained how actually putting some restraints to money would be a good thing in the context of Bitcoin.

2:02

Sjors Provoost Right. If you're sending me money, everybody can see that Bitcoin transaction, so you want to make sure, or in particular, I want to make sure that I'm the only one who can spend it. So I'm telling you, make this transaction such that it can only be spent by my public key. And the way that's done is using a script. Even though it's a very simple script and most people use the same script, it is actually a script.

2:27

Aaron van Wirdum Yeah, and script is actually a programming language.

2:31

Sjors Provoost Yes.

2:32

Aaron van Wirdum It's a new programming language. It was introduced in Bitcoin, like it didn't exist before, although it resembles something that did exist before, which is called Forth.

2:43

Sjors Provoost Yes. Basically, it's pretty horrible. I mean, it looks like it was just

2:49

Aaron van Wirdum It's a horrible programming language.

2:52

Sjors Provoost I think so. It seems to be coupled together as an afterthought. But I think it was only later that people realized that you can only change Bitcoin through very carefully crafted soft forks. So you can't just say, oh, let's just start with a draft language and then clean it up later. So it's been a complete nightmare to make sure that language doesn't do anything surprising, anything bad. So a lot of the... operations that were part of the language have been removed almost immediately because there were all sorts of ways that you could just crash a node or do other things.

3:22

Aaron van Wirdum Right, these were removed early on.

3:25

Sjors Provoost Yes. I mean, Ethereum had a similar experience in 2015, right, where complex programs could do all sorts of unexpected things. But Bitcoin had that in the beginning too.

3:34

Aaron van Wirdum Yeah. So just to remind our listeners, like what kind of restrictions can you put on a transaction? Like what kind of restrictions are we talking about here?

3:44

Sjors Provoost Yeah. So the main restriction would be that only the owner of a specific public key can spend this transaction. I think that's the typical pay-to-public key hash transaction. And maybe we want to demonstrate how that works.

3:58

Aaron van Wirdum Go for it.

3:59

Sjors Provoost Yeah. So it's a stack-based language, and a stack is like a stack of plates. You can put plates on it, and you can take the top plate off, but generally you don't want to just take a plate out of the middle. And this is just easy to implement as a programming language in general. So when people make early computer processors, it was just easier to have a memory where you could only put things on top of it and take the top element off. You didn't have addresses. Like with memory, you have to say, which part of the memory do you want? With a stack, you just say, put something on it, take something away from it. So the standard Bitcoin script reads as follows. It's very beautiful. It's OP_DUP, as in double, duplicate. Then OP_HASH160, as in take the 160 SHA hash and RIPEMD hash. Then the public key. And then OP_EQUALVERIFY. So it's four elements, duplicate, hash, pub key, and then equal verify. And if you kind of walk through what that does, let me see where I have it. So what happens when the blockchain encounters this script, it's going to be in the output of a transaction. So the output of a transaction shows the script that it's locked with and the amount. Now, if you want to spend that, what you do is you first publish You publish what you want to put on the stack, and then you sign it, essentially. Well, actually, you just publish what you want to put in the stack, and that probably includes a signature.

5:41

Aaron van Wirdum By publish, you mean generate a new transaction?

5:45

Sjors Provoost Yeah, so the input of your transaction, what that actually looks like is basically... a couple of things that you're putting on the stack. And what the Bitcoin interpreter will do is it will see the stuff you put on the stack, and then it starts running the program from the output. So given your stack, it starts running the program from the output. So in this case, what you put on the stack is your signature and your public key. Because the original script did not have your public key, it had the hash of your public key. Okay, so we start with a stack that has two plates. Plate one at the bottom is your signature, and on top of that is a plate with your public key. And then the script says OP_DUP. And what OP_DUP does is it takes the top element of the stack, takes the top plate, the public key, and duplicates it. So now you have two plates with a public key at the top of the stack, and your signature is still at the bottom. Then the next code, the next instruction, is OP_HASH 160. So what this does is it takes the top thing from the stack, which is one of those public keys. It hashes it and then puts the hash on the stack. So now the stack is... I'm trying to interrogate you here.

6:55

Aaron van Wirdum Apparently. Now the stack is a hash and the public key... I didn't keep up.

7:01

Sjors Provoost Yeah, so at the bottom is still the signature. Then there's a public key and then there's the hash of the public key. That's what's on the stack. So the next operation is pubkey hash. So that is the hash of your public key again. So now the top of the stack is two times the hash of your public key. And then the next operation is op equal verify. So that basically takes the two things off the top of the stack, says, hey, are they the same? So indeed, did you put the hash of your public key? And then the last thing that's left on the stack is only, again, your signature and your public key. And it calls OP_CHECKSIG. So it checks the signature using your public key. And then the stack is empty and everything is happy. That's how the Bitcoin program is run, and you can do arbitrarily complicated things that way.

7:54

Aaron van Wirdum So, yeah, so basically this stuff is telling your computer what to do, what to check, see if stuff matches. If it matches, it's okay. If it doesn't match, it's not, depending on whether it should match or not, and that's defined by the code. That's what we're doing here, right?

8:09

Sjors Provoost Yeah, but notice that you don't have to check a signature.

8:11

Aaron van Wirdum Exactly.

8:11

Sjors Provoost You could just have a script that says, yeah, it's fine, just take it.

8:15

Aaron van Wirdum Yes. Or you could have a script that says you either need a valid signature or you need 34 invalid signatures.

8:27

Sjors Provoost Yeah, you can do weird things. Yes, very strange things.

8:31

Aaron van Wirdum Okay, so that's kind of the point we're getting at here, I think, right?

8:34

Sjors Provoost Yes.

8:35

Aaron van Wirdum The script's language is diverse enough to allow for weird stuff.

8:41

Sjors Provoost Yeah. And now the question is, if you're just sending money to yourself, you only need this very simple standard script that everybody's seen a million times. But let's say you're collaborating. You want to do a multisig. Now, there's actually an instruction to do multisig, but let's say that didn't exist. So one way you could do multisig is, say, the script we just explained with my public key in it or my public key hash, and then the script we just explained with your public key hash. Just in sequence. So if that's executed, I will not repeat the process we did before, but you essentially start with those two public keys and two signatures on the stack, and you run both of these scripts in sequence, and then if both people signed, it's all good. So you have a poor man's... multisig.

9:26

Aaron van Wirdum Right.

9:26

Sjors Provoost But if I'm evil or stupid, I could make this a rekt-man multisig. Sorry for the joke. And that is achieved by, in the middle, inserting an opcode called OP_RETURN.

9:38

Aaron van Wirdum Right.

9:38

Sjors Provoost And the OP_RETURN code basically says, all right, stop evaluating this program. You're done. Now, if I had an electronic lawyer that wanted to check that this multisig... is what it says it does, or in fact, if you have that lawyer, your lawyer might say, well, I see that my signature is being checked, and whatever the rest of the script does, I don't care, but my signature is being checked, so I'm happy with this. But of course, you shouldn't be happy with this, so your electronic lawyer should see that OP_RETURN statement and warn you. But the problem is there's a trillion ways in which scripts can go wrong, and that is why you need a standardized... way of dealing with these scripts and that's where Miniscript really comes in.

10:18

Aaron van Wirdum I'll read a little fragment from Andrew Poelstra who I interviewed a long time ago when I wrote an article on this. So the example he gave was, and I'm not going to pretend like I understand everything he said in this quote, but that was sort of the point of the quote for me, that it was you know, exemplifying the complexity of potential ways to mess around with script. Anyways, so the quote was: "There are opcodes in Bitcoin script which do really absurd things like interpret the signature as a true false value, branch on that, convert that Boolean to a number, and then index into the stack and rearrange the stack based on that number. And the specific rules for how it does this are super nuts." You probably actually follow that perfectly.

11:02

Sjors Provoost No.

11:03

Aaron van Wirdum Oh, you don't either.

11:04

Sjors Provoost I kind of do, but the analogy would be you have this stack of plates and you take a hammer and you smash one and then you confuse two and you paint one red and then it still works if you do it correctly. It's completely absurd.

11:17

Aaron van Wirdum Right. Or another analogy I think you gave before this recording, correct me if this is not the right way of explaining this analogy, but it's like you have a contract. And it says, you know, you're buying this house and these are all the conditions. And then there's a small letter which says, unless there's like two commas in a row somewhere in this contract, in which case all your base are belong to us.

11:39

Sjors Provoost Exactly. Except that this will be like the law, right? So the contract doesn't say that at all. It's just that the law that's in this country has that stupid rule. Like if there are two commas in a contract, you're giving away your money. That's the script interpreter of all the consensus rules, which are quite complicated.

11:55

Aaron van Wirdum Yes. Okay, so I think we've now broken down the problem with Script. It's... It's a shitty programming language, or at least it's easy to make mistakes or hide bugs in there and make all sorts of complex arrangements that people might or might not notice, and then your money goes to places where you don't want it to go. Is that the best way? That's the summary, right?

12:18

Sjors Provoost Yeah, and we've seen in other projects how bad things can go if you have a very complicated language that does things you're not completely expecting.

12:27

Aaron van Wirdum Are you referring to a project that rhymes on Metherium? I think we're on the same page. Okay, so solutions. We're getting to the solution part of the story.

12:40

Sjors Provoost So what you're basically doing, what Miniscript is doing, is it's taking certain example scripts, so a sequence of opcodes, and it lists, I think, about 20 of them. 20 templates.

12:53

Aaron van Wirdum This is Miniscript.

12:53

Sjors Provoost Yes. It lists a few dozen templates. It does not use all of the available Bitcoin script. It uses a subset of it.

13:01

Aaron van Wirdum Right. So let's say Bitcoin script has 100 tools. I have no idea if it's close to 100. I'm just throwing out a number. The Miniscript. It says, okay, let's throw out 80 of these because these are just going to cause a mess. And let's keep 20. And that way it's going to be a little bit simpler for everyone. Right. Is that right?

13:17

Sjors Provoost Well, so if Bitcoin script uses an alphabet, essentially, and Miniscript has a set of words. So it's not a subset of the alphabet, but it's a subset of words.

13:28

Aaron van Wirdum I see. Okay. That's a better analogy.

13:30

Sjors Provoost So there's certain patterns of opcodes that you're allowed to use. And if you use those patterns in the way they describe.

13:37

Aaron van Wirdum So this double comma is removed now.

13:41

Sjors Provoost Yeah, there's no double comma. Or there is, but it is used in a very precise way. So basically Miniscript, yeah, it removes some of the foot guns, but it also allows you to do very cool stuff safely. In particular, it lets you do things like and. So you can say condition A must be true and condition B must be true. And you can do things like or. And whatever is inside the or or inside the and can be arbitrarily complex. So with Bitcoin script, you have if and else type of statements. But if you're not careful, those if and else statements will not do what you think they're going to do. Because there's

14:21

Aaron van Wirdum more complexity hidden after the if.

14:23

Sjors Provoost Yes, exactly. And the mini script, basically, the templates make sure that you're only doing things that are actually doing what you think they're doing. So they really contain it. And that allows you to do nice things. So let's say you're... You're a company and you offer a semi-custodial wallet solution where you have one of the keys of the user. And the user has the other, has two keys, for example. So you don't have a majority of the keys. And maybe there's a five-year timeout where you do have control in case the user dies. Something like that, right?

14:56

Aaron van Wirdum Yeah, like a multisig kind of setup.

14:58

Sjors Provoost And so normally when you set up a multisig, the way you kind of set it up is everybody gives their key, their master key, their XPUB, for example, and you create a very simple script that has three keys and three people sign. But the problem is because you're a big business that offers a service, you have some really complicated internal accounting department, and you maybe want to have five different signatures by specific people in God knows what complexity. But you don't want to...

15:24

Aaron van Wirdum Yeah, you have like five members on the board and you want three of them to sign. Yeah. Unless maybe the CEO gets some sort of special right from... two of the board members, and there's

15:38

Sjors Provoost a code hidden in an envelope inside the nuclear suitcase that has an override. Exactly.

15:42

Aaron van Wirdum Exactly. There's like all sorts of complex stuff you can do with it. And that should... all the complex stuff should count as one key. Like, you... right, that's where you're getting at. Like, you don't really care how the complex stuff is solved.

15:53

Sjors Provoost Yeah.

15:54

Aaron van Wirdum That's up to the company. You figure it out company.

15:56

Sjors Provoost Yeah.

15:57

Aaron van Wirdum As long as it's just... it's clear to us that it's only one key, however you do it.

16:02

Sjors Provoost Exactly. Now, the problem with that is if I gave you... You can do that with script or with taproot, but how do I, as a customer, know... Like I would have to hire my own electronic lawyer to check that script of yours that it doesn't have any of these double comma little gimmicks in it. And if only there was a way you could check that. And Miniscript is done such that you can check that as long as the script that you're getting is compatible with Miniscript. Because Miniscript to normal script is two ways. So you can take any Miniscript, turn it into a normal script. You can take any normal script. and turn it into a mini script. Well, unless it doesn't match, right? If there's codes in it that don't apply, then it just doesn't compile or doesn't translate.

16:45

Aaron van Wirdum Sure.

16:46

Sjors Provoost So, and if you can turn something into a mini script, then you can analyze it using all sorts of tools. that can analyze any miniscript.

16:54

Aaron van Wirdum Right.

16:55

Sjors Provoost So what you would have is every wallet out there could have a Miniscript interpreter and the interpreter could show you a little pie chart and saying, you are this one piece of the pie and there's this other piece of the pie that is really complicated, but you don't have to worry about it. It's not going to do anything sneaky.

17:10

Aaron van Wirdum Right. That's good.

17:12

Sjors Provoost That's excellent.

17:13

Aaron van Wirdum Yeah. One of the things that I... So, I mean, we're making a podcast, so we can't actually show this, unfortunately. But Poelstra, for example, he's drawn this out. You can actually draw out what a contract would look like. Apparently, that's not really possible with a script. All of this was news to me.

17:30

Sjors Provoost You can. It's just horrible, manual, tedious... Yeah. I mean, imagine the people from Liquid, for example, that have a 13 of five multi-sig with all sorts of fallbacks.

17:41

Aaron van Wirdum Yeah. Okay. So that's probably drawn out at some point. Yeah. But with miniscript, it's actually fairly simple to draw it out. Yeah. And you can show this to a CEO who has no idea about scripts or miniscripts. You can just look at the picture and figure, hey, I, yep, that's sort of what I want the blue and red squares to be. And if these keys work out like this, then it seems like a good idea to me.

18:06

Sjors Provoost Exactly.

18:07

Aaron van Wirdum So that's actually possible now.

18:09

Sjors Provoost Yeah, with Miniscript. But wait, there's more.

18:12

Aaron van Wirdum There's more.

18:13

Sjors Provoost And that's called the policy language.

18:16

Aaron van Wirdum No, I want to ask you something else first.

18:19

Sjors Provoost Okay.

18:20

Aaron van Wirdum With Miniscript, I do think there are, strictly technically speaking, there are some limitations. Like there is stuff you can't do with Miniscript, right?

18:30

Sjors Provoost Yes.

18:32

Aaron van Wirdum But as far as I understand, these are stuff no one actually does anyways.

18:35

Sjors Provoost Well, that's not necessarily true. So the thing is, but we have to go to policy language before I can explain that.

18:43

Aaron van Wirdum Oh, we do?

18:43

Sjors Provoost Yes.

18:44

Aaron van Wirdum Did you have this in mind already?

18:46

Sjors Provoost So, yeah. So let me just quickly explain.

18:49

Aaron van Wirdum You've got this episode planned out way better than I do.

18:50

Sjors Provoost Well, to understand why you might want to do really complicated stuff, I need to explain what the policy language is.

18:55

Aaron van Wirdum Yes. Okay, go for it.

18:56

Sjors Provoost So a policy language. poorly named, or maybe not poorly named, is a way to express your intentions. So for example, say I want two signatures. And this can be translated or compiled, I think is the better term, to Miniscript. And the nice thing is...

19:16

Aaron van Wirdum Okay, so to be clear, the policy language is the stuff, like if someone like you, Sjors, you're building a wallet, I don't know, you're doing something on your computer, improving Bitcoin, then you're typing and the stuff that comes out of your fingers is policy language. And then you actually compile that to script later on.

19:34

Sjors Provoost Yeah. I mean, you could just write the script directly or you could write the mini script directly. But the nice thing about writing the policy language is that you can have a compiler that can be very smart. So a simple policy language might be just give me two of two signatures and the policy language will probably convert that to op multisig. Or we'll convert that to multisig in Miniscript. And multisig in Miniscript is just op multisig. So that's super trivial.

20:02

Aaron van Wirdum Yeah. Okay. So whoever wrote the policy language, and now Peter Wuille, for example, wrote the policy language for this. It was him. It was his brain, basically. He figured out all the best ways to compile this policy language into Miniscript, right? Like he must have somehow figured it out.

20:20

Sjors Provoost Yeah, he wrote a compiler.

20:22

Aaron van Wirdum See, I don't know anything about this stuff.

20:24

Sjors Provoost That's okay. So basically, you write a policy language. It's like a higher-level programming language. So if you have a higher-level programming language, like, I don't know, BASIC, you can say go to five. I don't know if you've ever worked with BASIC.

20:39

Aaron van Wirdum Sjors, I can't code Hello World. Isn't that clear to you right now?

20:44

Sjors Provoost Well, I mean, Hello World.

20:45

Aaron van Wirdum I've coded Hello World once, but that's pretty much how limited I am.

20:48

Sjors Provoost Okay, but what language did you code Hello World in?

20:50

Aaron van Wirdum I don't remember.

20:52

Sjors Provoost That's amazing. Anyway, so what happens is usually when you see a programmer looking at a screen, you see something that looks like English, like with words like for and next and yadda yadda. But eventually the machine is just reading bits and bytes.

21:06

Aaron van Wirdum Sure. No, I understand that part.

21:07

Sjors Provoost So the bits and bytes are very close to what Bitcoin opcodes look like. They're very low level. They're very instructions like put this on the stack, take that away from the stack. And the mini script is essentially the same. It's just only a subset of it. But it's slightly more readable, but it's still extremely low level. The policy language is slightly higher level. So what you do is you start at the higher level, which is easier for a programmer to write. And then a computer looks at that high level language and says, how can I write this into low level machine readable stuff as efficiently as possible?

21:40

Aaron van Wirdum Sure.

21:41

Sjors Provoost In the case of the multisig thing, I might say, I just want two out of two signatures. I don't care how you do that. Then the compiler knows that there are multiple ways to do that.

21:50

Aaron van Wirdum Okay, but how does the compiler know this? I hope there's listeners out there that know as little about this as I do, so they might learn something. How does the compiler know this?

21:59

Sjors Provoost So disclaimer, I don't think I've ever written a compiler. I'm not that cool. But generally, compilers know because somebody wrote the compiler.

22:07

Aaron van Wirdum But that was my point. It must have come from Peter Wuille's brain in this case.

22:11

Sjors Provoost Of course, yes. Everything comes out of Peter Wuille's brain.

22:13

Aaron van Wirdum There we go.

22:15

Sjors Provoost But basically, the compiler knows, okay, there's maybe two or three ways to do this, to execute this intention. And then the question is, which of the three am I going to pick? Well, then it depends on the transaction weight and the fees that you might be involved. But also you can tell it, okay, I think most of the time it's condition A, but only 10% of the time it's condition B. And then the compiler can try. condition A nine times and condition B one time, and then figure out what the expected fee is. So it can optimize for typical use cases, worst case scenarios, all these things. And it can then spit out a Bitcoin script or a mini script that then becomes a Bitcoin script.

22:53

Aaron van Wirdum Yes, the compiler figures out the best way to do something.

22:56

Sjors Provoost And in very practical terms, another thing it could do, I don't know if it can already do that, is you have SegWit scripts now, but we'll hopefully have Taproot, which can put things in a Merkle tree. So your compiler could figure out where to put stuff in the Merkle tree. You don't have to worry about how to build the Merkle tree.

23:11

Aaron van Wirdum Right, yes.

23:12

Sjors Provoost So it can do all sorts of things. So you start at the policy language, and then you write Miniscript, and that goes into...

23:19

Aaron van Wirdum Okay, so that's what a compiler is. The policy language you use, you put it into the compiler, and then Miniscript comes out of it, which is, in a way, script.

23:29

Sjors Provoost Yes, I think the technical term for going from Miniscript to script is transpiling, which basically is like a one-on-one thing. You can do it in two directions. So you can go from Miniscript to script, from script to miniscript, but you cannot go back to a policy language. Well, you can guess the policy language.

23:46

Aaron van Wirdum Okay, you can. Yeah, I guess so, yes. I understand that. And then getting back to... Are we ready to get back to my question about the limitations?

23:55

Sjors Provoost Absolutely.

23:56

Aaron van Wirdum Okay, so now there are some limitations. when you're using, I guess, this policy language or miniscripts in general?

24:02

Sjors Provoost Yes.

24:03

Aaron van Wirdum But these are limitations that no one actually suffers from, is how I understood it.

24:09

Sjors Provoost Not necessarily. I mean, ideally, yes. But in practice, some scripts or some policies might be very complicated. And there would be infinite ways to execute these in Bitcoin script. And because of all these weird double comma foot guns that are in Bitcoin script, sometimes that's an advantage. Sometimes you can write something really efficiently in Bitcoin script. that is just really horrible if you objectively look at it, but it is really fast or really fee efficient. And in fact, I believe Lightning uses that, the way they sometimes deal with time locks or with hashes. Or nonces. There are some tricks in Lightning, I believe, that you cannot do a miniscript, or at least you could not do a miniscript. Maybe you can now.

24:50

Aaron van Wirdum Okay.

24:50

Sjors Provoost So there are some optimizations where, like what Poelstra said, like, oh, you do some weird switching of the stack and you interpret things not the way they were, you know, you put a public key on it, but you interpret it as a number. Those kind of weird tricks. Those might be very hard to reason about, but a human might be able to do it. But the Miniscript compiler would not do it, which means you end up with longer. potentially longer Lightning scripts if you do not have all the whistles and bells in it. So it's possible that Miniscript would be expanded if there is some other optimal way to do it. But you have to be careful because you really want to make sure there's nothing in Miniscript that brings back those scary properties of the underlying language.

25:33

Aaron van Wirdum Well, to be clear, in case this isn't clear to anyone, miniscripts is an addition to what there is already. Like, script is going nowhere. Bitcoin still uses script, and that's the way it's going to be. It's just this is an extra tool for people who want to use that.

25:47

Sjors Provoost And in fact, it's not a consensus change at all.

25:49

Aaron van Wirdum No, it's nothing in that.

25:50

Sjors Provoost It's a tool that you can use or not use. Like, don't worry. It's not Blockstream dominating the script here.

25:57

Aaron van Wirdum Yes. Okay, so we mentioned Peter Wuille has this policy language. I know this is very fresh and you probably haven't looked at it very much, but Nadav Ivgi also wrote a policy language. You haven't studied that yet.

26:10

Sjors Provoost I have not yet.

26:11

Aaron van Wirdum So I thought that would be a cliffhanger.

26:13

Sjors Provoost That would be a cliffhanger.

26:14

Aaron van Wirdum You like the cliffhanger. So that will be a cliffhanger for another episode.

26:17

Sjors Provoost Or never.

26:18

Aaron van Wirdum Or maybe we'll have one of those Lost...

26:21

Sjors Provoost But I can tell you from what I know about the policy language is that... And you're still some steps away from having a practical tool where you and I can set up a very complicated multisig wallet. There's all sorts of questions you want to answer, like how exactly do you do this setup? What are you emailing to each other? Are you emailing your keys or are you emailing something a little bit more abstract that you agree on first and then you exchange keys? Those very practical things are not solved inside a miniscript.

26:49

Aaron van Wirdum Let me at least mention... It's called Minsc. So his policy language is called Minsc.

26:56

Sjors Provoost Okay.

26:57

Aaron van Wirdum Okay. I'm afraid we can't give you any more info about Minsc yet.

27:01

Sjors Provoost Well, I know Minsk with a K is a city, but I think it's with a C.

27:05

Aaron van Wirdum Minsc with a C. Yeah, that's some extra info. All right. Is this the end of our episode? Did we cover everything we needed to cover from Miniscript?

27:16

Sjors Provoost I hope so.

27:17

Aaron van Wirdum It was maybe slightly messy, so let's sum it up. Miniscript is a subsection. No, you called it a template?

27:23

Sjors Provoost Yes, it's a template of script pieces.

27:25

Aaron van Wirdum Even the summary is getting messy now.

27:27

Sjors Provoost So basically, Bitcoin script is like an alphabet, essentially, just different letters that have different meanings. And you could see Miniscript is a set of words. Not really words, because you can put things between the words. maybe words and brackets and commas. That's what Miniscript is. And then the policy language is the thing that can be converted to Miniscript. It's a bit more high level.

27:48

Aaron van Wirdum And there are several of those apparently by now.

27:51

Sjors Provoost Yes, exactly. Because Miniscript, it has to be set in stone, I guess, sort of, because you want to do all the safety checks on it. But then just like you can have different programming language, you can have different policy languages.

28:04

Aaron van Wirdum Yes. So if you're into Bitcoin programming, This is what you want to study. This is what you want to look at.

28:10

Sjors Provoost If you're into Bitcoin programming, the rabbit hole is massive and pick something. There's a talk by Andrew Poelstra.

28:17

Aaron van Wirdum This one is probably pretty good though, right?

28:20

Sjors Provoost Yeah. So there's a talk by Andrew Poelstra from Advancing Bitcoin, not the conference, but the meetup before it, the BitDevs London, where he talks for two hours about all the problems with regular script and why he hates things. And that's just... He said he was going to do it in 20 minutes, and I think he still didn't cover everything. I don't think that's the best place to start.

28:41

Aaron van Wirdum He's still on stage.

28:42

Sjors Provoost He's still on stage out there, just going through it.

28:46

Aaron van Wirdum All right, this was our episode of Miniscript, I think.

28:48

Sjors Provoost Yep, so thank you. Should I say thank you?

28:51

Aaron van Wirdum I forgot how we closed our episode.

28:54

Sjors Provoost I think I say thank you for listening to the Van Wirdum Sjorsnado.

28:58

Aaron van Wirdum There we go.