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

00:00:20.460 --> 00:00:22.560
<v Aaron van Wirdum>Live from Utrecht this is Bitcoin

00:00:22.560 --> 00:00:23.640
<v Sjors Provoost>Explained.

00:00:23.640 --> 00:00:25.060
<v Aaron van Wirdum>Hey Sjors.

00:00:25.060 --> 00:00:25.800
<v Sjors Provoost>Hello.

00:00:25.800 --> 00:00:31.280
<v Aaron van Wirdum>we're back and today we're gonna talk about multisig and cool

00:00:31.280 --> 00:00:32.120
<v Aaron van Wirdum>MuSig.

00:00:32.120 --> 00:00:33.500
<v Sjors Provoost>Music?

00:00:33.700 --> 00:00:39.420
<v Aaron van Wirdum>That pun is too easy even for our show Sjors. Okay, but first of all

00:00:39.610 --> 00:00:45.070
<v Aaron van Wirdum>you want we gave you your special part of the show I'll give you the…

00:00:45.610 --> 00:00:46.850
<v Sjors Provoost>Are you going to do the song again?

00:00:46.970 --> 00:00:52.590
<v Aaron van Wirdum>Of course. Sjors stacks sats. Sjors stacks sats. Sjors stacks sats.

00:00:53.190 --> 00:00:56.890
<v Sjors Provoost>And of course our editor will run it through the auto tune so that it sounds

00:00:56.890 --> 00:01:02.790
<v Sjors Provoost>cool. Yeah. So we've got one from Slim Shady. And he sends us 101

00:01:02.790 --> 00:01:06.210
<v Sjors Provoost>sats for the tune. And another one.

00:01:06.310 --> 00:01:07.470
<v Aaron van Wirdum>I'm not even getting the money.

00:01:08.180 --> 00:01:13.160
<v Sjors Provoost>You're not. And from Vake, 6,000 sats. Learning a lot from each episode.

00:01:14.080 --> 00:01:14.600
<v Sjors Provoost>So.

00:01:15.320 --> 00:01:17.420
<v Aaron van Wirdum>That's good. Glad to hear that.

00:01:18.910 --> 00:01:22.190
<v Aaron van Wirdum>And congratulations on the money.

00:01:23.860 --> 00:01:25.500
<v Aaron van Wirdum>Ready for the rest of the episode?

00:01:25.860 --> 00:01:26.380
<v Sjors Provoost>yes

00:01:26.380 --> 00:01:31.300
<v Aaron van Wirdum>okay so we're going to discuss multisig which is of course a topic, we've

00:01:31.300 --> 00:01:35.780
<v Aaron van Wirdum>mentioned probably many times by now but we've never done a full episode on

00:01:35.780 --> 00:01:40.140
<v Aaron van Wirdum>multisig so that's what we're doing today. and we're going to discuss sort of how

00:01:40.140 --> 00:01:45.600
<v Aaron van Wirdum>multisig has evolved over the years so the different ways of doing multisig all

00:01:45.600 --> 00:01:49.220
<v Aaron van Wirdum>of which are still possible I guess right? we don't you know we don't remove

00:01:49.220 --> 00:01:53.040
<v Aaron van Wirdum>options from Bitcoin, so every option that we're going to discuss is actually

00:01:53.040 --> 00:01:53.740
<v Aaron van Wirdum>available today.

00:01:54.230 --> 00:01:56.590
<v Sjors Provoost>Well, some of them are not, but we'll get to those.

00:01:56.910 --> 00:02:01.110
<v Aaron van Wirdum>I guess at the very end we're going to discuss some future potential ways to do

00:02:01.110 --> 00:02:02.830
<v Aaron van Wirdum>multisig. Is that what you're referring to or not?

00:02:03.250 --> 00:02:05.010
<v Sjors Provoost>No, I was referring to some early bugs.

00:02:05.630 --> 00:02:10.270
<v Aaron van Wirdum>Oh, okay. I guess I'll hear about that in a minute then, as well you are the listener.

00:02:10.890 --> 00:02:14.010
<v Sjors Provoost>Yeah, and we're also not going to talk about the combination of multisig and

00:02:14.010 --> 00:02:16.650
<v Sjors Provoost>timelocks and all these kind of things you can do. We're going to talk about

00:02:16.650 --> 00:02:21.930
<v Sjors Provoost>pretty much the opcode of multisig and its successor in Taproot.

00:02:22.540 --> 00:02:27.500
<v Aaron van Wirdum>yeah there are some tie-ins with our previous episode that's also where we got

00:02:27.500 --> 00:02:32.380
<v Aaron van Wirdum>the idea to do this episode because in our previous episode on P2SH we kind of

00:02:32.380 --> 00:02:37.340
<v Aaron van Wirdum>touched on some of this stuff I don't think the previous episode is required

00:02:37.340 --> 00:02:40.320
<v Aaron van Wirdum>listening for this episode but it might help Right, Sjors?

00:02:40.320 --> 00:02:41.220
<v Sjors Provoost>Yeah, it's not.

00:02:41.220 --> 00:02:47.220
<v Aaron van Wirdum>Yeah, okay, so first of all let's let's start at the beginning as always, in,

00:02:47.220 --> 00:02:53.130
<v Aaron van Wirdum>very general terms what is multisig? Do you even want to...

00:02:53.290 --> 00:02:58.730
<v Sjors Provoost>Yeah, the idea is that you can create a transaction that can be signed using not

00:02:58.730 --> 00:03:04.330
<v Sjors Provoost>just one key, but either multiple keys or one out of keys. So

00:03:04.330 --> 00:03:08.330
<v Sjors Provoost>you might say, okay, there's three possible keys that I can sign with, three of

00:03:08.330 --> 00:03:12.430
<v Sjors Provoost>my different hardware wallet devices, and I only need to provide two of them or

00:03:12.430 --> 00:03:15.720
<v Sjors Provoost>one of them. Or three of them that's what multisig does.

00:03:15.720 --> 00:03:19.700
<v Aaron van Wirdum>Yeah, I think in technical terms usually you're the one using the technical terms

00:03:19.700 --> 00:03:24.880
<v Aaron van Wirdum>and then I try to dumb it down but in technical terms it's M of M or M of N am I

00:03:24.880 --> 00:03:25.340
<v Aaron van Wirdum>saying that's right?

00:03:25.340 --> 00:03:26.140
<v Sjors Provoost>Yeah, M of N.

00:03:26.750 --> 00:03:32.950
<v Aaron van Wirdum>Or N of N right? that's also so N of N would be I mean M of N means that…

00:03:32.950 --> 00:03:38.850
<v Sjors Provoost>N of M. N of N means that M is equal to N. But yes

00:03:38.850 --> 00:03:40.430
<v Sjors Provoost>we then you call it N of N.

00:03:42.310 --> 00:03:47.330
<v Aaron van Wirdum>Anyways, it means you can have a number of potential keys to sign with, and then

00:03:47.330 --> 00:03:51.370
<v Aaron van Wirdum>another equal or smaller number of these keys.

00:03:51.750 --> 00:03:54.170
<v Sjors Provoost>We're making this more confusing. Yes, and the cryptographers who try to explain

00:03:54.170 --> 00:03:57.410
<v Sjors Provoost>this stuff like to write things down, so they don't care that the word M is

00:03:57.410 --> 00:03:58.690
<v Sjors Provoost>pronounced almost the same as N.

00:03:59.030 --> 00:04:04.170
<v Aaron van Wirdum>Right. Okay, well, I think everyone knows what multisig is anyways, so we don't

00:04:04.170 --> 00:04:07.750
<v Aaron van Wirdum>have to really get into that. Well, okay, one more thing. Why would people want

00:04:07.750 --> 00:04:09.870
<v Aaron van Wirdum>to use this? Do you want to give some examples of that?

00:04:10.610 --> 00:04:16.130
<v Sjors Provoost>Yeah, I mean, the initial use case was a thought of use case was escrow. So the

00:04:16.130 --> 00:04:20.130
<v Sjors Provoost>idea would be that you would send money to a third party, but then there would be

00:04:20.130 --> 00:04:24.330
<v Sjors Provoost>an escrow agent in the middle who would hold the money for you. And the idea is

00:04:24.330 --> 00:04:30.310
<v Sjors Provoost>that this escrow person or company would have one key and you, the sender, has

00:04:30.310 --> 00:04:34.200
<v Sjors Provoost>one key and me, the recipient, has another key. And then you need two out of

00:04:34.200 --> 00:04:39.480
<v Sjors Provoost>three. So I send it to the escrow. And then if we both agree, we both sign and it

00:04:39.480 --> 00:04:43.460
<v Sjors Provoost>goes away from the escrow. The escrow agent is not necessary. If we disagree,

00:04:44.020 --> 00:04:47.840
<v Sjors Provoost>then the escrow agent will either, you know, will provide a signature either to

00:04:47.840 --> 00:04:49.820
<v Sjors Provoost>send it back or to send it forward.

00:04:50.690 --> 00:04:56.010
<v Aaron van Wirdum>Yeah, or another way to use this is something we've discussed in a previous

00:04:56.010 --> 00:05:01.930
<v Aaron van Wirdum>episode about... smart contracts maybe I think where we could we can sort of

00:05:01.930 --> 00:05:07.590
<v Aaron van Wirdum>construct proto smart contracts using this where we for example bet on I think

00:05:07.590 --> 00:05:11.450
<v Aaron van Wirdum>the example we used was the winner of the world cup and then we have a neutral

00:05:11.450 --> 00:05:15.250
<v Aaron van Wirdum>party and we all the three of us have a key you and I bet.

00:05:15.250 --> 00:05:18.750
<v Sjors Provoost>yeah that was in the episode about discreet log contracts so you can do fairly…

00:05:18.750 --> 00:05:22.750
<v Sjors Provoost>you can do Lightning obviously that also uses multisig so but the initial use

00:05:22.750 --> 00:05:26.250
<v Sjors Provoost>case I think was escrow Because that's sort of what people were talking about in

00:05:26.250 --> 00:05:30.450
<v Sjors Provoost>the comments on GitHub. and even in the source code it was kind of referring to

00:05:30.450 --> 00:05:32.550
<v Sjors Provoost>escrow but obviously you can do more with it.

00:05:32.550 --> 00:05:37.910
<v Aaron van Wirdum>yeah well another very basic example is for example you split

00:05:37.910 --> 00:05:43.770
<v Aaron van Wirdum>your own funds across multiple keys right so you sent your own funds you you

00:05:43.770 --> 00:05:48.910
<v Aaron van Wirdum>store you save your money your Bitcoin in a multisig address of your own and you

00:05:48.910 --> 00:05:52.110
<v Aaron van Wirdum>for example have three keys and you keep these three keys on three different

00:05:52.110 --> 00:05:56.890
<v Aaron van Wirdum>machines could be three hardware wallets for example and you store these hardware

00:05:56.890 --> 00:06:01.390
<v Aaron van Wirdum>wallets in different locations that way a hacker would have to steal two of your

00:06:01.390 --> 00:06:05.950
<v Aaron van Wirdum>three hardware wallets in order to even have a chance to get your funds. yeah for

00:06:06.140 --> 00:06:10.640
<v Aaron van Wirdum>example that that's another or another example would be I'll after this example

00:06:10.640 --> 00:06:16.430
<v Aaron van Wirdum>we'll move on but another other example would be three people want to or two or

00:06:16.430 --> 00:06:22.070
<v Aaron van Wirdum>whatever number of course they want to just store funds collectively and only if

00:06:22.070 --> 00:06:27.370
<v Aaron van Wirdum>some subset of them agree to spend the funds they can do it so for example a

00:06:27.370 --> 00:06:32.390
<v Aaron van Wirdum>board of a company that consists of you know three board members and they agree

00:06:32.390 --> 00:06:35.910
<v Aaron van Wirdum>that two of them will have to sign off to spend money then they can set up a two

00:06:35.910 --> 00:06:39.690
<v Aaron van Wirdum>of three multisig address so that would be another example and there's plenty of

00:06:39.690 --> 00:06:43.090
<v Aaron van Wirdum>other examples but we won't bore you anymore with that we'll get to the meat of

00:06:43.090 --> 00:06:48.420
<v Aaron van Wirdum>the episode So it's yours, multisig. Multisig has been in Bitcoin since the very

00:06:48.420 --> 00:06:49.380
<v Aaron van Wirdum>beginning, I think, right?

00:06:49.740 --> 00:06:52.620
<v Sjors Provoost>Yeah. I thought you were going to make a pun about raw meat.

00:06:53.400 --> 00:06:55.120
<v Aaron van Wirdum>Feel free to make it. What's the pun?

00:06:55.320 --> 00:07:00.200
<v Sjors Provoost>Well, the original version is called raw multisig. Or actually, it's called bare

00:07:00.200 --> 00:07:00.660
<v Sjors Provoost>multisig.

00:07:00.660 --> 00:07:02.140
<v Aaron van Wirdum>There's some potential for a pun then.

00:07:02.400 --> 00:07:03.380
<v Sjors Provoost>I think I wrote it down incorrectly.

00:07:04.930 --> 00:07:09.310
<v Aaron van Wirdum>You're right. Let's get to the raw meat, raw multisig of the episode. It's yours.

00:07:11.120 --> 00:07:15.480
<v Aaron van Wirdum>So it's been in Bitcoin since the very beginning. Satoshi implemented multisig.

00:07:15.720 --> 00:07:19.220
<v Sjors Provoost>Yeah. So from the beginning, it was an op code. So that's one of the commands

00:07:19.220 --> 00:07:23.430
<v Sjors Provoost>that you can put in a script. And it was just called OP_MULTISIG. And it's just

00:07:23.430 --> 00:07:29.310
<v Sjors Provoost>there, OP_CHECKMULTISIG. And this was, well, the idea was that this you

00:07:29.310 --> 00:07:33.810
<v Sjors Provoost>would put as the recipient, you would provide the script saying OP_MULTISIG. And

00:07:33.810 --> 00:07:37.450
<v Sjors Provoost>then you would also provide two or three or whatever keys. And you would specify

00:07:37.450 --> 00:07:43.430
<v Sjors Provoost>the threshold. So you would say two and then you would list three keys. That

00:07:43.430 --> 00:07:46.650
<v Sjors Provoost>would mean you need two out of three signatures to satisfy the script.

00:07:46.910 --> 00:07:47.210
<v Aaron van Wirdum>Right.

00:07:47.430 --> 00:07:51.430
<v Sjors Provoost>And there was no address format for this to be able to communicate this. So we

00:07:51.430 --> 00:07:56.030
<v Sjors Provoost>talked about that with P2SH because you, the sender, will have to put that script

00:07:56.030 --> 00:08:00.170
<v Sjors Provoost>on the blockchain. So that means if you wanted to do a 20 out of 20 multisig, the

00:08:00.170 --> 00:08:03.410
<v Sjors Provoost>sender would have to make a very long transaction and pay the fees for your

00:08:03.410 --> 00:08:04.230
<v Sjors Provoost>complicated setup.

00:08:05.030 --> 00:08:10.470
<v Aaron van Wirdum>Yeah, that was one of the problems, right? So I'm the one… I want to receive

00:08:10.470 --> 00:08:16.380
<v Aaron van Wirdum>the coins in a specific way but now you Sjors,

00:08:16.380 --> 00:08:20.380
<v Aaron van Wirdum>who are sending the money to me you have to pay for that rather than me having to

00:08:20.380 --> 00:08:24.040
<v Aaron van Wirdum>pay for that was one of the exact problems with the original multisig.

00:08:24.040 --> 00:08:28.400
<v Sjors Provoost>yeah so and and that and the fact that there's no standard address format for it,

00:08:28.400 --> 00:08:32.760
<v Sjors Provoost>although that of course that could be invented Now, the more interesting part is

00:08:32.760 --> 00:08:37.980
<v Sjors Provoost>that originally this had no limit. So you could, at least from a consensus point

00:08:37.980 --> 00:08:41.340
<v Sjors Provoost>of view, I don't know about standardness. So standardness is what nodes will

00:08:41.340 --> 00:08:45.600
<v Sjors Provoost>relay to each other and what miners will mine by default. But consensus means

00:08:45.600 --> 00:08:49.820
<v Sjors Provoost>that even if it's in a block, you're going to check by less strict rules. And

00:08:49.820 --> 00:08:53.340
<v Sjors Provoost>there was no limit on the size of a multisig, as far as I know, in the consensus

00:08:53.340 --> 00:08:57.600
<v Sjors Provoost>rules. And this is a problem because verifying signatures...

00:08:57.600 --> 00:08:59.820
<v Aaron van Wirdum>So hang on, you could make a...

00:09:03.210 --> 00:09:08.930
<v Aaron van Wirdum>6,382 out of 18,723 multisig?

00:09:09.070 --> 00:09:12.470
<v Sjors Provoost>As far as I know, yes. There may have been a limit on the size of the transaction

00:09:12.470 --> 00:09:13.890
<v Sjors Provoost>itself, but that's it, yeah.

00:09:14.800 --> 00:09:15.560
<v Aaron van Wirdum>That's pretty good.

00:09:15.860 --> 00:09:16.960
<v Sjors Provoost>So that was pretty cool.

00:09:17.100 --> 00:09:18.320
<v Aaron van Wirdum>What's the problem? This sounds great.

00:09:18.540 --> 00:09:22.260
<v Sjors Provoost>Yeah, the problem is the way the script is evaluated, the way the blockchain

00:09:22.260 --> 00:09:25.640
<v Sjors Provoost>basically checks the validity of the script. And roughly this works as follows.

00:09:25.820 --> 00:09:31.750
<v Sjors Provoost>You take the pile of public keys. And then the person who spends it will have to

00:09:31.750 --> 00:09:35.670
<v Sjors Provoost>provide one or a whole pile of signatures. Now they have to be in the correct

00:09:35.670 --> 00:09:39.230
<v Sjors Provoost>sequence. So it's not a random order that would have been even worse, but they

00:09:39.230 --> 00:09:42.370
<v Sjors Provoost>have to be in the right sequence, but there could be gaps, right? So in the

00:09:42.370 --> 00:09:45.830
<v Sjors Provoost>simple example of one out of three, I'm providing one signature and there are

00:09:45.830 --> 00:09:51.290
<v Sjors Provoost>three public keys. Now, what the script does is it will look at the

00:09:51.290 --> 00:09:56.160
<v Sjors Provoost>signature and... It will look at the first key. It will see if the signature is

00:09:56.160 --> 00:09:59.920
<v Sjors Provoost>correct for that first key. If not, it will look at the second key. It will check

00:09:59.920 --> 00:10:02.760
<v Sjors Provoost>if the signature is correct for the second key. And if not, it will try the third

00:10:02.760 --> 00:10:07.550
<v Sjors Provoost>key. And if you have two out of three, it's a little bit more efficient. So it

00:10:07.550 --> 00:10:11.990
<v Sjors Provoost>will look at the first. If you have two signatures out of three, it will look at

00:10:11.990 --> 00:10:15.670
<v Sjors Provoost>the first signature using the algorithm I just described. And then if it finds a

00:10:15.670 --> 00:10:19.490
<v Sjors Provoost>match, it tosses that signature and that public key. And then it moves on to the

00:10:19.490 --> 00:10:22.670
<v Sjors Provoost>next one. So they do have to be in the correct order because otherwise it won't

00:10:22.670 --> 00:10:27.000
<v Sjors Provoost>find it. But it's still pretty slow because if you have a one out of a million

00:10:27.000 --> 00:10:33.080
<v Sjors Provoost>multisig, then you're going to try a million public keys before you find it.

00:10:33.870 --> 00:10:37.510
<v Aaron van Wirdum>Well, only if it's the very last one, right? You might get lucky. It might be the

00:10:37.510 --> 00:10:37.950
<v Aaron van Wirdum>first one.

00:10:38.210 --> 00:10:40.810
<v Sjors Provoost>Yeah, but if you're trying to attack Bitcoin, you make sure that Bitcoin does not

00:10:40.810 --> 00:10:41.250
<v Sjors Provoost>get lucky.

00:10:41.690 --> 00:10:46.910
<v Aaron van Wirdum>Right. And if it's the 6,852 out of

00:10:46.910 --> 00:10:52.850
<v Aaron van Wirdum>18,731, I guess the math gets very complicated. But the bottom

00:10:52.850 --> 00:10:55.890
<v Aaron van Wirdum>line is it will take your computer a long time to verify this.

00:10:56.510 --> 00:10:56.670
<v Sjors Provoost>Yeah.

00:10:56.830 --> 00:11:00.950
<v Aaron van Wirdum>It will just take a long time because it has to check for every key that's in

00:11:00.950 --> 00:11:05.250
<v Aaron van Wirdum>there. Whether the signature matches and then go on to the next one one.

00:11:05.250 --> 00:11:08.810
<v Sjors Provoost>Yeah, so there's a little bit of acceleration in there that it doesn't like you

00:11:08.810 --> 00:11:11.850
<v Sjors Provoost>can't you can't I think you cannot provide them in any order that would be really

00:11:11.850 --> 00:11:15.830
<v Sjors Provoost>Bad. yeah but still but it's still pretty bad yeah so it was bad enough that

00:11:15.830 --> 00:11:20.750
<v Sjors Provoost>Satoshi decided very quickly in 2010 to in september 2010,

00:11:21.640 --> 00:11:26.860
<v Sjors Provoost>to add a limit to say you can only have 20 as in 20 pub keys.

00:11:26.860 --> 00:11:31.360
<v Aaron van Wirdum>okay so it can be a one out of 20 or 20 out of 20 according to that.

00:11:31.360 --> 00:11:31.980
<v Sjors Provoost>Yes.

00:11:31.980 --> 00:11:33.260
<v Aaron van Wirdum>I guess that was a soft fork then?

00:11:33.360 --> 00:11:36.320
<v Sjors Provoost>Yes, it was that was one of the first soft forks

00:11:36.320 --> 00:11:41.980
<v Aaron van Wirdum>and it was a so that was a consensus rule implemented by Satoshi in Bitcoin to

00:11:41.980 --> 00:11:43.240
<v Aaron van Wirdum>limit the

00:11:44.640 --> 00:11:45.960
<v Aaron van Wirdum>size of multisig

00:11:45.960 --> 00:11:51.440
<v Sjors Provoost>Yeah, he did okay really two things but this was in version 0.3.13 for those who

00:11:51.440 --> 00:11:52.000
<v Sjors Provoost>want to look it up.

00:11:52.000 --> 00:11:53.380
<v Aaron van Wirdum>When was this did you mention this?

00:11:53.380 --> 00:11:57.320
<v Sjors Provoost>September 2010. So it was released in October 2020. so around the time of the one

00:11:57.320 --> 00:12:01.360
<v Sjors Provoost>megabyte limit too right? And this was introduced in his usual style so the

00:12:01.360 --> 00:12:05.300
<v Sjors Provoost>commit so the change that was made which is called something like clean up

00:12:05.300 --> 00:12:10.700
<v Sjors Provoost>various stuff and in it would be that critical change because if people saw what

00:12:10.700 --> 00:12:13.160
<v Sjors Provoost>the change was they would try and attack Bitcoin using it

00:12:14.140 --> 00:12:18.420
<v Aaron van Wirdum>Right. You say that's his usual way. That was Satoshi's usual way of

00:12:18.420 --> 00:12:21.560
<v Aaron van Wirdum>implementing, of changing the Bitcoin protocol, essentially.

00:12:21.820 --> 00:12:24.820
<v Sjors Provoost>He would basically say, well, from this block height, here are the new rules, and

00:12:24.820 --> 00:12:27.960
<v Sjors Provoost>that would be in the code. But if you didn't check the code, you wouldn't know

00:12:27.960 --> 00:12:30.620
<v Sjors Provoost>that the new rules came out there because he wouldn't announce it, or he might

00:12:30.620 --> 00:12:32.600
<v Sjors Provoost>later announce it, or other people would figure it out later.

00:12:32.880 --> 00:12:37.860
<v Aaron van Wirdum>Right. So he probably did this because he figured out that the unlimited multisig

00:12:37.860 --> 00:12:40.440
<v Aaron van Wirdum>thing was a problem for the reason you just mentioned.

00:12:40.660 --> 00:12:40.820
<v Sjors Provoost>Yep.

00:12:40.880 --> 00:12:43.970
<v Aaron van Wirdum>But he never actually explained that. He just... hit it in the code somewhere.

00:12:44.290 --> 00:12:47.110
<v Sjors Provoost>He may have. I didn't check if he did, but he usually didn't.

00:12:47.310 --> 00:12:47.390
<v Aaron van Wirdum>Right.

00:12:47.510 --> 00:12:51.310
<v Sjors Provoost>Or he sometimes didn't. So the other limit he also introduced is a per block

00:12:51.310 --> 00:12:55.270
<v Sjors Provoost>limit. And the idea there would be that there's a limited number of these

00:12:55.270 --> 00:13:01.060
<v Sjors Provoost>multisigs that you can have in a given block. This is called the ops limit.

00:13:01.060 --> 00:13:03.000
<v Sjors Provoost>And that's still there, although it's changed a bit.

00:13:03.720 --> 00:13:07.240
<v Aaron van Wirdum>Wait, so what's the limit, first of all, I guess?

00:13:07.400 --> 00:13:13.310
<v Sjors Provoost>The limit was, at the time, you could have 1,000... multisig transactions

00:13:13.310 --> 00:13:17.510
<v Sjors Provoost>in a single block, no matter how big they were. Because initially, you would get

00:13:17.510 --> 00:13:22.750
<v Sjors Provoost>20 points, essentially, for each multisig transaction in a block. And the limit

00:13:22.750 --> 00:13:27.690
<v Sjors Provoost>was 20,000 for the whole block. So if you had 1,000 multisig transactions, no

00:13:27.690 --> 00:13:32.010
<v Sjors Provoost>matter how small they were, that was the max you were allowed to put in a block.

00:13:32.150 --> 00:13:36.910
<v Sjors Provoost>And regular transactions counted as a score of 1. So a single-sig transaction

00:13:36.910 --> 00:13:40.310
<v Sjors Provoost>would give you 1 point. So you could have 20,000 single-sig transactions in a

00:13:40.310 --> 00:13:44.150
<v Sjors Provoost>block. or a thousand multisig transactions or some combination

00:13:44.150 --> 00:13:50.020
<v Aaron van Wirdum>so what happens if there's a thousand multisig transactions in waiting in the

00:13:50.020 --> 00:13:53.920
<v Aaron van Wirdum>mempool say and now you want to send me a multisig transaction you're just out of luck

00:13:53.920 --> 00:13:56.040
<v Sjors Provoost>No, the mempool can have as many as you want

00:13:56.040 --> 00:13:58.240
<v Aaron van Wirdum>Yeah, but it's not going to be included in the block.

00:13:58.240 --> 00:13:59.400
<v Sjors Provoost>no it'll go into the next block

00:14:01.510 --> 00:14:04.430
<v Sjors Provoost>So miners have to be careful when they create a block that they don't violate

00:14:04.430 --> 00:14:06.690
<v Sjors Provoost>this rule, but as long as you do that correctly.

00:14:06.970 --> 00:14:12.450
<v Aaron van Wirdum>So maybe this is getting into weeds, but would this work based on fee markets as well?

00:14:13.310 --> 00:14:14.970
<v Sjors Provoost>No, this is one of the...

00:14:14.970 --> 00:14:19.130
<v Aaron van Wirdum>Like which transaction gets priority, I mean, if there's 1,001.

00:14:19.370 --> 00:14:22.550
<v Sjors Provoost>Well, so a rational miner would have to do some complicated math to figure out

00:14:22.550 --> 00:14:27.870
<v Sjors Provoost>whether he'd want the multisigs in there or not. So at the time, there was no fee

00:14:27.870 --> 00:14:32.350
<v Sjors Provoost>market, so that helped. And also, if you looked at the original mining code, so

00:14:32.350 --> 00:14:38.050
<v Sjors Provoost>the standard mining code as it existed at the time was very conservative. I think

00:14:38.050 --> 00:14:41.210
<v Sjors Provoost>it would only put in maybe 20 of them.

00:14:42.530 --> 00:14:46.170
<v Sjors Provoost>like some some really small number oh because there were almost no multisig

00:14:46.170 --> 00:14:51.390
<v Sjors Provoost>transactions anyway right of course any miner could do it differently but he was

00:14:51.390 --> 00:14:52.690
<v Sjors Provoost>pretty much the only miner probably

00:14:52.690 --> 00:14:57.910
<v Aaron van Wirdum>so yeah just to be clear because we're talking about this kind of in the past

00:14:57.910 --> 00:15:02.990
<v Aaron van Wirdum>tense but does this limit still exist in Bitcoin I know we do other ways of doing

00:15:02.990 --> 00:15:06.810
<v Aaron van Wirdum>multisig now, but does this technical limit still exist?

00:15:07.010 --> 00:15:10.790
<v Sjors Provoost>Yes, but we'll get to that in P2SH. The limit is slightly more intelligent.

00:15:11.030 --> 00:15:11.450
<v Aaron van Wirdum>Okay.

00:15:11.650 --> 00:15:17.440
<v Sjors Provoost>But for this bare multisig, so multisig without P2SH, and for

00:15:17.440 --> 00:15:20.220
<v Sjors Provoost>P2SH multisig, this limit exists.

00:15:20.740 --> 00:15:21.280
<v Aaron van Wirdum>Today?

00:15:21.780 --> 00:15:23.360
<v Sjors Provoost>Yes, but not for Taproot.

00:15:24.350 --> 00:15:27.840
<v Aaron van Wirdum>Right. Interesting. I don't think I knew that.

00:15:28.320 --> 00:15:30.920
<v Sjors Provoost>Yeah. So I don't know how that plays into the fee market. If there's too many

00:15:30.920 --> 00:15:35.030
<v Sjors Provoost>multisig transactions. candidates yeah I guess then as a miner you'd have to do

00:15:35.030 --> 00:15:38.610
<v Sjors Provoost>the math what what makes more sense to include the transaction with the higher

00:15:38.610 --> 00:15:42.230
<v Sjors Provoost>fee but it has a multisig are you going to kick out some some other transaction

00:15:42.230 --> 00:15:45.410
<v Sjors Provoost>or are you going to say well I'd rather have the single-sick transactions than

00:15:45.410 --> 00:15:49.650
<v Sjors Provoost>the multisig transactions because you know how the fees work out because you get a limit

00:15:49.650 --> 00:15:53.890
<v Aaron van Wirdum>okay so we're going to talk about other ways of doing multisig but my curiosity

00:15:53.890 --> 00:15:59.010
<v Aaron van Wirdum>is triggered now so spoiler alert we're also going to talk about P2SH multisig

00:15:59.010 --> 00:16:04.490
<v Aaron van Wirdum>SegWit multisig Taproot multisig and MuSig Which of these types of multisig are

00:16:04.490 --> 00:16:08.090
<v Aaron van Wirdum>relevant in context of this limit? Is it only bare multisig or other?

00:16:08.090 --> 00:16:09.310
<v Sjors Provoost>All of them except Taproot.

00:16:10.400 --> 00:16:14.440
<v Aaron van Wirdum>Really? So SegWit multisig is also affected by this limit?

00:16:14.980 --> 00:16:15.420
<v Sjors Provoost>Yes.

00:16:15.420 --> 00:16:16.240
<v Aaron van Wirdum>From 2010.

00:16:16.400 --> 00:16:19.520
<v Sjors Provoost>That's one of the reasons for the change in Taproot, because this limit is

00:16:19.520 --> 00:16:21.160
<v Sjors Provoost>annoying for all sorts of reasons.

00:16:21.180 --> 00:16:24.200
<v Aaron van Wirdum>Okay, I guess we'll get there. We're skipping ahead now, but this will...

00:16:24.200 --> 00:16:27.580
<v Sjors Provoost>So there's also the standardness rules, right? So as far as I can tell, when he

00:16:27.580 --> 00:16:32.220
<v Sjors Provoost>introduced this limit, the standardness rule was two out of two. So you could

00:16:32.220 --> 00:16:37.260
<v Sjors Provoost>have a one out of two or two out of two multisig. And then several years later,

00:16:37.400 --> 00:16:42.360
<v Sjors Provoost>or actually one year later in December 2011, I think Gavin Andresen raised the

00:16:42.360 --> 00:16:46.520
<v Sjors Provoost>limit to three. So you could have a two out of three or a three out of three.

00:16:47.000 --> 00:16:47.480
<v Aaron van Wirdum>Right.

00:16:47.720 --> 00:16:51.680
<v Sjors Provoost>And we know that because that limit led to the OP_RETURN wars that we did another

00:16:51.680 --> 00:16:52.240
<v Sjors Provoost>episode on.

00:16:53.510 --> 00:16:59.000
<v Aaron van Wirdum>Yeah. Okay. So the limit was brought back. The consensus rule was made 20

00:16:59.000 --> 00:17:04.460
<v Aaron van Wirdum>by Satoshi in 2010. And then the standardness

00:17:04.490 --> 00:17:07.170
<v Aaron van Wirdum>rule was made two.

00:17:07.530 --> 00:17:07.870
<v Sjors Provoost>Yeah.

00:17:08.190 --> 00:17:13.980
<v Aaron van Wirdum>Okay. And three later by Gavin Andresen. Okay. So that's raw multisig,

00:17:15.120 --> 00:17:15.340
<v Aaron van Wirdum>right?

00:17:15.680 --> 00:17:16.000
<v Sjors Provoost>Yeah.

00:17:16.000 --> 00:17:18.180
<v Aaron van Wirdum>We've now explained what raw multisig is.

00:17:18.320 --> 00:17:21.180
<v Sjors Provoost>Yes. Or bare multisig, I think is the correct term, but it doesn't really matter.

00:17:21.920 --> 00:17:22.100
<v Aaron van Wirdum>Okay.

00:17:23.560 --> 00:17:27.820
<v Aaron van Wirdum>Then, and this is what we discussed last week as well. Regardless, we'll go over

00:17:27.820 --> 00:17:33.310
<v Aaron van Wirdum>it. Then the next type of multisig in Bitcoin was pay-to-script hash,

00:17:34.960 --> 00:17:40.960
<v Aaron van Wirdum>P2SH, multisig. So how did it evolve from bare multisig?

00:17:41.540 --> 00:17:45.240
<v Sjors Provoost>Yeah, so the difference is, again, the recipient now pays for the fees because

00:17:45.240 --> 00:17:50.620
<v Sjors Provoost>the recipient provides a hash of the script. And inside that script can be some

00:17:50.620 --> 00:17:54.820
<v Sjors Provoost>sort of multisig construction. But the sender doesn't have to care. The hash of

00:17:54.820 --> 00:17:57.840
<v Sjors Provoost>the script is always the same size. So when you pay a detection fee for the

00:17:57.840 --> 00:18:02.160
<v Sjors Provoost>outputs, that's always going to be the same. It also makes addresses easy. Well,

00:18:02.200 --> 00:18:04.500
<v Sjors Provoost>that's what we explained in the last episode. It also gives you a little bit

00:18:04.500 --> 00:18:07.700
<v Sjors Provoost>better privacy because you can't see what the script is until you try to spend

00:18:07.700 --> 00:18:13.970
<v Sjors Provoost>it. Now, there is a new limit. which is 15 at the consensus level.

00:18:15.470 --> 00:18:19.270
<v Sjors Provoost>I didn't check what the standardness was. Maybe the standardness was also 15.

00:18:19.430 --> 00:18:21.510
<v Aaron van Wirdum>Wait, so the limit was decreased?

00:18:22.050 --> 00:18:27.210
<v Sjors Provoost>Well, the consensus limit was decreased from 20 to 15, and the standardness

00:18:27.210 --> 00:18:31.510
<v Sjors Provoost>limit, I think, was increased either immediately or later on to 15.

00:18:32.010 --> 00:18:36.330
<v Aaron van Wirdum>Right, so the consensus limit and the standardness limit were made the same at

00:18:36.330 --> 00:18:36.770
<v Aaron van Wirdum>that point.

00:18:36.870 --> 00:18:41.270
<v Sjors Provoost>Yeah, and the consensus limit is accidental because there is a limit of 20 that's

00:18:41.270 --> 00:18:45.430
<v Sjors Provoost>still there. but you never reach that limit because the script can only be 512

00:18:45.430 --> 00:18:51.370
<v Sjors Provoost>bytes in P2SH. And if you divide 512 bytes by the number of bytes that one public

00:18:51.370 --> 00:18:53.390
<v Sjors Provoost>key requires, you end up with 15.

00:18:54.850 --> 00:18:58.650
<v Aaron van Wirdum>Okay, this is getting complicated, but I do think I'm following you.

00:18:58.830 --> 00:19:02.230
<v Sjors Provoost>Yeah, basically it means you cannot spend a multisig with more than 15 keys in it.

00:19:02.760 --> 00:19:08.680
<v Aaron van Wirdum>Yeah, but not because that's a specific rule concerning multisig,

00:19:08.800 --> 00:19:12.220
<v Aaron van Wirdum>but a more general rule concerning script.

00:19:12.420 --> 00:19:12.740
<v Sjors Provoost>Yes.

00:19:13.490 --> 00:19:19.090
<v Aaron van Wirdum>And that just happens to, the math just happens to end up at 15 in that case.

00:19:19.310 --> 00:19:24.130
<v Sjors Provoost>Yeah, because in order to spend a multisig transaction, you, the recipient, have

00:19:24.130 --> 00:19:28.570
<v Sjors Provoost>to specify which keys are involved. All of them, not just the ones you're using.

00:19:29.390 --> 00:19:30.830
<v Sjors Provoost>And so that's 15.

00:19:31.850 --> 00:19:37.460
<v Aaron van Wirdum>So if… Because at first it's sent to a hash, right? So then the script… Yeah.

00:19:37.050 --> 00:19:42.870
<v Sjors Provoost>and then you reveal the actual script. So the script contains all the

00:19:42.870 --> 00:19:43.410
<v Sjors Provoost>public keys.

00:19:43.810 --> 00:19:49.650
<v Aaron van Wirdum>So if there's a 16 out of 16 multisig, let's say, it just

00:19:49.650 --> 00:19:50.750
<v Aaron van Wirdum>means it can't be spent?

00:19:50.930 --> 00:19:54.470
<v Sjors Provoost>Yep, you can't reveal it. If you try to reveal the script, it's invalid because

00:19:54.470 --> 00:19:54.970
<v Sjors Provoost>it's too long.

00:19:57.010 --> 00:20:01.960
<v Aaron van Wirdum>Wasn't this an incompatibility, like a backwards? compatibility issue at the time?

00:20:01.960 --> 00:20:06.000
<v Sjors Provoost>yeah the limit of 512 is a backwards compatibility issue because the I think the

00:20:06.000 --> 00:20:09.880
<v Sjors Provoost>size of stuff that can be on the stack so the size of each element on the stack

00:20:09.880 --> 00:20:15.870
<v Sjors Provoost>is 512 bytes and the old nodes what they would see if you're using P2SH they

00:20:15.870 --> 00:20:19.610
<v Sjors Provoost>would see something on the stack and they would hash it so that something on the

00:20:19.610 --> 00:20:23.830
<v Sjors Provoost>stack has to be 512 bytes now the new nodes don't interpret it that way anymore

00:20:23.830 --> 00:20:27.550
<v Sjors Provoost>but you have to be backwards compatible hence the 512 limit yeah so if you want

00:20:27.550 --> 00:20:29.090
<v Sjors Provoost>to lose your coins that's one way to do it.

00:20:31.760 --> 00:20:36.620
<v Aaron van Wirdum>right okay anything else we discussed this last week so we probably don't want to

00:20:36.620 --> 00:20:42.180
<v Aaron van Wirdum>get into too much in rehashing mode but what else is new with

00:20:42.180 --> 00:20:44.520
<v Aaron van Wirdum>P2SH is there anything else we need to know about that?

00:20:44.520 --> 00:20:48.260
<v Sjors Provoost>yeah so one other thing is that like we said this sigops limit that we talked

00:20:48.260 --> 00:20:52.560
<v Sjors Provoost>about It used to be that you just get 20 points for any multisig, no matter how

00:20:52.560 --> 00:20:56.180
<v Sjors Provoost>big it was. So that's kind of annoying because if you're making a small multisig,

00:20:56.340 --> 00:21:01.060
<v Sjors Provoost>you're not paying, but you're using up a limit in the block that's quite high.

00:21:01.340 --> 00:21:06.320
<v Sjors Provoost>And now it was changed to the actual number of public keys. So if you do a two

00:21:06.320 --> 00:21:09.260
<v Sjors Provoost>out of three multisig, you get three sigops.

00:21:11.460 --> 00:21:13.540
<v Aaron van Wirdum>Right. Again, this sounds to me...

00:21:13.540 --> 00:21:16.880
<v Sjors Provoost>Or two. I forgot if the limit is the number of public keys or the number of signatures.

00:21:18.520 --> 00:21:22.800
<v Aaron van Wirdum>I'm just wondering out loud here, but when this was changed at the time, again,

00:21:23.020 --> 00:21:28.450
<v Aaron van Wirdum>wouldn't that lead to backwards incompatibility issues where different nodes are

00:21:28.450 --> 00:21:29.650
<v Aaron van Wirdum>making different calculations?

00:21:29.930 --> 00:21:34.330
<v Sjors Provoost>No, because this new limit, this new way of counting only applies to the P2SH

00:21:34.330 --> 00:21:39.130
<v Sjors Provoost>scripts. So the multisig that you were using bare script for... they would still

00:21:39.130 --> 00:21:44.330
<v Sjors Provoost>count as 20 but if you were using P2SH it's it's essentially a discount for P2SH

00:21:44.330 --> 00:21:50.270
<v Sjors Provoost>not so much a discount in fees but a discount in how many of

00:21:50.270 --> 00:21:53.960
<v Sjors Provoost>these things you can put in a single block again it didn't matter in practice,

00:21:53.960 --> 00:21:55.880
<v Sjors Provoost>because blocks were not anywhere near full.

00:21:56.430 --> 00:22:01.690
<v Aaron van Wirdum>yeah no I I get that I think that that makes sense okay so

00:22:03.270 --> 00:22:07.250
<v Sjors Provoost>But other than that, this worked exactly the same. So as soon as you've unwrapped

00:22:07.250 --> 00:22:11.310
<v Sjors Provoost>the P2SH thing, you have an OP_CHECKMULTISIG and it works exactly the same way as

00:22:11.310 --> 00:22:15.290
<v Sjors Provoost>it used in the old consensus code. It is the same code that is checking it, the

00:22:15.290 --> 00:22:16.710
<v Sjors Provoost>same lines of code that are checking it.

00:22:16.770 --> 00:22:17.470
<v Aaron van Wirdum>Yeah, the same opcode.

00:22:17.790 --> 00:22:22.370
<v Sjors Provoost>Yeah, it's the same piece of C++ code that is just used in both situations.

00:22:23.200 --> 00:22:28.390
<v Aaron van Wirdum>Right. Okay, so that was bare multisig and that was...

00:22:28.660 --> 00:22:34.500
<v Aaron van Wirdum>P2SH as well now we move to SegWit so SegWit also

00:22:34.500 --> 00:22:37.120
<v Aaron van Wirdum>changed things about how multisig works

00:22:37.120 --> 00:22:41.600
<v Sjors Provoost>yeah well one thing that SegWit changes is SegWit also had a its own P2SH

00:22:41.600 --> 00:22:46.560
<v Sjors Provoost>essentially wrapped P2SH or pay to SegWit script hash

00:22:46.560 --> 00:22:52.550
<v Sjors Provoost>and this hash could be the script could be as big as you

00:22:52.550 --> 00:22:56.660
<v Sjors Provoost>want I think there's no limit or at least the limit is large enough for this

00:22:56.660 --> 00:23:01.220
<v Sjors Provoost>purpose, which means now the limit is actually 20. So the original limit of 20

00:23:01.220 --> 00:23:04.520
<v Sjors Provoost>that's in the consensus code is now actually relevant for SegWit.

00:23:07.170 --> 00:23:10.670
<v Sjors Provoost>So it wasn't that SegWit decided to make it 20. It's just that they removed the

00:23:10.670 --> 00:23:12.490
<v Sjors Provoost>512 limit on the script size.

00:23:12.730 --> 00:23:18.130
<v Aaron van Wirdum>Right. Yeah, that's what we just... discussed so there wasn't an actual

00:23:18.130 --> 00:23:23.510
<v Aaron van Wirdum>explicit limit on multisig but there was a practical limit because there was a

00:23:23.510 --> 00:23:28.450
<v Aaron van Wirdum>more general script limit and this more general script limit was removed in the

00:23:28.450 --> 00:23:33.700
<v Aaron van Wirdum>case of SegWit, and therefore we went back to the original

00:23:33.700 --> 00:23:38.920
<v Aaron van Wirdum>Satoshi imposed multisig limit consensus limit is that right

00:23:38.920 --> 00:23:41.220
<v Sjors Provoost>the super sneaky soft fork that he introduced Yep.

00:23:41.680 --> 00:23:45.640
<v Aaron van Wirdum>Okay, right. So then because of SegWit, we went back to 20.

00:23:46.040 --> 00:23:49.880
<v Sjors Provoost>Yes, and also the limit per block, so that we talked about the sigops limit per

00:23:49.880 --> 00:23:55.360
<v Sjors Provoost>block. SegWit also multiplied that by four. So if you wanted to use multisig

00:23:55.360 --> 00:23:59.840
<v Sjors Provoost>and you did it inside of SegWit, it would be cheaper. You would be able to put

00:23:59.840 --> 00:24:00.660
<v Sjors Provoost>more of them in a block.

00:24:02.390 --> 00:24:07.270
<v Aaron van Wirdum>okay where now now I'm getting lost again so where is this limit? does this

00:24:07.270 --> 00:24:08.390
<v Aaron van Wirdum>question even make sense?

00:24:08.390 --> 00:24:12.230
<v Sjors Provoost>yeah the sigops limit is per block so there is a counter that says the number of

00:24:12.230 --> 00:24:16.890
<v Sjors Provoost>sigops and every time it sees a normal signature it says okay one sees another

00:24:16.890 --> 00:24:17.450
<v Sjors Provoost>normal signature

00:24:17.450 --> 00:24:19.130
<v Aaron van Wirdum>but it's all in the witness right?

00:24:19.840 --> 00:24:23.420
<v Sjors Provoost>It doesn't matter where the signature is. But this counter is different for where

00:24:23.420 --> 00:24:28.220
<v Sjors Provoost>it is. So before SegWit, there was one counter, and if it saw a single sig, it

00:24:28.220 --> 00:24:31.200
<v Sjors Provoost>would give you one point. If it saw a multisig, it would give you n points,

00:24:31.300 --> 00:24:34.980
<v Sjors Provoost>depending on what n was. Except if it was a raw multisig, then it would give you

00:24:34.980 --> 00:24:40.120
<v Sjors Provoost>20 points. Now the new rule is that all of these examples from before would get

00:24:40.120 --> 00:24:44.160
<v Sjors Provoost>four points. So that was multiplied by four. But if it was in SegWit, it would

00:24:44.160 --> 00:24:45.060
<v Sjors Provoost>only get one point.

00:24:45.230 --> 00:24:47.670
<v Aaron van Wirdum>Yeah, that's the weight limit, essentially, what we're talking about, right?

00:24:47.770 --> 00:24:51.940
<v Sjors Provoost>It's the same trick as with the weight limit, but it's not the same thing. It's a

00:24:51.940 --> 00:24:55.080
<v Sjors Provoost>different counter, but it gets the same discount as everything else at SegWit.

00:24:55.220 --> 00:25:00.760
<v Aaron van Wirdum>I see. Okay. So once again, we're talking about a

00:25:00.760 --> 00:25:03.020
<v Aaron van Wirdum>specific limit on...

00:25:03.210 --> 00:25:05.150
<v Sjors Provoost>Well, not SegWit.

00:25:05.410 --> 00:25:06.250
<v Aaron van Wirdum>There's a point system.

00:25:06.680 --> 00:25:08.760
<v Sjors Provoost>Yeah. The point system was...

00:25:08.760 --> 00:25:12.520
<v Aaron van Wirdum>The thing is, we're not talking about the block size limit itself. We're talking

00:25:12.520 --> 00:25:16.880
<v Aaron van Wirdum>about another type of limit for the types of transactions that can be put in

00:25:16.880 --> 00:25:22.480
<v Aaron van Wirdum>blocks and that different transactions can score different points.

00:25:22.680 --> 00:25:25.940
<v Sjors Provoost>Yeah. And for some reason, that was also multiplied by four. I don't know what

00:25:25.940 --> 00:25:29.940
<v Sjors Provoost>the reason is because as far as I know, the problems with this inefficient

00:25:29.940 --> 00:25:31.240
<v Sjors Provoost>evaluation is still there.

00:25:31.520 --> 00:25:36.950
<v Aaron van Wirdum>Yeah. Well, my mind is going to... why wouldn't that be backwards

00:25:36.950 --> 00:25:41.430
<v Aaron van Wirdum>incompatible? But I guess the reason is because it is in the witness, so you can

00:25:41.430 --> 00:25:44.690
<v Aaron van Wirdum>just do whatever at that point. It doesn't have to be backwards compatible

00:25:44.690 --> 00:25:46.690
<v Aaron van Wirdum>because all the nodes don't see the witness, right?

00:25:46.930 --> 00:25:47.690
<v Sjors Provoost>Exactly, yeah.

00:25:47.930 --> 00:25:48.090
<v Aaron van Wirdum>Okay.

00:25:49.210 --> 00:25:53.490
<v Sjors Provoost>All the nodes are only looking at all the transactions, and because that score is

00:25:53.490 --> 00:25:56.150
<v Sjors Provoost>multiplied by four, it is effectively the same thing.

00:25:56.830 --> 00:25:59.990
<v Aaron van Wirdum>Well, they're also looking at new transactions, just not the witness part.

00:26:01.570 --> 00:26:04.750
<v Sjors Provoost>Yeah, so they're seeing all these new transactions and they don't see the script

00:26:04.750 --> 00:26:06.410
<v Sjors Provoost>of those new transactions. They just ignore them.

00:26:06.570 --> 00:26:06.770
<v Aaron van Wirdum>Yeah.

00:26:06.910 --> 00:26:08.610
<v Sjors Provoost>So they don't count the number of signatures in it.

00:26:08.810 --> 00:26:09.010
<v Aaron van Wirdum>Right.

00:26:10.250 --> 00:26:15.530
<v Aaron van Wirdum>Okay. So there was still a limit when SegWit was imposed, which was four times

00:26:15.530 --> 00:26:18.680
<v Aaron van Wirdum>what used to be the limit. Wait. So the number of…

00:26:18.650 --> 00:26:23.130
<v Sjors Provoost>Basically, the number of signatures per block was increased by four. And I guess

00:26:23.130 --> 00:26:23.610
<v Sjors Provoost>that makes sense.

00:26:23.810 --> 00:26:28.530
<v Aaron van Wirdum>And to remind me and our listeners maybe, if they have the same type of memory as

00:26:28.530 --> 00:26:29.970
<v Aaron van Wirdum>I do, what was the original limit?

00:26:31.090 --> 00:26:33.150
<v Sjors Provoost>20,000, and so it became 80,000.

00:26:34.820 --> 00:26:38.880
<v Aaron van Wirdum>Oh, yeah, but that was 1,000, right? Because it was 20 points per...

00:26:38.880 --> 00:26:42.440
<v Sjors Provoost>Well, only if you had these 20 out of 20 [unclear]. So in practice, the limit

00:26:42.440 --> 00:26:46.800
<v Sjors Provoost>before SegWit was about 1,000 multisig transactions per block if they were using

00:26:46.800 --> 00:26:49.680
<v Sjors Provoost>the full size. A bit more because the full size was 16.

00:26:49.880 --> 00:26:50.140
<v Aaron van Wirdum>Right.

00:26:50.460 --> 00:26:55.260
<v Sjors Provoost>And with SegWit, SegWit, you could do more. Basically four times as many.

00:26:57.140 --> 00:26:59.300
<v Aaron van Wirdum>Okay, sure. Is there a nice...

00:26:59.300 --> 00:27:03.160
<v Sjors Provoost>But I'm not aware of a single block that was produced that was violating that

00:27:03.160 --> 00:27:06.080
<v Sjors Provoost>limit. And I don't know if that's because miners are brilliant or just because

00:27:06.080 --> 00:27:09.440
<v Sjors Provoost>there's not that many multisig transactions and nobody hit the limit or because

00:27:09.440 --> 00:27:12.400
<v Sjors Provoost>the miners use Bitcoin Core and Bitcoin Core makes sure you don't make that mistake.

00:27:13.200 --> 00:27:17.780
<v Aaron van Wirdum>Real quick, if people want to look up what all these limits are, especially the

00:27:17.780 --> 00:27:20.860
<v Aaron van Wirdum>current limits, I guess, is there a nice website for this or something? Where are

00:27:20.860 --> 00:27:21.500
<v Aaron van Wirdum>you finding this?

00:27:21.700 --> 00:27:23.320
<v Sjors Provoost>The Bitcoin Core source code.

00:27:23.640 --> 00:27:24.340
<v Aaron van Wirdum>Oh, God.

00:27:24.460 --> 00:27:24.700
<v Sjors Provoost>Mostly.

00:27:25.610 --> 00:27:28.350
<v Aaron van Wirdum>Well, I guess, like you said, wallets are taking care of it.

00:27:28.880 --> 00:27:29.520
<v Sjors Provoost>Sometimes.

00:27:29.800 --> 00:27:30.120
<v Aaron van Wirdum>Hopefully.

00:27:30.960 --> 00:27:31.200
<v Sjors Provoost>Okay.

00:27:31.340 --> 00:27:37.120
<v Aaron van Wirdum>Okay. So that's SegWit. I think we've discussed how SegWit

00:27:37.120 --> 00:27:40.580
<v Aaron van Wirdum>changed Multisig from P2SH, right?

00:27:40.920 --> 00:27:42.160
<v Sjors Provoost>Yeah, it's a very small change.

00:27:42.520 --> 00:27:48.490
<v Aaron van Wirdum>Okay. Then there was another update to how Multisig works when

00:27:48.490 --> 00:27:50.230
<v Aaron van Wirdum>Taproot was introduced, right?

00:27:50.790 --> 00:27:51.130
<v Sjors Provoost>Yes.

00:27:52.030 --> 00:27:54.670
<v Aaron van Wirdum>Okay. So what changed with Taproot?

00:27:55.140 --> 00:28:01.100
<v Sjors Provoost>Well, Taproot got rid of the multisig opcode, the specific

00:28:01.100 --> 00:28:05.440
<v Sjors Provoost>opcode. Because of this weirdness that you just throw a bucket of signatures and

00:28:05.440 --> 00:28:08.980
<v Sjors Provoost>public keys and you don't tell which public key corresponds to which signature.

00:28:09.400 --> 00:28:10.840
<v Sjors Provoost>That weirdness is all gone.

00:28:10.940 --> 00:28:14.820
<v Aaron van Wirdum>So basically the reason that we even have limits on this kind of stuff.

00:28:14.840 --> 00:28:19.460
<v Sjors Provoost>Yeah, and it was replaced with something a little simpler called OP_CHECKSIGADD.

00:28:19.920 --> 00:28:25.800
<v Sjors Provoost>And what OP_CHECKSIGADD does... is it basically checks the signature and

00:28:26.000 --> 00:28:31.190
<v Sjors Provoost>then it adds the number one to the stack. And so it's essentially a counter. So

00:28:31.190 --> 00:28:36.990
<v Sjors Provoost>what you do is you say, okay, you call this OP_CHECKSIGADD 10 times. And so if

00:28:36.990 --> 00:28:40.390
<v Sjors Provoost>that gives you 10 valid signatures, then the number on the counter is going to be

00:28:40.390 --> 00:28:44.090
<v Sjors Provoost>10. And then at the end of the script, you say, okay, is the number more than

00:28:44.090 --> 00:28:49.290
<v Sjors Provoost>five? And then you've created a five out of 10 multisig. So you don't create one

00:28:49.290 --> 00:28:52.970
<v Sjors Provoost>line that says this is a multisig. You just... It implicitly is a multisig by

00:28:52.970 --> 00:28:55.330
<v Sjors Provoost>using this opcode in an intelligent way.

00:28:58.100 --> 00:29:01.140
<v Aaron van Wirdum>Okay. What does that mean? Why is this better?

00:29:01.960 --> 00:29:07.700
<v Sjors Provoost>Well, it's better because when you call this OP_CHECKSIGADD, as the spender, when

00:29:07.700 --> 00:29:11.680
<v Sjors Provoost>you're spending it, you don't just give it a pile of signatures. You actually

00:29:11.680 --> 00:29:16.840
<v Sjors Provoost>have to specifically say for each public key which signature you're giving. And

00:29:16.840 --> 00:29:21.120
<v Sjors Provoost>the way you do that is by if you don't have a specific public key, because let's

00:29:21.120 --> 00:29:24.980
<v Sjors Provoost>say you have only one out of the three keys, then when you don't see your key,

00:29:25.120 --> 00:29:29.700
<v Sjors Provoost>you just give it an empty signature. And then when you do see your key, you give

00:29:29.700 --> 00:29:33.400
<v Sjors Provoost>it a real signature. And this makes the evaluation of the script a lot easier

00:29:33.400 --> 00:29:38.610
<v Sjors Provoost>because now the rule is every signature is either valid or it's empty.

00:29:39.200 --> 00:29:42.520
<v Sjors Provoost>And this also means in the future we can aggregate signatures. So we can

00:29:42.520 --> 00:29:45.760
<v Sjors Provoost>basically evaluate the script and just say, okay, every time we see

00:29:45.760 --> 00:29:51.520
<v Sjors Provoost>OP_CHECKSIGADD with a signature, we just kind of assume that it's correct. And

00:29:51.520 --> 00:29:54.500
<v Sjors Provoost>then at the end of the block, we take all the public keys and all the signatures

00:29:54.500 --> 00:30:00.370
<v Sjors Provoost>and evaluate them in one go with this key aggregation tricks, which would

00:30:00.370 --> 00:30:01.550
<v Sjors Provoost>make block evaluation faster.

00:30:01.790 --> 00:30:05.950
<v Aaron van Wirdum>Let me try to make this very sort of practical. See if this is kind of a

00:30:05.950 --> 00:30:11.560
<v Aaron van Wirdum>translation of what you just said. So if I have a 12 out of

00:30:11.560 --> 00:30:17.210
<v Aaron van Wirdum>15 multisig and I'm spending it and there at this point

00:30:17.210 --> 00:30:22.580
<v Aaron van Wirdum>there's 15 pub keys and I'm saying these are signatures

00:30:22.580 --> 00:30:28.410
<v Aaron van Wirdum>numbers one two three six eight etc

00:30:28.410 --> 00:30:29.230
<v Sjors Provoost>yeah, exactly.

00:30:29.230 --> 00:30:33.730
<v Aaron van Wirdum>And that's and so now you know exactly the rest of the network all nodes know

00:30:33.730 --> 00:30:35.610
<v Aaron van Wirdum>exactly where to look and check it.

00:30:35.610 --> 00:30:39.290
<v Sjors Provoost>yeah whereas in the original one you would just give 12 signatures and the

00:30:39.290 --> 00:30:41.690
<v Sjors Provoost>network would have to figure out which signature belongs to which key.

00:30:41.690 --> 00:30:46.970
<v Aaron van Wirdum>yeah okay that makes sense that sounds like a sort of very obvious improvement

00:30:46.970 --> 00:30:52.490
<v Aaron van Wirdum>that makes me wonder why wasn't this already the case was it just originally kind

00:30:52.490 --> 00:30:57.070
<v Aaron van Wirdum>of sloppy implementation by Satoshi? or well I think how should we think about this?

00:30:58.160 --> 00:31:01.820
<v Sjors Provoost>I'm not entirely sure, but one of the things is that because Taproot also

00:31:01.820 --> 00:31:07.620
<v Sjors Provoost>introduced Schnorr, and these signatures are Schnorr, they're not ECDSA, if I

00:31:07.620 --> 00:31:13.540
<v Sjors Provoost>remember correctly, they are easier to aggregate in general. So... This new way

00:31:13.540 --> 00:31:19.380
<v Sjors Provoost>of doing it in the future can take advantage of Schnorr. So there was not as good

00:31:19.380 --> 00:31:23.560
<v Sjors Provoost>a reason to do this earlier because things like aggregating keys was not really a

00:31:23.560 --> 00:31:24.780
<v Sjors Provoost>practical thing with ECDSA.

00:31:24.980 --> 00:31:27.780
<v Aaron van Wirdum>I didn't realize we're not talking about aggregating keys.

00:31:27.900 --> 00:31:31.860
<v Sjors Provoost>No, but it basically means in the future we could without a soft fork even…

00:31:31.860 --> 00:31:37.050
<v Sjors Provoost>because what you can do is you can take a block and now we evaluate the script

00:31:37.050 --> 00:31:39.970
<v Sjors Provoost>and while we evaluate the script, we have to evaluate every signature. We have to

00:31:39.970 --> 00:31:45.190
<v Sjors Provoost>check every individual signature. which is very slow. But in the future, what you

00:31:45.190 --> 00:31:48.130
<v Sjors Provoost>could do is you could say, well, we're going to evaluate all the scripts. We're

00:31:48.130 --> 00:31:51.390
<v Sjors Provoost>going to pretend that they're okay. And then at the end of the block, we're going

00:31:51.390 --> 00:31:54.010
<v Sjors Provoost>to evaluate all the signatures in the block or at least all the Taproot

00:31:54.010 --> 00:31:58.610
<v Sjors Provoost>signatures in the block in one operation. And this would be faster than doing it

00:31:58.610 --> 00:32:04.050
<v Sjors Provoost>as individual operations. So by enforcing this structure, now

00:32:04.050 --> 00:32:07.650
<v Sjors Provoost>we are making it easier later to make the valuation faster.

00:32:08.110 --> 00:32:12.670
<v Aaron van Wirdum>Okay, so that sounds to me like that's

00:32:13.630 --> 00:32:19.290
<v Aaron van Wirdum>a good reason to do it this way. But even without that, it's

00:32:19.290 --> 00:32:21.990
<v Aaron van Wirdum>still better to do it this way, right?

00:32:22.430 --> 00:32:25.910
<v Sjors Provoost>Probably, yes. Yeah, I mean, yeah, very probably.

00:32:25.910 --> 00:32:29.290
<v Aaron van Wirdum>Is there a downside? It just sounds like this is less work.

00:32:29.950 --> 00:32:33.730
<v Sjors Provoost>Yeah, well, the downside is it's more... I guess a bit more tedious to write the

00:32:33.730 --> 00:32:36.170
<v Sjors Provoost>script, but I don't know if that really matters.

00:32:36.450 --> 00:32:36.690
<v Aaron van Wirdum>Okay.

00:32:36.830 --> 00:32:37.450
<v Sjors Provoost>The script might be bigger.

00:32:37.790 --> 00:32:37.930
<v Aaron van Wirdum>Right.

00:32:38.130 --> 00:32:41.450
<v Sjors Provoost>But I guess there's no limit anyway to the script size, so... Yeah, no, so this

00:32:41.450 --> 00:32:44.670
<v Sjors Provoost>is better, yeah. But it may have not been worth the risk of making a consensus

00:32:44.670 --> 00:32:49.650
<v Sjors Provoost>mistake if the advantages are not big enough. And nobody really needs those

00:32:49.650 --> 00:32:53.950
<v Sjors Provoost>really big multisig things. It's just that this happens to make it possible to

00:32:53.950 --> 00:32:56.230
<v Sjors Provoost>make a 999 multisig.

00:32:57.730 --> 00:32:59.630
<v Aaron van Wirdum>Which is now literally possible.

00:33:00.050 --> 00:33:05.790
<v Sjors Provoost>Yeah, so Mr. Burak did a demonstration. He made a 998 out of 999 multisig.

00:33:05.990 --> 00:33:06.210
<v Aaron van Wirdum>Yeah.

00:33:06.450 --> 00:33:11.150
<v Sjors Provoost>But as far as I know, he could have done a 1999 out of 1999 multisig too. I'm not

00:33:11.150 --> 00:33:11.830
<v Sjors Provoost>entirely sure.

00:33:12.030 --> 00:33:16.230
<v Aaron van Wirdum>That's the transaction that crashed the btcd nodes, which we also made an episode about.

00:33:16.670 --> 00:33:19.950
<v Sjors Provoost>Yes, two episodes even, because we talked about it in the second episode after

00:33:19.950 --> 00:33:21.590
<v Sjors Provoost>that, about the second attack.

00:33:21.850 --> 00:33:27.040
<v Aaron van Wirdum>Okay, but just hold on, because I don't think we've mentioned this explicitly. So

00:33:27.040 --> 00:33:30.560
<v Aaron van Wirdum>with Taproot, the limit was removed entirely. Is that right?

00:33:30.960 --> 00:33:36.600
<v Sjors Provoost>Yes. So OP_CHECKSIGADD has no limit itself.

00:33:36.900 --> 00:33:38.820
<v Aaron van Wirdum>This is the new multisig opcode.

00:33:38.980 --> 00:33:43.180
<v Sjors Provoost>Yes. It intrinsically has no limit because all it does is it checks one signature

00:33:43.180 --> 00:33:48.860
<v Sjors Provoost>and it adds a number to another number. So it has no idea how many

00:33:48.860 --> 00:33:51.620
<v Sjors Provoost>signatures there are. So in that sense, there [unclear] be a limit.

00:33:51.980 --> 00:33:52.280
<v Aaron van Wirdum>Okay.

00:33:53.030 --> 00:33:58.570
<v Sjors Provoost>And there's also no more sigops. So this block counter that we talked about, the

00:33:58.570 --> 00:34:03.680
<v Sjors Provoost>sigops counter, doesn't apply to Taproot. It still applies for SegWit and the old

00:34:03.680 --> 00:34:04.860
<v Sjors Provoost>stuff, but it doesn't apply to Taproot.

00:34:05.080 --> 00:34:05.460
<v Aaron van Wirdum>Okay.

00:34:05.700 --> 00:34:07.760
<v Sjors Provoost>So this complexity that we just talked about is gone.

00:34:08.610 --> 00:34:10.830
<v Aaron van Wirdum>So basically what you're saying

00:34:12.070 --> 00:34:15.730
<v Aaron van Wirdum>is... That's weird.

00:34:17.420 --> 00:34:20.220
<v Aaron van Wirdum>Makes me think of the Cathy Newman interview.

00:34:20.540 --> 00:34:25.360
<v Sjors Provoost>Yeah, exactly. So what you're saying is Bitcoin is not really signatures, is it?

00:34:26.280 --> 00:34:31.880
<v Aaron van Wirdum>Okay, so basically what you're saying is Taproot completely changed how multisig

00:34:31.880 --> 00:34:33.420
<v Aaron van Wirdum>works at all, right?

00:34:34.280 --> 00:34:34.680
<v Sjors Provoost>Yes.

00:34:35.080 --> 00:34:40.500
<v Aaron van Wirdum>It's a new opcode. There's no limits. All the old limits are gone. And we can

00:34:40.500 --> 00:34:41.160
<v Aaron van Wirdum>even...

00:34:41.160 --> 00:34:44.820
<v Sjors Provoost>Well, not all the old limits are gone. There's still a block size limit. But

00:34:44.820 --> 00:34:46.360
<v Sjors Provoost>there's another limit.

00:34:46.460 --> 00:34:48.400
<v Aaron van Wirdum>All the multisig... Oh, there's another limit?

00:34:48.420 --> 00:34:50.120
<v Sjors Provoost>All the limits we just talked about are gone.

00:34:50.240 --> 00:34:50.680
<v Aaron van Wirdum>Okay, yes.

00:34:50.680 --> 00:34:50.980
<v Sjors Provoost>I agree.

00:34:51.200 --> 00:34:51.340
<v Aaron van Wirdum>Right.

00:34:51.500 --> 00:34:55.480
<v Sjors Provoost>But there was another limit out there that we never ran into because our

00:34:55.480 --> 00:34:58.920
<v Sjors Provoost>multisigs were very small because of these earlier limits. But now if you try to

00:34:58.920 --> 00:35:02.780
<v Sjors Provoost>make the multisig bigger and bigger and bigger, you run into another limit. which

00:35:02.780 --> 00:35:07.980
<v Sjors Provoost>is called the stack size limit. And remember, the stack is like a pile of plates,

00:35:08.240 --> 00:35:13.680
<v Sjors Provoost>like a stack of plates. And when you want to spend a multisig, you put a

00:35:13.680 --> 00:35:18.180
<v Sjors Provoost>signature on a plate or you put a zero on a plate for each placeholder,

00:35:18.200 --> 00:35:23.840
<v Sjors Provoost>basically. So if you want to do a 999 multisig, one

00:35:23.840 --> 00:35:29.760
<v Sjors Provoost>of 999 doesn't matter, you have to create a plate of 999

00:35:29.760 --> 00:35:33.770
<v Sjors Provoost>plates. And one of these plates or more have a signature on it and the others

00:35:33.770 --> 00:35:37.860
<v Sjors Provoost>have zero on it. And there's a limit in the Bitcoin code that says if the stack

00:35:37.860 --> 00:35:40.160
<v Sjors Provoost>is more than a thousand, the script is invalid.

00:35:41.560 --> 00:35:45.720
<v Aaron van Wirdum>So what you're saying is Bitcoin is now in the restaurant business.

00:35:45.980 --> 00:35:46.420
<v Sjors Provoost>Yes.

00:35:46.960 --> 00:35:47.540
<v Aaron van Wirdum>Got it.

00:35:48.520 --> 00:35:53.620
<v Sjors Provoost>And in case the listener is curious why the limit is 999 for the multisig and not

00:35:53.620 --> 00:35:59.440
<v Sjors Provoost>1000, it's because the stack can only be a thousand. And now you have to kind of

00:35:59.440 --> 00:36:02.980
<v Sjors Provoost>look at what happens exactly when you're spending it under the hood. Essentially,

00:36:03.020 --> 00:36:08.640
<v Sjors Provoost>what you're doing is when you're spending it, you put all the signatures on the

00:36:08.640 --> 00:36:14.540
<v Sjors Provoost>stack, right? So that's 999. But then the script has to also put the

00:36:14.540 --> 00:36:19.780
<v Sjors Provoost>pub keys on the stack. Not all of them at once, but one by one. So when the

00:36:19.780 --> 00:36:24.950
<v Sjors Provoost>script starts, it puts one pub key on the stack. Now your stack is 1000 high. And

00:36:24.950 --> 00:36:29.610
<v Sjors Provoost>then it goes down because once it's verified the public key and the signature, it

00:36:29.610 --> 00:36:33.450
<v Sjors Provoost>removes both the public key and the signature from the stack. So now you're down

00:36:33.450 --> 00:36:36.370
<v Sjors Provoost>to 999 and then the next signature you're down to 998, etc.

00:36:37.090 --> 00:36:38.190
<v Aaron van Wirdum>Okay, that makes sense.

00:36:38.290 --> 00:36:41.030
<v Sjors Provoost>But because you have to put one public key on the stack, that's why you hit the

00:36:41.030 --> 00:36:41.690
<v Sjors Provoost>1,000 limit.

00:36:41.850 --> 00:36:43.450
<v Aaron van Wirdum>That makes a lot of sense.

00:36:44.810 --> 00:36:49.550
<v Aaron van Wirdum>What I do wonder, though, is why is there a limit of 1,000? You just explained

00:36:49.550 --> 00:36:51.470
<v Aaron van Wirdum>why the limit is 999 for...

00:36:51.470 --> 00:36:55.570
<v Sjors Provoost>Because I think, as far as I know, Satoshi put in the limit of 1,000, so it's an

00:36:55.570 --> 00:36:56.330
<v Sjors Provoost>old consensus rule.

00:36:56.510 --> 00:36:58.690
<v Aaron van Wirdum>Oh, so that rule also existed already.

00:36:59.170 --> 00:37:05.120
<v Sjors Provoost>Yep. And, of course, Taproot could have removed it, but people felt

00:37:05.120 --> 00:37:05.940
<v Sjors Provoost>no need to remove it.

00:37:07.240 --> 00:37:10.930
<v Aaron van Wirdum>1,000 should be enough for your average

00:37:10.930 --> 00:37:15.790
<v Sjors Provoost>type of transaction. And this is also why the ordinals have a limit because or

00:37:15.790 --> 00:37:17.130
<v Sjors Provoost>not. I forgot.

00:37:17.510 --> 00:37:20.890
<v Aaron van Wirdum>Ordinals just have the block size limit as limited as far as I know. The

00:37:20.890 --> 00:37:22.090
<v Aaron van Wirdum>inscriptions is what I mean.

00:37:22.250 --> 00:37:25.230
<v Sjors Provoost>The inscriptions, yeah, you might be right. I thought there was something about

00:37:25.230 --> 00:37:28.380
<v Sjors Provoost>the 1,002, but maybe not.

00:37:29.910 --> 00:37:34.310
<v Aaron van Wirdum>No, I think they, I mean, we've seen blocks of 4 megabytes, right? That are

00:37:34.310 --> 00:37:35.630
<v Aaron van Wirdum>basically just one inscription.

00:37:35.770 --> 00:37:40.460
<v Sjors Provoost>That's true, yeah. So anyway, this 1000 limit exists. So that's basically the

00:37:40.460 --> 00:37:42.320
<v Sjors Provoost>naive way in Taproot to do multisig.

00:37:43.940 --> 00:37:49.840
<v Aaron van Wirdum>Okay, just to recap this real quick. Taproot basically just changed how

00:37:49.840 --> 00:37:54.340
<v Aaron van Wirdum>multisig works in a technical way in that it uses a new opcode. It removed all

00:37:54.340 --> 00:37:59.380
<v Aaron van Wirdum>the limits we've just mentioned. And the only limit, it just ran into a new limit

00:37:59.380 --> 00:38:04.160
<v Aaron van Wirdum>that was also already there and that was kept of 1000, which is the stack limit.

00:38:05.160 --> 00:38:07.440
<v Aaron van Wirdum>Right? So that was the Taproot version of multisig.

00:38:08.520 --> 00:38:13.280
<v Sjors Provoost>And keep in mind that with Taproot, you can have a tree of different scripts. So

00:38:13.280 --> 00:38:18.820
<v Sjors Provoost>you can probably make a much bigger multisig effectively by spreading all the

00:38:18.820 --> 00:38:20.280
<v Sjors Provoost>keys over different parts of the tree.

00:38:20.480 --> 00:38:20.780
<v Aaron van Wirdum>Yeah.

00:38:21.420 --> 00:38:24.560
<v Sjors Provoost>But then you might be ruling out certain combinations, right? So you might say,

00:38:24.640 --> 00:38:28.960
<v Sjors Provoost>okay, there's 2,000 keys in total, and you need one of the first 1,000 keys, and

00:38:28.960 --> 00:38:33.260
<v Sjors Provoost>you need one of the second 1,000 keys. And then both of these would be a separate

00:38:33.260 --> 00:38:37.220
<v Sjors Provoost>tapleaf, a different leaf. So if you want to spend using one of the thousand

00:38:37.220 --> 00:38:40.540
<v Sjors Provoost>keys, you pick one of the leaves that you have the key from.

00:38:42.520 --> 00:38:46.420
<v Sjors Provoost>But that means you can actually make a one out of a million multisig if you want

00:38:46.420 --> 00:38:50.200
<v Sjors Provoost>to, because you can make a thousand leaves with each with a thousand keys. And

00:38:50.200 --> 00:38:53.700
<v Sjors Provoost>when you're spending it, you pick one of the thousand leaves and then you produce

00:38:53.700 --> 00:38:56.300
<v Sjors Provoost>one of the thousand keys. Well, 999.

00:38:56.640 --> 00:39:01.620
<v Aaron van Wirdum>Yep. Yeah, and also there's another way of doing, for example, two out of three,

00:39:01.840 --> 00:39:07.240
<v Aaron van Wirdum>which is you make three branches with two out of two with the different two

00:39:07.240 --> 00:39:08.920
<v Aaron van Wirdum>out of the same three.

00:39:07.620 --> 00:39:12.320
<v Sjors Provoost>Yep. Exactly. And the advantage could be that it gives better privacy because you

00:39:12.320 --> 00:39:13.900
<v Sjors Provoost>would not reveal any key that you're not using.

00:39:15.300 --> 00:39:19.180
<v Aaron van Wirdum>It might also be more compact or not because you know it's the same.

00:39:19.340 --> 00:39:20.100
<v Sjors Provoost>Yeah, it's also more compact.

00:39:20.300 --> 00:39:20.600
<v Aaron van Wirdum>Oh, it is?

00:39:20.840 --> 00:39:24.480
<v Sjors Provoost>Yeah, because the individual scripts that you're using only have two keys in

00:39:24.480 --> 00:39:25.920
<v Sjors Provoost>them. So the scripts are smaller.

00:39:26.140 --> 00:39:30.140
<v Aaron van Wirdum>Yeah, but you only need to publish two signatures anyways, right?

00:39:30.300 --> 00:39:32.140
<v Sjors Provoost>Yeah, but you also need to publish the original script.

00:39:32.300 --> 00:39:37.260
<v Aaron van Wirdum>Right, yeah. So it is more compact then, right? Yeah. Okay, so that's another way

00:39:37.260 --> 00:39:38.180
<v Aaron van Wirdum>of doing it in Taproot.

00:39:39.400 --> 00:39:42.740
<v Aaron van Wirdum>Taproot opens the possibility of doing multisig in multiple ways.

00:39:42.920 --> 00:39:43.320
<v Sjors Provoost>Yes.

00:39:43.850 --> 00:39:47.880
<v Aaron van Wirdum>and potentially therefore it's even more flexible. Interesting.

00:39:48.480 --> 00:39:50.420
<v Sjors Provoost>And we haven't even talked about the best way to do it.

00:39:50.580 --> 00:39:53.840
<v Aaron van Wirdum>Let's talk about the best way to do it, Sjors. What is the best way to do

00:39:53.840 --> 00:39:54.300
<v Aaron van Wirdum>multisig?

00:39:54.460 --> 00:39:59.440
<v Sjors Provoost>Well, the best way to do multisig, in theory, doesn't really exist yet. But it is

00:39:59.440 --> 00:40:03.980
<v Sjors Provoost>by using the key-spend path of Taproot. So Taproot has two ways of spending. One

00:40:03.980 --> 00:40:09.100
<v Sjors Provoost>is you provide a script, as we just described, similar to P2SH. And the other is

00:40:09.100 --> 00:40:13.540
<v Sjors Provoost>you provide a key, a public key and its signature. Now, from the point of view of

00:40:13.540 --> 00:40:17.060
<v Sjors Provoost>the blockchain, that is one public key and one signature. So it looks like a one

00:40:17.060 --> 00:40:21.250
<v Sjors Provoost>of one. I guess, but under the hood, you can actually use key aggregation

00:40:21.250 --> 00:40:26.590
<v Sjors Provoost>strategies to combine multiple public keys into one. Now you could already do

00:40:26.590 --> 00:40:32.430
<v Sjors Provoost>this with before Taproot with signatures, but Schnorr makes it easier

00:40:32.430 --> 00:40:36.890
<v Sjors Provoost>to do this and to make proof that it's secure. And one of the ways to do that is

00:40:36.890 --> 00:40:40.650
<v Sjors Provoost>MuSig2 as an algorithm, which we have, well, we haven't talked about MuSig2, but

00:40:40.650 --> 00:40:44.110
<v Sjors Provoost>we have talked about Taproot. And sort of this phenomenon that you can aggregate

00:40:44.110 --> 00:40:44.730
<v Sjors Provoost>keys before.

00:40:45.110 --> 00:40:51.490
<v Aaron van Wirdum>Yes, episode two was about Taproot. Yeah. But still, let's recap it a little bit.

00:40:51.710 --> 00:40:55.570
<v Sjors Provoost>So TL;DR, there is a way. As far as the blockchain is concerned, it doesn't

00:40:55.570 --> 00:40:59.270
<v Sjors Provoost>matter how you do it, what cryptographic trick you're using. As far as not losing

00:40:59.270 --> 00:41:01.950
<v Sjors Provoost>your coins, you want to make sure that you use a cryptographic trick that is

00:41:01.950 --> 00:41:04.870
<v Sjors Provoost>actually safe. Because from the consensus point of view, if the cryptographic

00:41:04.870 --> 00:41:08.650
<v Sjors Provoost>trick is not safe, you could lose your coins either by theft or by making them

00:41:08.650 --> 00:41:09.170
<v Sjors Provoost>unspendable.

00:41:10.430 --> 00:41:15.110
<v Sjors Provoost>and MuSig2 is a paper by the Blockstream folks and there's even a BIP for it now

00:41:15.110 --> 00:41:20.770
<v Sjors Provoost>that is basically it describes a procedure of how to make these

00:41:20.770 --> 00:41:26.210
<v Sjors Provoost>keys and they are n of n so 2 of 2 or 3 of 3 or 4 of 4

00:41:26.210 --> 00:41:31.450
<v Sjors Provoost>and it describes exactly how each of the participants come together and construct

00:41:31.450 --> 00:41:35.290
<v Sjors Provoost>the key and then how the participants come together and sign a transaction in a

00:41:35.290 --> 00:41:35.910
<v Sjors Provoost>way that's safe

00:41:36.070 --> 00:41:38.070
<v Aaron van Wirdum>yeah so basically

00:41:40.390 --> 00:41:44.210
<v Aaron van Wirdum>Taproot, we always call it Taproot, but I think the official name of the upgrade

00:41:44.210 --> 00:41:47.790
<v Aaron van Wirdum>was Schnorr Taproot, right? Because the other big thing it did was...

00:41:47.790 --> 00:41:48.310
<v Sjors Provoost>Add Schnorr.

00:41:48.470 --> 00:41:53.820
<v Aaron van Wirdum>Add Schnorr, Schnorr, another type of signature. And the sort of very simple way

00:41:53.820 --> 00:41:59.570
<v Aaron van Wirdum>of explaining how this would work is you have several... public keys

00:41:59.570 --> 00:42:04.070
<v Aaron van Wirdum>and you create several which also have several private keys of course and then

00:42:04.070 --> 00:42:09.130
<v Aaron van Wirdum>you create several signatures and you can essentially just mathematically add up

00:42:09.130 --> 00:42:13.670
<v Aaron van Wirdum>the public keys and you get a new public key and then you can also add up the

00:42:13.670 --> 00:42:18.310
<v Aaron van Wirdum>different signatures that you created with the different private keys and then

00:42:18.310 --> 00:42:23.690
<v Aaron van Wirdum>the signatures also add up to a valid signature for that valid combined public

00:42:23.690 --> 00:42:28.250
<v Aaron van Wirdum>key Right, that's that's exactly right. Yeah, so that's why you can, for example,

00:42:28.390 --> 00:42:32.850
<v Aaron van Wirdum>have three people, all three have their own public key. But then if they all

00:42:32.850 --> 00:42:37.850
<v Aaron van Wirdum>three sign off to a transaction, then their combined signatures would match their

00:42:37.850 --> 00:42:42.110
<v Aaron van Wirdum>combined public keys. and therefore you can spend it. All the while on the

00:42:42.110 --> 00:42:45.350
<v Aaron van Wirdum>blockchain itself, it looks like a very regular one out of one transaction.

00:42:45.710 --> 00:42:49.370
<v Sjors Provoost>Yeah, and there's the caveat there is that if you do it in the naive way, which

00:42:49.370 --> 00:42:52.510
<v Sjors Provoost>is just to add up the keys, which you can do from a mathematical point of view.

00:42:52.890 --> 00:42:56.470
<v Sjors Provoost>then it's not safe, but we can get into that some other episode or never.

00:42:56.690 --> 00:42:59.590
<v Aaron van Wirdum>Yeah, or maybe is there a one sentence explanation?

00:43:00.110 --> 00:43:05.470
<v Sjors Provoost>I mean, if you Google something like rogue key attack. So the idea is that I give

00:43:05.470 --> 00:43:11.290
<v Sjors Provoost>you my key and then you give me your key. But if you're mean, then you could

00:43:11.290 --> 00:43:15.570
<v Sjors Provoost>actually take my key and put a minus in front of it. And so you would use minus

00:43:15.570 --> 00:43:20.010
<v Sjors Provoost>my key. And so if I add my key to your key, that's zero.

00:43:21.220 --> 00:43:25.290
<v Sjors Provoost>Basically the effect of that. And that means you can steal the money. And of

00:43:25.290 --> 00:43:28.290
<v Sjors Provoost>course you wouldn't do it that way. You would probably add another key to it so

00:43:28.290 --> 00:43:31.770
<v Sjors Provoost>that I wouldn't be able to see it. But it basically boils down to that. If you

00:43:31.770 --> 00:43:37.090
<v Sjors Provoost>can take the negative of my key, you can steal my money. And that's prevented

00:43:37.090 --> 00:43:39.450
<v Sjors Provoost>with some tricks to make sure you can't do that.

00:43:39.730 --> 00:43:42.670
<v Aaron van Wirdum>Right. And that's a pretty decent one sentence explanation.

00:43:42.970 --> 00:43:46.430
<v Sjors Provoost>That's not the only way you can get fucked, but that is definitely the most.

00:43:47.570 --> 00:43:53.570
<v Aaron van Wirdum>Right. So MuSig, it spells M-U-S-I-G in case

00:43:53.570 --> 00:43:59.350
<v Aaron van Wirdum>anyone was wondering. It's short [unclear]. That is available in

00:43:59.350 --> 00:44:02.770
<v Aaron van Wirdum>Bitcoin now, right? People can do it if they want to since Schnorr is there.

00:44:02.930 --> 00:44:05.470
<v Sjors Provoost>I think if they have to, yeah, but they'd have to write their own wallet

00:44:05.470 --> 00:44:05.950
<v Sjors Provoost>basically.

00:44:07.190 --> 00:44:11.590
<v Aaron van Wirdum>Right, so it's available. I mean, we can't even know if people are using it

00:44:11.590 --> 00:44:16.390
<v Aaron van Wirdum>because it would just look like one out of one. But as far as you know, as far as

00:44:16.390 --> 00:44:18.910
<v Aaron van Wirdum>I know, there's no wallet that's actually using it now.

00:44:19.070 --> 00:44:19.230
<v Sjors Provoost>Nope.

00:44:19.640 --> 00:44:21.440
<v Aaron van Wirdum>Okay, so it's conceptually possible.

00:44:21.700 --> 00:44:24.720
<v Sjors Provoost>I think, though, that there are Lightning implementations that are using it or

00:44:24.720 --> 00:44:30.440
<v Sjors Provoost>are almost ready to use it because one nice use case, because the MuSig ritual,

00:44:30.680 --> 00:44:34.260
<v Sjors Provoost>as we could call it, is a bit complicated for humans to do, but it's very easy

00:44:34.260 --> 00:44:38.420
<v Sjors Provoost>for machines to do. So when two Lightning nodes talk to each other, they create a

00:44:38.420 --> 00:44:43.780
<v Sjors Provoost>two out of two multisig, and they can use MuSig for that. And it's relatively

00:44:43.780 --> 00:44:48.220
<v Sjors Provoost>straightforward for Lightning to add that. So that might already be happening or

00:44:48.220 --> 00:44:53.470
<v Sjors Provoost>happening soon TM. Now, the downside is it's N of N. And so there are other

00:44:53.470 --> 00:44:57.870
<v Sjors Provoost>proposals out there that will let you do M of N. So do a three or et cetera in

00:44:57.870 --> 00:45:00.910
<v Sjors Provoost>the same way that looks like one signature. Those I think are a bit more

00:45:00.910 --> 00:45:02.090
<v Sjors Provoost>experimental, but coming.

00:45:02.570 --> 00:45:06.430
<v Aaron van Wirdum>Are we still talking about MuSig or would this get a new name?

00:45:06.430 --> 00:45:07.850
<v Sjors Provoost>No, they would not be called. They would have a new name.

00:45:08.010 --> 00:45:13.110
<v Aaron van Wirdum>Okay. But it's essentially using the same Schnorr trick, right?

00:45:13.210 --> 00:45:16.470
<v Sjors Provoost>In the end, as far as the Bitcoin chain is concerned, it's just Schnorr. And in

00:45:16.470 --> 00:45:20.050
<v Sjors Provoost>the future, somebody can come up with completely different ways of doing this. So

00:45:20.050 --> 00:45:23.150
<v Sjors Provoost>that's the nice future-proof aspect of this.

00:45:23.490 --> 00:45:26.510
<v Aaron van Wirdum>What do you mean by completely new ways of doing this?

00:45:26.650 --> 00:45:30.510
<v Sjors Provoost>Well, some new algorithm. So MuSig2 has a specific way of saying, take your key,

00:45:30.570 --> 00:45:33.650
<v Sjors Provoost>then take the next key, and do this hash on this key, and do this hash on this

00:45:33.650 --> 00:45:37.090
<v Sjors Provoost>other key. And you can have a different way to do it, as long as the end result

00:45:37.090 --> 00:45:37.830
<v Sjors Provoost>is a Schnorr signature.

00:45:38.570 --> 00:45:39.450
<v Aaron van Wirdum>Sure. Okay, yeah.

00:45:40.110 --> 00:45:43.970
<v Sjors Provoost>And so the other thing to mention, and then I think we've pointed out everything,

00:45:44.230 --> 00:45:48.670
<v Sjors Provoost>is that you can combine these two things. So you can use... In the

00:45:48.670 --> 00:45:54.070
<v Sjors Provoost>OP_CHECKSIGADD opcode, you don't have to put a single signature in there. You can

00:45:54.070 --> 00:45:58.950
<v Sjors Provoost>also put a Schnorr threshold signature or multisig in there. So you could have

00:45:58.960 --> 00:46:02.210
<v Sjors Provoost>a trillion out of a trillion multi… one out of trillion multisig, for example.

00:46:03.110 --> 00:46:07.530
<v Sjors Provoost>where the way to spend it, I don't know, some sort of weird threshold signature

00:46:07.530 --> 00:46:12.690
<v Sjors Provoost>inside a tapscript. So you'd have, you need one out of a thousand keys in order

00:46:12.690 --> 00:46:17.010
<v Sjors Provoost>to create a regular Schnorr signature that is then part of one of the leaves that

00:46:17.010 --> 00:46:23.010
<v Sjors Provoost>is part of a million different leaves. Or sorry, that is one. So again, one out

00:46:23.010 --> 00:46:27.840
<v Sjors Provoost>of a thousand signatures. Keys will allow you to produce a valid Schnorr

00:46:27.840 --> 00:46:31.400
<v Sjors Provoost>signature that will look like a one of one. You put that inside the

00:46:31.400 --> 00:46:37.380
<v Sjors Provoost>OP_CHECKSIGADD in one of the leaves, which each have a thousand possible keys,

00:46:37.420 --> 00:46:41.320
<v Sjors Provoost>and then there are a thousand leaves. So that is a one out of a billion multisig.

00:46:42.540 --> 00:46:47.940
<v Aaron van Wirdum>Could we make a multisig that's big enough for all of humanity and sort of to

00:46:47.940 --> 00:46:51.280
<v Aaron van Wirdum>protect us from the Martians when they come?

00:46:48.240 --> 00:46:50.620
<v Sjors Provoost>Yeah, I mean this would be a one out of a billion…

00:46:51.880 --> 00:46:54.460
<v Aaron van Wirdum>What would be the best threshold for that, do you think?

00:46:54.640 --> 00:46:59.340
<v Sjors Provoost>Well, the opposite would be like a 4 billion out of 8 billion multisig.

00:46:59.520 --> 00:47:01.740
<v Aaron van Wirdum>So just majority, you think that's good?

00:47:01.940 --> 00:47:05.740
<v Sjors Provoost>And so that would definitely require something like a MuSig or probably a

00:47:05.740 --> 00:47:10.160
<v Sjors Provoost>threshold signature because you can only have a thousand in each of the script

00:47:10.160 --> 00:47:16.080
<v Sjors Provoost>leaves. So each of these 1,000 keys will have to represent the majority of

00:47:16.080 --> 00:47:21.730
<v Sjors Provoost>a million people or so in order to get there. And the question is, can you make

00:47:21.730 --> 00:47:27.150
<v Sjors Provoost>an algorithm that lets a million people combine their keys and signatures and

00:47:27.150 --> 00:47:30.390
<v Sjors Provoost>produce a signature? I don't know if that's possible because a lot of these

00:47:30.390 --> 00:47:34.550
<v Sjors Provoost>algorithms, they get exponentially slower. So as you add more participants, it

00:47:34.550 --> 00:47:37.850
<v Sjors Provoost>doesn't take twice as long. If you add more participants, it might take four

00:47:37.850 --> 00:47:43.720
<v Sjors Provoost>times as long. And so maybe if you add a million participants, it gets two to the

00:47:43.720 --> 00:47:44.980
<v Sjors Provoost>times a million harder.

00:47:45.280 --> 00:47:49.080
<v Aaron van Wirdum>Yeah, but maybe not if it's a million out of a million, right? Then it just

00:47:49.080 --> 00:47:49.620
<v Aaron van Wirdum>takes...

00:47:49.620 --> 00:47:54.280
<v Sjors Provoost>Maybe that's easier, but it's still a question of... If you look at MuSig, I

00:47:54.280 --> 00:47:58.940
<v Sjors Provoost>don't know what the pattern there is, but my guess is that making MuSig from,

00:47:58.940 --> 00:48:04.410
<v Sjors Provoost>say, two of two... versus making a MuSig of four of four is not twice as slow

00:48:04.410 --> 00:48:08.750
<v Sjors Provoost>it's like four times as slow or eight times as slow so it grows exponentially or

00:48:08.750 --> 00:48:09.370
<v Sjors Provoost>some other thing

00:48:10.740 --> 00:48:12.580
<v Aaron van Wirdum>Okay, so that's not…

00:48:12.580 --> 00:48:15.920
<v Sjors Provoost>but you'd have to ask the Blockstream cryptographers they probably can give you a

00:48:15.920 --> 00:48:20.990
<v Sjors Provoost>chart that shows exactly what happens when you do a million of them? right? my

00:48:20.990 --> 00:48:24.610
<v Sjors Provoost>guess is it'll get exponentially hard and it'll it'll break down but somebody

00:48:24.610 --> 00:48:28.780
<v Sjors Provoost>might come up with a way to do a and you definitely don't want to do N of N with

00:48:28.780 --> 00:48:31.920
<v Sjors Provoost>the whole planet, because then if one person doesn't show up which is pretty

00:48:31.920 --> 00:48:33.100
<v Sjors Provoost>likely with a big population…

00:48:33.100 --> 00:48:36.960
<v Aaron van Wirdum>so that was that was my first question like what do you think would be a good

00:48:36.960 --> 00:48:41.980
<v Aaron van Wirdum>threshold if we want to protect ourselves from you know we want to protect our

00:48:41.980 --> 00:48:46.780
<v Aaron van Wirdum>funds from martians and with humanity like what threshold would you opt for?

00:48:46.780 --> 00:48:51.190
<v Sjors Provoost>I don't know because it depends on what the martians are capable of doing. if

00:48:51.190 --> 00:48:54.850
<v Sjors Provoost>they can just read all the private keys then no threshold helps. so

00:48:56.070 --> 00:48:56.730
<v Sjors Provoost>I don't know.

00:48:57.180 --> 00:49:02.880
<v Aaron van Wirdum>Well, no, the problem is more that maybe some of us will be corrupted by the

00:49:02.880 --> 00:49:08.080
<v Aaron van Wirdum>Martians. So we want to be careful that we, you know, if we let anyone spend the

00:49:08.080 --> 00:49:12.320
<v Aaron van Wirdum>funds, then the Martians only have to corrupt that specific person. So that's

00:49:12.320 --> 00:49:17.680
<v Aaron van Wirdum>probably not good. But how many humans would you trust not to be corrupted?

00:49:17.840 --> 00:49:22.440
<v Sjors Provoost>It really depends on how the Martians operate. So yeah, I think we've talked

00:49:22.440 --> 00:49:25.350
<v Sjors Provoost>enough. So unless you have anything to add or summarize?

00:49:25.350 --> 00:49:29.250
<v Aaron van Wirdum>No. Have we discussed anything? Yeah. You think we've had everything? then I'm

00:49:29.250 --> 00:49:30.470
<v Aaron van Wirdum>good with this episode, Sjors?

00:49:30.470 --> 00:49:32.950
<v Sjors Provoost>Excellent. Well, then thank you for listening to Bitcoin,

00:49:32.950 --> 00:49:33.730
<v Aaron van Wirdum>Explained.

