Discreet Log Contracts - Episode 53
Ep. 53

Discreet Log Contracts - Episode 53

•

Episode description

In this episode of Bitcoin, Explained, hosts Aaron van Wirdum and Sjors Provoost are joined by resident sidechain and Layer Two expert Ruben Somsen again, this time to discuss Discreet Log Contracts (DLCs).

Discreet Log Contracts are a type of smart contracts for Bitcoin, first proposed by Lightning Network white paper coauthor Tadge Dryja. In essence, DLCs are a way to perform bets— but this means that they can ultimately be leveraged for all sorts of financial instruments, including futures markets, insurances and stablecoins.

At the start of the episode, Aaron, Sjors and Ruben discuss what can be considered a type of proto-DLC, namely a multi-signature setup for sports betting where two participants add a neutral third party (an “oracle”) that can resolve the bet one way or the other if needed. The trio explains, however, how this solution comes with a number of downsides, like the difficulty of scaling it.

From there, Aaron, Sjors and Ruben go on to explain how DLCs solved these problems using a setup that resembles payment channels as used on the Lightning Network. When structured like this, they explain, oracles merely need to publish a cryptographically signed message about the outcome of an event, which can be used by the winning participant of the bet to create a withdrawal transaction from the payment channel. Finally, Ruben explains how the original DLC concept could be streamlined by using adaptor signatures, a sort of “incomplete signatures” that can be made complete using the signed message from the oracle. With adaptor signatures, DLCs no longer require a separate withdrawal transaction, as the winner can claim funds from the payment channel directly.

Transcript

Download transcript (.vtt)
0:19

Aaron van Wirdum Live from Utrecht, this is Bitcoin Explained.

0:23

Sjors Provoost Hello.

0:24

Aaron van Wirdum Hey, Sjors.

0:24

Sjors Provoost What's up?

0:25

Aaron van Wirdum I'm good. And welcome back, Ruben.

0:28

Ruben Somsen Thank you. Good to be back.

0:30

Aaron van Wirdum Back-to-back episodes for you?

0:32

Ruben Somsen Yeah, sure. Almost. Or has there not been an episode in between? I don't even know.

0:36

Aaron van Wirdum We skipped last one. So yeah, no, it's truly back-to-back for you this time.

0:40

Ruben Somsen All right, cool.

0:41

Aaron van Wirdum Happy you are back because we're going to discuss a particularly... interesting and at least in my opinion, pretty complex topic. We did have a, we had a call the three of us before we started recording this, this afternoon, and uh, it was basically a call between the two of you because I tapped out after like a minute and especially when it became mathematical, when the mathematics came into play, that's where it went a little bit over my head. So let's see how we can manage this episode today.

1:14

Sjors Provoost Yeah, for me, it was also just confusing initially, especially reading some of the documentation that explains some of the assumptions behind it and then just skips all the details that I care about to actually understand it. It's not the full math, but it's like, ah, tell me one more thing, tell me one more thing. But then if you're listening to a high-level talk by somebody who's not trying to make it technical, they're not filling out the details. And then if you want to read... an actual spec gets too technical.

1:41

Aaron van Wirdum So the thing we are going to discuss is Discreet log contracts, also known as DLCs.

1:49

Sjors Provoost Yeah, and it's spelled discreet E-E-T, which kind of means careful in what you're saying, versus discrete with E-T-E, which is single digits, like a discrete number. But it's a pun. Yeah, you cannot say in audio because it sounds the same.

2:12

Ruben Somsen I think the end result is that people are just confused, but it's a, it's funny for those who are in the know.

2:18

Aaron van Wirdum Yeah, anyway, so let's start with a short summary of what Discreet long—log contracts actually are. I would summarize it as there are, they are essentially smart contracts for Bitcoin and a little bit more specifically they are bets, essentially. Yeah. And the interesting thing about bets is that many types of financial contracts are essentially bets, even if we don't normally think of them as bets. You, you can sort of distill them as bets

2:49

Sjors Provoost like, right, they're not gambling necessarily. They could just be saying I think the dollar is going to go up, uh, so I want a derivative project, uh, product that follows the dollar price and you could call that betting, but it's, it's, it's a sane thing to do even as, as a non-gambler

3:03

Aaron van Wirdum Yeah, yeah, exactly. Or like an insurance, if you, if you're insuring your house in a way you're sort of betting that your house will burn down. And then if you lose the bet and you didn't, your house is still there, you're kind of happy, but it did cost a little bit of money. So that's sort of the down payment. Well, if your house burns down, you win the bet and you get all this money. So a lot of financial products are essentially bets. So that's why it's interesting to think of how can we bring this sort of betting to Bitcoin. And then what we really want or, you know, the essence of smart contracts, what smart contracts are ideally at least, is that these bets are executed automatically, right?

3:48

Sjors Provoost Yes. And in the case of blockchain, not just automatically, but also in a way that does not require any trust. Now, just a spoiler. There is this thing called the Oracle problem. And we are not solving the Oracle problem. The Oracle problem basically means that if you have anything that relies on information outside the blockchain, well, anything except the knowledge of a private key or hash, If you need any kind of information from outside the blockchain, like the weather or the dollar price, there has to be an oracle that knows this thing. And the blockchain has no idea if the oracle is lying or not. And we're not going to solve that. So everything we're doing here still assumes that the oracle is honest. And then there are some tricks that you can use to make it slightly more honest. But it's not a perfect solution.

4:34

Aaron van Wirdum Well, that is kind of what we're doing, right? We're sort of trying to minimize the trust in the Oracle or at least a little bit.

4:41

Sjors Provoost Well, we're also trying to reduce the workload for the Oracle, and increase the plausible deniability for the oracle.

4:47

Ruben Somsen Yeah, that's I think an important point where the oracle doesn't have to be directly involved with your bets. It can just post the outcome and then you take the outcome and you resolve your bets with that outcome without the oracle specifically having to know that you were even betting.

5:02

Sjors Provoost Right, and that also makes the oracle hopefully more neutral. So again, you cannot guarantee that.

5:07

Ruben Somsen Yeah.

5:08

Aaron van Wirdum Okay, so... Before we get into it, let's pick a very nice and easy sort of bet that everyone will understand is a bet.

5:14

Sjors Provoost If it's going to rain tomorrow.

5:16

Aaron van Wirdum I don't like that one.

5:18

Sjors Provoost Especially because the answer tends to be yes here.

5:22

Aaron van Wirdum Let's go for the World Cup final. We'll have the World Cup later this year. Let's assume the World Cup final is the Netherlands versus Germany, and now we're gonna bet on the winner of the World Cup final. Yeah, all right.

5:33

Sjors Provoost Yeah, all right. Trivial, but yeah.

5:36

Aaron van Wirdum That will be the bet throughout this episode.

5:39

Ruben Somsen Obviously, the Netherlands is gonna win, but okay.

5:40

Aaron van Wirdum The Netherlands versus Germany. All right, in the World Cup final. So the very— let's start at the beginning. We want to solve this problem, um, Ruben and Sjors, you want to bet against each other. Ruben, you're betting on the Netherlands apparently. Sjors, you're betting on Germany. Now we need to make this trustless somehow. I think the most basic solution is to create a multisig. Well, you could create a multisig between the two of you, two of two, but then you have the obvious problem that the loser might not cooperate, right?

6:13

Ruben Somsen Yeah.

6:14

Aaron van Wirdum So if we take the next step... we'll take it one step further. We'll introduce the oracle that's gonna be me. Both of you trust me. So now we create a two out of three multisig and now the final has been played. The Netherlands has won at this point. Either Sjors can cooperate with Ruben to get all the money in the multisig to Ruben, or if Sjors doesn't cooperate, then Ruben can contact me. I'll step in. I'll acknowledge that the Netherlands won the final. So I'll provide my signature and I'll help Ruben get the money. Now, because I can do this, and because both of you know I can do this, and Sjors in particular, you know for a fact that I can do this. So at this point, there's really no reason for you to obstruct. You might as well just cooperate, right?

7:01

Sjors Provoost Yeah, exactly. And so this could just be a trusted friend or this could be the actual organization that runs the soccer match that has no reason to lie about the result and is subject to some scrutiny. But the problem is then, of course, if you want to do a contract with this World Cup organizer, you know... You need to involve them. They actually need to sign something specifically for you. And they may not want to do that because, hey, then they're cooperating with sports betting. Or they don't feel like doing that. I don't know.

7:35

Aaron van Wirdum Yeah, what you're saying is that there are a number of problems with this solution. One of them is it requires me to actually be actively involved in your bet, even before the bet is made. I need to provide my public key and I sort of need to know what you guys are doing and I need to agree with that. And then after the bet, you might need my help and I might do stuff. If it's just two of you, that's maybe acceptable, but now tens of thousands of people want to make the same bet, and I would have to provide my public key to tens of thousands of people, and now it starts to become a lot of work, right?

8:12

Sjors Provoost And they don't even know what you exactly are betting, right? So they would have to read the terms and conditions of each of your bets to even know which side to have to sign. Because you can't tell by the public key which side I, Ruben, bet it on. So yeah, it's pretty tedious.

8:27

Aaron van Wirdum Yeah, and then there's the problem that I need to know what you guys are doing, which is sort of bad for your privacy. I need to know which coins are yours and what they're used for. Are there more problems?

8:38

Ruben Somsen Well, I think you summed it up pretty well.

8:41

Sjors Provoost That said, I think it's possible. It's not impossible.

8:45

Aaron van Wirdum Yeah. Obviously, I could try to cheat by, for example, Sjors could try to bribe me. He could contact me, say, hey, Aaron, let's share the prize and forget about Ruben. Let's share the prize between us. And, you know, I could be corrupted in this way. It's not a problem. Lots of problems with this solution, even though it technically works.

9:06

Sjors Provoost Yes.

9:07

Ruben Somsen I will say there's an upside to it as well, which is that if the bet somehow is unclear or I don't know, there's a meteor crashes on earth and the finals are canceled. And now we're like, oh, what are we going to do with our bets? Then you being a human, you can maybe, you know, sort of have, you can make a decision on our behalf. That's maybe one small advantage, but I don't think it's a great one.

9:32

Sjors Provoost Okay, method two. Method one.

9:34

Aaron van Wirdum Yeah, so let's try to improve on this solution. Sjors, you wanted to improve on the solution.

9:39

Sjors Provoost Yes. So today I learned about a concept, which I had not followed, and it's called Reality Keys.

9:46

Ruben Somsen Yeah.

9:47

Sjors Provoost And this is actually a pretty simple idea. It takes it one step further.

9:52

Aaron van Wirdum This is an existing thing.

9:54

Ruben Somsen It was an existing thing.

9:55

Aaron van Wirdum This was an existing thing.

9:56

Ruben Somsen It existed between 2014 and 2018, and it just disappeared. And I don't think a lot of Bitcoiners remember, but it was actually kind of a really awesome little platform.

10:08

Sjors Provoost But the general idea still exists. Of course, you can do this. So what the World Cup leaders in this case probably, they would be the Oracle, what they would do is they would say, here is two public keys. Public key A, or public key N, I guess, and public key D, as in the Netherlands public key and the Germany public key. And depending on who wins, we will publish one of those keys. We will publish the private key of one of those two keys.

10:36

Aaron van Wirdum Right. So either winner, both winners, have a public key attributed to them, essentially, by Reality Keys, by whoever is running this. And... based on the winner, depending on who wins, they will publish one of the corresponding private keys.

10:53

Sjors Provoost Yeah, and they promised to only publish one. So in that case, Ruben and I set up our little multisig with, again, two out of three, I think, the threshold, one key of you, one key of me, and then... The Germany key, I guess, would send it to me and the Netherlands key would send it to you. It's a little bit more complicated.

11:14

Aaron van Wirdum Well, essentially, I guess you would set up two out of three multisigs, right?

11:18

Ruben Somsen You can do, well, you can make it a two of two where one is my key plus the Netherlands key and the other key is Sjors plus the Germany key.

11:27

Aaron van Wirdum That also makes sense, yeah.

11:28

Ruben Somsen But the thing is that Reality Keys doesn't care. They're just going to issue the key, and we get to deal with that key whatever we want. So we can set it up in any way that we like, but that would be a plausible way for it.

11:40

Sjors Provoost Yeah, I guess we put the money into the multisig and then we take it out. We have two different pre-signed transactions, right? One that takes it out or something like that.

11:49

Ruben Somsen Yeah, you probably want two out of three where the third key is you and me together. So, well, no, that might also not make sense. Yeah, I'm not sure. But anyway, you need to have a fallback for if Reality Keys doesn't issue any key whatsoever. So you need to take that into account as well, which we didn't thus far.

12:07

Sjors Provoost And there's another problem that they might actually reveal both keys, which is a problem. And that's not a problem in the first situation because they're just putting the signature. I guess they could also just sign two transactions. Then you have to fight over it, with, you know, replaced by fee.

12:23

Ruben Somsen Well, yeah, you could have two bets with the interactive Oracle and it could resolve those two bets in a different way, right? Even though there's one outcome.

12:32

Aaron van Wirdum I think we're botching this. I think the simple solution would be to have three out of four, right? And then you both sign. Am I saying this right? What's the solution there, Ruben?

12:42

Sjors Provoost There has to be a different result depending on which public key gets published.

12:46

Aaron van Wirdum Yeah.

12:46

Sjors Provoost If it's just three out of four, the script doesn't care which three. So it would just send the money to one person regardless of who wins. So you need to think about this a little bit.

12:56

Ruben Somsen Two out of four, I think.

12:58

Sjors Provoost Anyway.

13:00

Aaron van Wirdum Two out of four, that makes sense.

13:01

Ruben Somsen I think that works. I think I sold it.

13:03

Aaron van Wirdum That's the one.

13:04

Ruben Somsen Okay.

13:05

Aaron van Wirdum All right, we figure it out. Two out of four. However, we're still not... So yeah, to clarify two out of four because...

13:12

Ruben Somsen Then Oracle can steal though. There's still a problem. Oh yeah.

13:16

Aaron van Wirdum It sounded very simple on paper until we started to actually figure this out live on the podcast.

13:22

Ruben Somsen Yeah, the platform is down. You can't really test it anymore. But what was interesting about the platform is that it actually worked with APIs. So it was just connected to a bunch of APIs. And you could then just tell it to pay attention to that API and publish a key depending on an event from that API. So it was semi-automated in that regard. So it was kind of a nifty little platform that I think is very similar. But one sort of downside, I think, to that platform that we're going to address as well is that it was mostly centered around binary bets, right? Either one party or the other party is going to win or the price of Bitcoin is going to be X at this date, things like that. But so not very, you wouldn't have these kind of bets with a granular outcome where depending on the price, I get this amount of Bitcoin and Sjors gets some other amount of Bitcoin.

14:11

Sjors Provoost Right. And especially when you're talking about, say, the US dollar price, if that's what you're betting on, then it could be have all sorts of numbers involved. Okay.

14:21

Aaron van Wirdum So anyways, Reality Keys. I don't understand how it would actually work, but there's probably some way to make it work.

14:27

Ruben Somsen I'm sure there's a way.

14:28

Aaron van Wirdum Where the Oracle just publishes a private key depending on the winner. But we just discussed that as a sort of stepping stone for the actual subject of this specific podcast, which is DLCs. And that's sort of what we're getting at now, right? So who wants to give DLCs a first go?

14:47

Ruben Somsen I'll start and then maybe Sjors can continue from where I begin.

14:52

Aaron van Wirdum Right.

14:53

Ruben Somsen So I think the DLC paper came from Tadge Dryja, who currently works on Utreexo, so a very interesting project as well, which I think we discussed.

15:03

Sjors Provoost We have.

15:03

Ruben Somsen Yeah.

15:04

Aaron van Wirdum Also one of the co-authors of the Lightning White Paper.

15:07

Ruben Somsen Yeah, and Lightning Network Paper as well. Yeah, good points. So the idea there is to basically have the bets be a channel where you lock up your funds together with a counterparty. And then from that state where you have a channel. So it's very similar to a Lightning channel, right? There's two of two, and you would have to have some kind of transaction where you can exit out of it in case you disagree or something.

15:34

Aaron van Wirdum So hang on. In this specific case, essentially Ruben and Sjors, the two of you would open a payment channel, which looks a little bit like a Lightning channel.

15:44

Ruben Somsen Yeah.

15:45

Aaron van Wirdum Right? Okay, go on.

15:46

Ruben Somsen The initial setup is the two of two.

15:47

Aaron van Wirdum Which essentially means you're both depositing funds in this channel, right?

15:50

Ruben Somsen Yes. But the way that you can get the funds out is sort of the key difference. Where now in order to get your funds out, you have a bunch of transactions that are basically bet outcomes. And so in our example, a World Cup, Netherlands versus Germany, we would have two transactions basically. One transaction would be a transaction where Sjors wins. So he can publish his version of the transaction and then he can spend that money with both his key plus the key of the oracle where the oracle says that Germany won. But then there's also a time lock because if Sjors publishes his transaction, but that transaction is actually not the one that the Oracle published, well, then basically what happens is that he can't spend it because he doesn't have both keys. He only has one of the keys. And then the time lock expires. And the time lock says that after the time lock expires, I get to take the money.

16:52

Aaron van Wirdum Okay, so hang on. In a Lightning channel, if I'm remembering correctly, which I think I am, both of you would essentially, you've exchanged signed transactions, right? You both have a different version of the redemption transaction. Am I saying that right?

17:10

Ruben Somsen Yeah, yeah.

17:11

Aaron van Wirdum And so in this case, both of these transactions depend on the outcome of the match, essentially. So you would have the transaction that should be broadcast if the Netherlands wins, Ruben. And then Sjors has a slightly different version of an almost identical transaction that he should broadcast if Germany wins. Right?

17:33

Ruben Somsen Yeah.

17:33

Sjors Provoost And in both cases, if we happen to broadcast the wrong one... which, you know, we don't have to do, but then the other side can just take the...

17:42

Aaron van Wirdum Yes, this is what Ruben was just explaining. So the Netherlands won in our example and Sjors bet on Germany. So Sjors has the transaction that he should broadcast only if Germany wins, but he broadcasts it anyways. The reason he can't actually claim the funds is because he needs something from the Oracle in combination with his own signature in order to actually claim the funds, right?

18:06

Ruben Somsen Yes.

18:06

Aaron van Wirdum So he— because he can't do that now a time lock is ticking, yeah, it's going to clock out at which point the money is sent to you Ruben.

18:16

Ruben Somsen Yes.

18:16

Aaron van Wirdum So that's sort of a strong disincentive for Sjors to try to claim the money even though he didn't win.

18:22

Ruben Somsen Yes.

18:23

Aaron van Wirdum Okay, so this...

18:24

Sjors Provoost It's useful to know here that a transaction has inputs and outputs and so the transaction that both of the transactions that go out of this pot that we put the money in or this channel both of them have the same inputs so both of us can just throw it on the chain because they you know. But the outputs are different. And so we need another transaction to actually take the money to really own it. And that's where the Oracle signature comes in.

18:47

Aaron van Wirdum Right. So let me ask about it. So the Netherlands won. Ruben, you bet on the Netherlands.

18:52

Ruben Somsen Yeah.

18:52

Aaron van Wirdum So we just gave the example where Sjors is trying to cheat. Let's forget about that. Now you're just broadcasting the legitimate transaction.

18:59

Ruben Somsen Yeah.

18:59

Aaron van Wirdum Which requires now a signature from you. As well as what's the other thing exactly?

19:06

Ruben Somsen Yeah. So really what it is, and we have to go into more detail here, but essentially it is two keys. One is mine and the other key comes from the Oracle.

19:16

Aaron van Wirdum Wait, wait, wait. You're saying key. Do you mean key or do you mean signature?

19:20

Ruben Somsen I mean an actual key. Yeah. So when I send my transaction to the Bitcoin blockchain, there's going to be an output and the output is encumbered by a key. And that key is the combination of my key and a key that is provided by the Oracle. And I basically take both keys. When the Oracle reveals his private key, I get that private key. I combine it with my private key. And that combined number is what I use to sign the transaction and then actually take the money. And I have to do that because if I don't do that, then the time lock expires and Sjors gets to take it.

19:56

Sjors Provoost Yeah, to go back to that encumbering it's, it's encumbered, of course, by the public key. Well, it's encumbered by… So it's basically saying anybody with this public key can spend it and this public key happens to be your public key plus a public key that we have pre-computed that belongs to the Oracle.

20:11

Ruben Somsen Yeah.

20:13

Sjors Provoost And this is sort of where the magic comes in because it's not the same as the previous mechanism. The Oracle is not actually publishing a private key like a private key that holds funds. But we're actually getting it from the signature. And this is kind of where things get a little funky, because a signature is really two numbers. It is essentially a public key, or it's not a public key, but it's a point, a point on the elliptic curve, and it is a number. And in general, when you have a number, you can treat that as a private key. And when you have a point, you can treat that as a public key. And the reason is that you can very easily go from a number to a point. but you cannot go from a point to the corresponding number. So that's why the private key is the number and the point is the public key. But in the case of the signature, we don't interpret it that way. So we're seeing a point and we're seeing a number, but we can if we want to, and that's actually what we're doing here. So we're interpreting the second part of the signature, which is a number. We're interpreting that as a private key. And that is the private key that we're missing. And now the nice thing is that the Oracle can sign anything, really. They can publish any signature they want. And depending on exactly what message they sign, we're going to get a different private key in that signature. And so if they publish Germany, then I get a private key. Then that private key that the Oracle just published is useful for me. It allows me to redeem the coins. If the oracle wrote Germany in the message, then Ruben gets the private key that is useful for him and of no use to me. And to make it even nicer is if they publish both, well, now we can actually punish the oracle because the oracle also has its own private key. And by this, I mean the real private key that he would use to protect his own funds. And that now becomes known. Because there's a rule that if you publish, basically, if you make two, if you sign two different messages this way, you're giving away your private key.

22:31

Ruben Somsen Yeah, that's exactly right. So maybe to sort of give a...

22:35

Sjors Provoost But that's maybe a little bit tangential.

22:37

Ruben Somsen Yeah, to give sort of a high-level summary here is that basically we just get the Oracle to pre-commit to what it's going to sign. So it's going to say like, look, I'm going to sign either Germany or the Netherlands. And we calculate ahead of time what that signature is going to look like. And we use that in our scripts, in our transactions.

23:03

Aaron van Wirdum Well, you can know what the signature will look like exactly, right?

23:06

Sjors Provoost No, we know one part of that signature, what it's going to look like.

23:09

Ruben Somsen Yeah, we know sort of, we know the, as Sjors stated, you can treat the signature as a key. And so we know the public key, but we don't know the private key, basically, of the signature. So we treat the signature as a key. And we only know the public key. We don't know the private key until the Oracle actually signs.

23:32

Aaron van Wirdum All right, well, I didn't get all of that. Maybe some of our listeners did. I do want to, at the risk of confusing our listeners even more, I actually want to take one step back. So we were discussing this Reality Keys idea where the Oracle would just publish a private key. Why can't we just use that in this setup? So the Netherlands won, Ruben, you're now publishing your transaction that allowed you to withdraw the funds, which... requires your signature. And why don't we just say it also requires a signature from a private key, which is for the [unclear] specifically.

24:10

Ruben Somsen Yeah.

24:10

Aaron van Wirdum Like we were speaking out loud where we were at that step of the podcast and we were budging it, but this actually seems to make sense to me. Like this would actually work, right? Yeah.

24:18

Ruben Somsen So I think the first thing to point out is that, yes, that works. So if you're confused about everything that we said, you can just think of it in that way.

24:26

Aaron van Wirdum Right.

24:26

Ruben Somsen So that's, I think, like the first point. Second point is there are two subtle differences. And the first difference is what Sjors explained earlier, where if the Oracle signs two things, we can punish the Oracle by extracting their private key.

24:42

Aaron van Wirdum Right, yeah. So if...

24:45

Sjors Provoost So the Oracle would say in this case...

24:47

Aaron van Wirdum If the Oracle would publish both results for whatever reason, then there's this mathematical trick where you can combine the signatures and from there derive the actual private key from the actual Oracle. Assuming that the Oracle put up some funds there to prove that it won't cheat, that's how you're sure that the Oracle will only publish one result, right? That's the point here.

25:11

Ruben Somsen Yeah.

25:11

Aaron van Wirdum Right. And then there was another solid point I think you were going to mention, Ruben.

25:15

Ruben Somsen Yeah. And the second point is sort of a smaller one that probably not everybody appreciates, but it's just less data, basically. So the Oracle can basically commit to what it's going to reveal in less data than you would need if you would create a public key for every bet event.

25:35

Sjors Provoost Well, and this becomes especially important if you're doing something like predicting the price of the US dollar in Bitcoin. Because you might want to publish a six-digit number. And that means, you know, hundreds of thousands of public keys that you would have to publish for each possible value. And you'd have to pre-sign transactions for each of these possible values.

25:52

Ruben Somsen Yeah. Well, not necessarily because you can do it in binary, which makes it a lot less.

25:58

Sjors Provoost I guess we'll get to that.

25:58

Ruben Somsen We'll get to that later. Yes.

26:00

Sjors Provoost Okay. So maybe... Fun to just dive into a little bit more detail for those who do understand the math better than we. Do we? Yeah, so there's a couple of things that the Oracle publishes or that are known here. If you look at what a signature is, it's like an equation, essentially. If I can read it out loud, you have on the left side of the equation, you have S times G, where S is the signature. G is the, what's it called?

26:33

Ruben Somsen Generator.

26:34

Sjors Provoost Is a generator. Now, the generator is a publicly known universal number that all of Bitcoin uses. So that's a number that everybody knows. So we only have one unknown thing on the left side.

26:43

Ruben Somsen Yeah.

26:43

Sjors Provoost And then on the right side, we have capital R. And R is actually... something that the oracle is going to reveal before the bet. So they're going to say, this is my R. So again, we have something that we already know. Then we have...

26:57

Ruben Somsen The capital R meaning it's a curve point.

27:00

Sjors Provoost Yes. And then the next part of the equation is plus the hash of R concatenated by the message. So the message is something we already said. We don't know what the message will be, but we can enumerate all the possible messages. We can enumerate M is Germany or M is Netherlands. And we're hashing that with R and we know R. So that's all known. And then there's times P, capital P. And P is the public key of the Oracle, which they've also published. So the Oracle will say, hey, I'm a Bitcoin related Oracle. So you have to assume G is the generator as we know it in Bitcoin. Here's my public key. And by the way, this public key belongs to a Bitcoin address and there's a million dollars on it. So I'm not going to do anything bad. And here's an R that I'm going to use for this specific bet. So you have to have a new R for every bet. But in this case, if it's Netherlands, Germany, here's the R for that. And so that equation that I just read out loud really only has one real unknown, and that's lowercase s. And if you have an equation with only one unknown, well, then you're quite happy. Right?

28:09

Ruben Somsen Yeah.

28:10

Sjors Provoost Except in this case, you cannot actually derive the private key because as we said, you cannot go from a public key to a private key. So anyway, that's just to say that if you really looked at it and you had a little bit more time and you could see it in front of you, you could just see it's an equation with some unknowns and it's not that hard.

28:26

Ruben Somsen Yeah.

28:27

Sjors Provoost And so then when the oracle actually signs a message, they let you know which M they picked. That's not going to be too much of a surprise. It's going to be the Netherlands. And then it's going to actually put down the signature, and that reveals this lowercase s. That was the only missing part from our equation. And we use that to do our own signature.

28:50

Ruben Somsen Yeah.

28:52

Aaron van Wirdum Okay, so let's bring this back to the real world a little bit. We started with the example where Sjors and Ruben, the two of you, are betting on the winner of the World Cup and I was part of a multisig who would help in case one of you tried to obstruct. And then we mentioned some of the problems with that. Now we have this new solution which we just described, which I sort of get and the two of you seem to get it pretty well. So the benefits here are that the FIFA who's organizing the World Cup, they can always just publish a signed message of the winner.

29:30

Ruben Somsen Yeah.

29:31

Aaron van Wirdum And this can be used by anyone, right? So the FIFA does not need to be part of any multisig. They do not need to have any active involvement. They do not even need to know that a bet took place at all.

29:44

Ruben Somsen Yeah.

29:44

Aaron van Wirdum All they need to know is that they need to sign a message and this will allow anyone to create bets on their own accord, right?

29:51

Ruben Somsen That is correct.

29:52

Aaron van Wirdum Is that...

29:53

Sjors Provoost And optionally, they can publish, they can post a collateral that if they cheat... then they lose a collateral. But that's not essential for the algorithm.

30:01

Ruben Somsen Yeah.

30:01

Aaron van Wirdum Right. And then I think another benefit here is that if the FIFA would try to cheat for whatever reason, if they would announce the wrong winner, then that's also very obvious and publicly known to anyone. So now everyone knows we shouldn't rely on them to settle our bets for the next World Cup.

30:21

Sjors Provoost Yeah, which might be more difficult to prove in the earlier scenarios, right, where they... where they just manually sign one of our sides. We don't really, you know, you don't really know what was going on there.

30:31

Ruben Somsen I think it's still solvable because you can get them to commit to what they're going to do and then you can reveal that they said they were going to do x if this happened and they didn't. So, okay, it's probably solvable either way, but uh, it's a little nicer here, it's more formalized.

30:44

Aaron van Wirdum Okay, okay, so this message that FIFA is broadcasting this can be used as we explained in combination with your own bets, depending on who won, you publish the original transaction that you have. Then you use this signature from the FIFA, combine it with your own signature. Does this require Schnorr, by the way? Does this require Schnorr signatures?

31:05

Sjors Provoost It's easier.

31:06

Ruben Somsen It— so the, the oracle signs with Schnorr signatures because, uh, that's the, because Schnorr signatures are linear and that's how you can do the thing that Sjors just explained. Well, that's how you can, that's how you can calculate ahead of time what the expected signature is going to be, the public key of the expected signature.

31:26

Aaron van Wirdum Right.

31:26

Ruben Somsen And you need Schnorr for that. You can't do that with the ECDSA, I believe. But on the side of the betters, you can use ECDSA.

31:36

Sjors Provoost But we're not going to because we're cool people and we use Schnorr.

31:39

Ruben Somsen That's right.

31:40

Sjors Provoost Anyway, but there's more.

31:42

Aaron van Wirdum Okay, yeah. I was almost done with sort of reiterating the point of how it actually works. So the FIFA broadcasts a message saying the Netherlands won in this case. Then Ruben can take that message. He broadcasts the transaction that he had. Sjors cannot because then he might lose his money. So Ruben is broadcasting that message, that transaction, and then he uses this signed message from FIFA, combines it with his own signature, and now... Yeah, with some key. And now you're withdrawing the funds for yourself and you won the bet. That's right. And the FIFA doesn't even need to know that there was a bet at all.

32:18

Ruben Somsen Yep.

32:18

Aaron van Wirdum Right? Great. So that gets us one step ahead. And then I think there's another incremental improvement, which we're also going to discuss. Is that right?

32:30

Sjors Provoost Yeah. And that basically gets rid of a bunch of transactions and makes it look even more... inconspicuous.

32:37

Aaron van Wirdum So hang on, what I just explained, what we just discussed are Discreet log contracts, right?

32:43

Ruben Somsen From the, from the paper by Tadge Dryja. So this is the original design and not the design that it's currently in use.

32:50

Aaron van Wirdum Okay, so now there has been an improvement on the original design. Yeah. Is it still called Discreet log contract?

32:56

Ruben Somsen Yes.

32:57

Aaron van Wirdum All right, just an improved version of it.

32:59

Ruben Somsen It is, it is just I would say it's a slight tweak that was kind of obvious, but makes things a lot easier.

33:07

Aaron van Wirdum All right. Who wants to...

33:10

Sjors Provoost I think I'm going to go give this one to Ruben.

33:13

Ruben Somsen Okay.

33:14

Sjors Provoost Because he wrote a mailing list post about it.

33:15

Ruben Somsen That is true, yeah. So to my knowledge, I'm the first person who actually wrote it up. I don't think it was super novel because it's literally just... I just realized, oh, you can combine adaptor signatures with the DLC protocol that Tadge Dryja came up with.

33:36

Aaron van Wirdum Wait, you're being modest probably, but are you saying, did you invent this? Was it your original idea?

33:42

Ruben Somsen I don't think, because it's literally just, yes, I'm probably the first person who mentioned it, but it wasn't an invention, I would say, because it's literally just you're taking adaptor signatures, which was invented, I guess, by Andrew Poelstra, and applying it to the DLC protocol. And there's nothing, like it's a very straightforward one-to-one conversion. So I guess I'm the first person who maybe saw the connection, maybe. I'm sure other people must have seen it too, but just didn't mention it. I'm at least maybe the first person to actually mention it. Let's put it like that.

34:19

Aaron van Wirdum Okay, so let's start at the beginning. Adaptor signatures, what are they?

34:23

Ruben Somsen So adaptor signatures at a high level, the way I would explain them is that it's a way to do a signature that is incomplete. So you create a signature, but it's not actually valid. It's missing something. And what it's missing, you can know the public key of what is missing. So there's a number that is missing. That number is basically a private key, but you only know the public key of what is missing. So if someone reveals the private key, then you can complete the signature. And now the signature becomes valid.

34:58

Aaron van Wirdum Right, I see. I think when I was trying to summarize DLCs earlier, this was kind of what I had in mind. Okay, but this is actually what that is.

35:07

Ruben Somsen Yes.

35:07

Aaron van Wirdum All right, got it.

35:08

Ruben Somsen And it makes a whole lot of sense because it makes things a lot easier. So what we had earlier was this mechanism where you publish a transaction. If you publish the wrong transaction, you get punished. And now we can basically get rid of that with adaptor signatures because what we can do is we can again start from our two of two multisig that me and Sjors have. And then we can create a bunch of transactions, in this case, two transactions, right? Sjors wins or I win. We put our signature on that transaction, but we do it in such a way that it's incomplete. We do it with an adaptor signature. And the signature where Sjors wins can be completed if the Oracle signs Germany wins.

35:48

Aaron van Wirdum Right.

35:49

Ruben Somsen And my transaction... that signature can be completed if the oracle signs the Netherlands wins. And now we, we completely circumvent that issue of having to go back and having to punish, uh, if Sjors publish the wrong transaction, having to publish him, because he can't publish his transaction because the oracle never revealed, uh, that secret.

36:09

Aaron van Wirdum Right, so, so in the previous example I explained that's like in a payment channel both of you essentially have a mirror version of the transaction. Yeah, you both have sort of your own version of the transaction. And then you publish that. And then from that transaction, you can withdraw the funds. And in this case, you still kind of have these mirror versions of the transactions. However, you can't even publish it in the first place if you don't have the adaptor signature. Is that right?

36:34

Sjors Provoost And that's also because the inputs are different in this case. So in the previous thing that we described are basically the money that takes it out of the multisig, the transaction that takes it out of the multisig is the same. The input side of the transaction is the same. It has the same signatures, essentially, because it's just taking out of a regular multisig. And what adaptor signatures do is they kind of create broken signatures to get it out of the multisig. So you're not actually getting it out of the multisig, but once you've got it out of the multisig, you can just send it straight to your own wallet. The only thing is you can't get it out of the multisig, because you need this thing from the Oracle. And we both do this. We both have this broken transaction that cannot spend any coins. And then we just hope that we get the private key.

37:21

Ruben Somsen Yeah.

37:21

Sjors Provoost So there's nothing we need to keep secret for each other. Well, except, you know, our own private keys, but yes.

37:26

Aaron van Wirdum Right. Yeah. So this does sound like a streamlined version of the previous example. So in this case, to clarify this, if I'm getting it right, is the Netherlands won, the FIFA broadcasts a message that says the Netherlands won and this time you actually use that message itself, Ruben, to combine that with your own signature.

37:48

Ruben Somsen Yeah, and Sjors's signature specifically, right? Because that's the one I need to complete. I can complete my own signature. That's not hard because I have my own key. But Sjors also had to put a signature on that transaction and that's the one I want to complete.

38:00

Aaron van Wirdum Right. Yeah. When I said your signature, I kind of meant the transaction that you're holding. Is that right? Yeah.

38:06

Ruben Somsen Yes.

38:07

Aaron van Wirdum But it is technically Sjors's signature. Right. Got it. All right. Is there anything else? Do you want to get into the P's and the G's and the math like you did before?

38:17

Sjors Provoost No, we try to. And I think conceptually, you know, it's again, you just have an equation with something on the left and something on the right. And you can see what the Oracle knows and what you know. And that's all straightforward. The only thing I got confused of is because, you know, we're doing this fancy Lightning-like thing. The multisig, the transaction that goes out of the multisig is a joint, sort of a joint signature with something like MuSig2 as a protocol.

38:40

Ruben Somsen Ideally.

38:41

Sjors Provoost And I was wondering whether you can actually combine that with this, with this moon math.

38:46

Ruben Somsen Yeah.

38:46

Sjors Provoost And I'm pretty sure the answer is yes.

38:48

Ruben Somsen Yeah.

38:49

Sjors Provoost And then you think the answer is super straightforward. Yes. And I looked at some, some comments by Nick. What's his last name?

38:58

Ruben Somsen Jonas. Jonas Nick.

38:59

Sjors Provoost Jonas Nick from Blockstream. And he said complicated things about security proofs, but he also said it was possible.

39:06

Ruben Somsen Yeah.

39:07

Sjors Provoost So maybe that, you know, you want to talk to your local cryptographer before implementing something.

39:13

Ruben Somsen That is always wise, for sure.

39:16

Sjors Provoost That is always wise. Okay, but that's pretty much...

39:18

Aaron van Wirdum Yeah, I do have one more question.

39:20

Sjors Provoost Oh, no, we have a bonus section.

39:21

Ruben Somsen Yeah.

39:21

Aaron van Wirdum Well, you touched on this throughout the episode at some point, but I do want to get back to this point towards the end, which is now.

39:29

Ruben Somsen Yeah.

39:30

Aaron van Wirdum So in the example so far, we've used this very simple bet of the Netherlands versus Germany. But now we want to bet on something like the price of Bitcoin in the future. So now there's not two outcomes, but there's... I don't know. Unlimited? Endless?

39:47

Sjors Provoost No, not endless, but N.

39:49

Aaron van Wirdum N. Oh, yeah, sure. So how would this translate to these solutions? How are we going to...

39:54

Sjors Provoost Well, naively, if you say you want to do the dollar price, and let's say it's a five-digit binary number, just to make it simple and to sort of anticipate where we're going. So that's not a huge precision, but that's fine. For every combination, so for 2 to the power of 5, that's the number of combinations, we would write a contract that redeems the correct amount for me and the correct amount for Ruben. So this is no longer completely binary, but if the dollar price is 00001, then you get a little bit of satoshi. If the dollar price is 1000, you get more satoshi. That's the idea. So we could just sign all these transactions. But if you want to have a bit more precision, we have to pre-sign a lot of transactions. But for the Oracle's point of view, it's very simple. The Oracle just produces, publishes a binary number and signs that.

40:50

Aaron van Wirdum All right.

40:51

Sjors Provoost That's one way to do it.

40:52

Aaron van Wirdum The Oracle, in this case, would only have to sign one message. For the Oracle nothing changes. It's very simple. However, the two of you would need to do a lot more preparation for all the different amounts.

41:02

Sjors Provoost And this works with both the proposals we just talked about, right? With the adaptor signatures, but also without the adaptor signatures. But we can do better.

41:12

Ruben Somsen Yeah, so hopefully I'm not lost here. But OK, so what you described thus far is you just get the Oracle to sign a specific number, and that number is in binary in this case.

41:26

Sjors Provoost Yeah, I already made it in binary, so it's easier to introduce your optimization.

41:34

Ruben Somsen In this case, you could have every possible number. So five bits would be 32 possible outcomes. So you could have 32 transactions that with each and every outcome, Sjors and I get a different amount of Bitcoin depending on the bet outcome. That's what you described thus far basically, right?

41:50

Sjors Provoost Yeah.

41:51

Ruben Somsen Okay. Yeah. So the thing that the Oracle can do is literally sign every bit. So there are five bits in this example. And the bit can be either one or it can be zero. So there are 10 possible outcomes that the Oracle can basically sign. And out of those 10 outcomes, it is only allowed to sign five of them because we use the same trick where if it signs something twice, you can punish the Oracle. So for every bit, it can sign either zero or a one, but never both. Because if it signs both, then we can punish the Oracle because we get their key. And so basically we get the Oracle to publish these five numbers, which is the binary outcome of the dollar amount that we want. And with that, Sjors and I can now create our transactions that we want to create to resolve our bets. But we can now, because we have the binary number, we can actually do some cool stuff with it. What we can do is, so hopefully this is followable. I'm not sure if this is going to be easy, but basically, we have five bits and let's say my bet number was, like the bet is that if it's seven or higher, I win, for instance.

43:06

Sjors Provoost Yeah, that's what I was wrong in my example because I made it like a dollar derivative. But in this case, it's more like if it's more than, if the dollar price is more than one satoshi, you win, or if it's less than one satoshi, I win. But we want the dollar price with high precision.

43:20

Ruben Somsen Yeah, but you could still have a bet where it's like between three and seven, we get paid out different amounts. And seven or more, I get paid out everything. Three or less, you get paid out everything.

43:31

Sjors Provoost Yeah, the key here is that the Oracle does not want to make a custom bet for everybody. It just wants to publish the actual dollar price. It doesn't care what ranges you have in mind. So, yeah.

43:44

Ruben Somsen So the nice thing is that you can sort of have these, you can have multiple outcomes. You can combine them in a single bet by just adding the points together. So in this case, what we could do is if we want the outcome seven specifically, that means that the first three bits, the lowest three bits have to be one. And so we can make an outcome where we just combine the key for first bit is one, second bit is one, third bit is one. We combine those three. And that, if the Oracle reveals all three, then that specific bet outcome becomes valid.

44:21

Sjors Provoost And that means seven or higher.

44:23

Ruben Somsen So in this case, what I described thus far is just seven. If we want seven or higher, then we need another transaction where we say, or instead of the first three bits, it's also okay if the Oracle signed the fourth bit, or it's also okay if the Oracle signed the fifth bit.

44:42

Sjors Provoost Yeah, so maybe we can make the example a little bit simpler if we wanted to say one or higher.

44:47

Ruben Somsen Yeah, that works. Well, then if it's one or higher...

44:52

Sjors Provoost Then you can basically say if the first bit is signed, then you win. Basically, regardless of what the other bits are.

45:00

Ruben Somsen Well, no, not regardless of what the other bits are, because if the second bit is signed, if the answer is two, then the first bit is zero. So that's not sufficient.

45:10

Sjors Provoost Ah, crap. Yeah.

45:12

Ruben Somsen So that's the problem. So it is quite complicated.

45:14

Sjors Provoost Anyway, you can basically say, like, if these and these bits are signed, that means this and this number range.

45:19

Ruben Somsen Yeah.

45:20

Sjors Provoost You can make bets like that, and each digit represents a public key, essentially. So before, the Oracle had only one public key. Now the Oracle might have, I don't know, how many bits you want. Maybe they have 32 public keys.

45:32

Ruben Somsen Yeah.

45:32

Sjors Provoost And so you can actually make a smart contract, quote, unquote, that... that says something about which public keys have to be present. And this is very cool.

45:41

Ruben Somsen Yeah. And so this is why this is a bonus segment, basically, because it is complicated. And I'm sure we're losing a lot of the audience. But for those who are still with us, basically, really at a high level, what we've been describing here is that you can have these and and or statements with the oracles. So you can even combine multiple oracle outcomes. And you can say this and this and this outcome and this and this and this outcome, or this and this and this and this. And you can basically make a whole bunch of bets based on whatever you want. So it just allows for a lot of custom contracts, whereas the Oracle itself doesn't have to do a lot of complex things. It just has to sign the outcome in binary.

46:25

Sjors Provoost Exactly. And I guess we're not even going to explain anything about it because I haven't even read it. But the bonus, bonus, bonus, bonus section would be that with OP_CTV, this template thing where you can pre-commit to a whole series of child transactions, you can do even fancier things.

46:42

Ruben Somsen Yeah. So I can maybe very briefly try to summarize it. Basically what we've done so far is we've been pre-signing all these transactions. And if you have a lot of bet outcomes, that's a lot of signatures, and you can sort of get rid of those signatures by using OP_CTV, because OP_CTV you can have, in tapscripts, you can have a bunch of OP_CTV branches. And then every branch commits to a different oracle outcome, and then together with the signature of the oracle for that specific outcome you can publish that specific OP_CTV branch. And what that means is that you only have to sign one specific tapscript with one signature from both of us, and that commits to every possible bet outcome. And so what that means is that it is just much faster to generate our bets. Other than that, it doesn't really change anything.

47:33

Sjors Provoost Okay, I don't understand that, but maybe if I listen back to the episode, I will.

47:36

Ruben Somsen I'm sure someone will.

47:37

Sjors Provoost Okay, out there.

47:38

Aaron van Wirdum Back to Earth one last time. What's the status of all of these DLCs? Is anyone working on this? Is there any progress?

47:48

Ruben Somsen So I know there's a work group that has a mailing list that you can follow. I think it's DLC-dev, but you'd have to Google for that. I know Chris Stewart is working on it. Lloyd Fournier is working on it. Lloyd Fournier.

48:06

Aaron van Wirdum Okay.

48:06

Ruben Somsen He actually, he came up with a way to do adaptor signatures for ECDSA. So that's sort of the kind of the way in which it's being used today. Even though we have Schnorr, I don't think the DLC project has switched from ECDSA to Schnorr yet. So I would check out their projects. I think it's DLCS, I think is Chris Stewart's project. And I know Lloyd Fournier has gun.fun, which is a very funny name. But he has a little DLC project where he can basically create a bet and you can publish it on Twitter. And he sort of came up with a way to sort of encode it in Twitter. So it's quite a bit of data, but it fits into a tweet because it uses all these weird characters. It's a fun little project. So if you want to mess around with it, I definitely recommend that one.

48:58

Aaron van Wirdum Yeah, I think Nicolas Dorier is also working on something. I think it's called NDLC.

49:04

Ruben Somsen Oh, okay. I'm not familiar with that, but that's cool.

49:07

Aaron van Wirdum Yeah, they did it. He used that, and Chris Stewart used his own implementation, I guess. They've done this one bet on the presidency, on the presidential elections last year, a year ago. That's the only example that I know of that it was actually used in some way or another.

49:25

Ruben Somsen Yeah. I used both projects on test nets, but not main nets.

49:29

Aaron van Wirdum Right. Well, I think that covers it.

49:32

Sjors Provoost I think so too.

49:34

Aaron van Wirdum Ruben, thanks a lot for coming again. I don't think we could have done this without you.

49:38

Ruben Somsen It was a…

49:39

Sjors Provoost Sure, we could not have.

49:40

Ruben Somsen It was a tough one, yeah, for sure. It's hard to explain it as well. But I think we did a decent job, even though I'm sure not everything was clear.

49:49

Sjors Provoost At least I understand it better.

49:51

Ruben Somsen Great.

49:51

Aaron van Wirdum So do I, Sjors.

49:53

Sjors Provoost So that's good.

49:54

Aaron van Wirdum We won something today.

49:56

Sjors Provoost All righty. In that case, thank you for listening to Bitcoin Explained.

50:01

Aaron van Wirdum There you go.