S16 E37: Andrew Poelstra on Simplicity, Bitcoin Smart Contracts & Upgrades
Search this conversation
0:46Vlad CosteaHey, hello there and welcome to the Bitcoin Takeover Podcast. This is Season 16, Episode 37. We are live with Andrew Poelstra, who is the Head of Science, or how should I present it, like Chief Scientist, Head of Research Department,
1:02Andrew PoelstraThere we go. Yeah, director of research
1:04Vlad Costeaat Blockstream, and also Big Bull in terms of improving Bitcoin with covenants and also OP_CAT, which can generate covenants. He was on the show last year. This time around, he came here to talk about Simplicity, which is a scripting language that was invented by Blockstream and is supposed to be easy to use. And also, I remember the meme that it fits on a T-shirt that was sort of a flex that you presented very early on, must have been like six, seven years. And it's finally live, right?
1:41Andrew PoelstraYeah, it is live on Liquid. So it was live on Liquid Testnet a few months ago, and that was our first kind of real network, if you will. But Liquid is the first production network that we've deployed it on. So that's a pretty big milestone for us to have Simplicity launched and usable on a network with real money on it.
2:03Vlad CosteaDo you guys still use Elements? I remember that being a thing.
2:08Andrew PoelstraYes, yeah. So Liquid is based off of Elements. Elements is a fork of Bitcoin Core that has just whatever random extensions we wanted to load onto it. Well, I shouldn't say that. Now that Liquid's deployed it, we had to curate it a little bit. We no longer have kind of a half-baked, two-way peg system and all those 2014 era things, but it's still the good old Elements. It now has, since maybe you last looked at it in 2015 or so, it has a modern SegWit from Bitcoin. It's kind of an interesting history there where Elements had this half-baked, very early hard forky version of SegWit.
2:45And then based on that, Luke Dashjr figured out the soft fork version eventually deployed on Bitcoin, and then we turned around and pulled it back onto Elements. We've got that, we've got multiple assets, we've got confidential transactions, we've got various script extensions, and now we have Simplicity. And that is a basis for Liquid.
3:04Vlad CosteaI think a lot of people know about Solidity, which is something that's very popular and has been used on Ethereum for a decade. Is Simplicity a response to that? The
3:16Andrew Poelstraname is, and this is a bit of unfortunate branding on our part. In Ethereum, the underlying language that lands on the chain is called EVM, and Solidity is a language that compiles down to EVM. Solidity is a language that humans look at, and EVM is a language that actually runs on the blockchain that computers look at. And so Simplicity fits in where EVM fits in. Simplicity is a super low level, very machine focused. It's designed for consensus validators, it's designed for proof validators, it's designed for analysis systems, basically.
3:53It's really not designed for people. So Simplicity, I mean, the way that it fits on a t-shirt, right, is that it's built out of these nine basic combinators, we call them, which are kind of similar to opcodes. And you can build up any program with these combinators. But in order for you to build any program from just nine of these, they have to be extremely low level, right? We don't even have a first class notion of a bit in Simplicity. So you've got to define a bit using a couple of combinators that we call injections.
4:22And then from a bit, you can define an adder and like a two bit adder and four and eight and 16 to build up to 256. There's a whole bunch of kind of layers of kind of fundamental primitive components of computer programs that in Simplicity you tend to be exposed to. So it's better to say that Simplicity, well, it is a pun on Solidity, right? The idea was rather than having this giant language where we took Bitcoin Script, added a whole ton of functionality, added a rich statefulness, added a reentrancy in this account based system.
4:55I mean, it doesn't even resemble Bitcoin Script anymore, but historically that's sort of where EVM came from. Simplicity started from scratch. I said, what if we just took the bare minimum components we needed based on theoretical computer science? What could we build a program out of? What could we build any program out of? This just takes a bare minimum. So as a user, you actually don't want to use Simplicity directly. You want to use a high level language that compiles down to Simplicity. So our language for that we call Simplicity HL.
5:27So I should say Simplicity HL is a response to Solidity is sort of where we're at.
5:35Vlad CosteaRight. So I think Solidity gets compared a lot with JavaScript. What is Simplicity like? Is it like Rust? Is it like Python?
5:47Andrew PoelstraIt's like Rust. So we have actually an explicit design goal. We'll see how long we can stick to it. But an explicit design goal that Simplicity HL code should compile as Rust. Like we're trying to be so syntax close that you can think of it as a subset of Rust. And this is a little bit of a, like it doesn't map exactly well, right? So Rust is for the most part an imperative language. You have a series of statements. Most things you might think are a statement or actually expressions.
6:17So they do a good job being functional in that sense. But basically when you're writing Rust code you're doing one thing after the other. And you've got threads, you can fork off, you've got conditionals, things like this. In Simplicity ultimately what you're doing is you are verifying that some computation was done. It's a very computational, it's a very pure functional kind of model. Where whatever program that is represented by your contract, what you're doing when you spend the coins is doing the execution and making sure that it's satisfied.
6:53But then what actually hits the chain is just a verification of a trace of that. And what that means, well ideally what that means from a user perspective is nothing at all. It just looks like Rust, it feels like Rust, that's great. But in practice this kind of low level distinction between verification and computation does bubble up even to Simplicity HL. So what you're really doing when you write Simplicity HL is you're building up a single function which is evaluated by the Simplicity interpreter. And that single function has two possible behaviors.
7:27Either it aborts or it doesn't. And if it aborts your transaction is invalid, if it doesn't abort then your transaction is valid. That's ultimately what goes on the blockchain. But our goal is that when you're writing code like that it nonetheless looks like Rust. It looks and it feels like you're doing one thing after the other basically. And the syntax is familiar, we got the curly braces, we got the functions and the parentheses, we've got modules, all that good stuff. So that's our inspiration as far as the syntax and usability goes is Rust.
7:59Vlad CosteaRight, so now that Simplicity is live and it's deployed on the Liquid Federation, are there any applications that were built sort of like demonstrations for what this can do?
8:13Andrew PoelstraYep, so on our website we've got called simplicity-lang.org. For a little while just on our testnet we've had a demo, a web playground where you can write Simplicity HL code. Compile it to Simplicity, generate addresses and you can connect to Liquid Testnet, send and receive coins. So on that website we've got a whole pile of example programs. We implemented OP_CAT, which is a little bit silly because if you've got an expressive programming language, OP_CAT just takes two things and concatenates them. So it's one line of code, but it's cool to demo.
8:44More interestingly, we have demos of vaults and we have demos of an implementation of SIGHASH_ANYPREVOUT. So one thing you can do in Simplicity is define an arbitrary SIGHASH. You can sign whatever parts of your transaction that you want to sign. And so one illustrative example of that is that you can implement SIGHASH_ANYPREVOUT directly in Simplicity. Now since the launch, the one big thing that we've had is the StarkWare folks. I'm wearing a shirt, not on purpose, I'm wearing a StarkWare shirt here.
9:15The StarkWare folks have developed a STARK verifier on Simplicity and I think they have a blog post that came out yesterday about that. Where using the computational power of Simplicity, they're able to implement a full STARK verifier. And their goal, I believe, is that you can take any Cairo program, which compiles down to some sort of zero-knowledge proof circuit. And then you can verify that in the STARK verifier circuit, which is run on Simplicity. So that, I think, is the biggest application that is kind of out there.
9:50If you're willing to go to GitHub and download stuff and kind of tape it together yourself, that's something you can actually use today, which is pretty cool.
9:58Vlad CosteaI can already sense how a bunch of angry Bitcoin maximalists on Twitter will say, wait a second, Satoshi left us with this Bitcoin Script, which is already perfect. We don't need anything better because Bitcoin is already perfect. So why do these Blockstream people come up with something that's called Simplicity and that tries to basically replace what Satoshi gave to us? And there are two questions that drive from this. What is it that Simplicity does that Bitcoin Script cannot? And why do you think that Simplicity can become potentially a BIP for Bitcoin?
10:35Andrew PoelstraYeah, those are great questions. And I appreciate the historical framing there because, in fact, the script system that Satoshi implemented had all sorts of stuff that modern Bitcoin Script does not, right? It had OPCAT, famously, but it had multiplication. It had division. It had modular arithmetic. It supported arbitrary big num arithmetic. So right now in Bitcoin Script, you can only deal with 32-bit numbers, and you can add and subtract them. You can't multiply or divide them. In the original Bitcoin Script, script it used OpenSSL Bignum library to let you manipulate numbers of arbitrary sizes.
11:11There was in fact no limit on the size of elements that you can work with in the original Bitcoin Script. Today there's a limit of 520 bytes per element and that would be preserved by the OP_CAT proposal that has a BIP. And in 2010 there was sort of a series of bugs found all at once. I think a couple people on the Bitcoin talk forums started like really looking at this Bitcoin Script things and what can this do and how can I grief this and they found a whole number of issues.
11:43And in the space of roughly a month it was I guess August 2010, 15 years ago, right about now, Satoshi disabled a whole bunch of this. He disabled the shift opcodes, he disabled multiplication, he disabled OP_CAT, he restricted the size of script elements to 520 bytes. There were just a whole bunch of limitations that showed up. So if you're coming at this from a kind of Satoshi's vision kind of perspective where we shouldn't change what Satoshi built because it's like and I get the argument like Bitcoin is amazing and let's not try to shake something that's not designed to be shaken and let's not change something that's not broken.
12:26But the fact is that the original script system had a whole ton of issues and it was limited in a bunch of ways in 2010 in a fairly ad-hoc way with the goal of eliminating all these classes of bugs. So basically any opcode that had funny or difficult to think about behavior was just shut down without a whole lot of high level thought about where that would leave the language. And where it left it is that script today can do basically three things. It can do signature checks, it can do hash preimage checks like you do in Lightning with PTLCs, and it can do time locks.
13:06And then you can combine these with ANDs and ORs and thresholds and kind of combine them in arbitrary ways. But those are the three things you can do. And each of those individually has a whole ton of weird quirks to it. So in signature checking prior to Taproot we use ECDSA signatures. And it's a form of ECDSA signature that doesn't commit to the public key that's being used to sign it, at least not directly. And that lets you do something called PubKey Recovery that lets you kind of run signature checks backwards and do all sorts of weird crypto tricks that are kind of surprising.
13:44The time locks that are included in this have a lot of weird behavior. You can specify the time lock that you want to do, either in absolute or relative terms, like an absolute block height or a block height, how many blocks since your thing was committed. You can specify it in seconds or in blocks. And if you're doing a relative time lock, then the number of seconds that you do, you actually have to specify in 512 second increments, which roughly approximates a 600 second block target, but except it's a power of two, which is convenient for implementation reasons.
14:24You can only go up to two to the 16, which is roughly a year and 10 days or something like that. The way that these seconds are counted is with respect to the median block time. So you take the most recent 11 blocks and you look at the fifth or the sixth one in that list. And you take that time and you compare it to what's in your script. I could probably spend the whole hour just trying to describe all the weirdness about the lock times. My point here is that Bitcoin Script has two kind of broad problems.
14:57One that I've hinted at is that it's not very expressive. It really can't do a lot of stuff. And I get the argument that maybe that's a good thing. Like, isn't it great that we've let the Ethereum and the Solana people run forth where fools dare to tread and encounter all of these crazy kind of things and all these failure modes and these re-entrancy bugs and these multiple hard forks to change resource counts and all that good stuff. Better that they do that rather than us, right?
15:23And I feel that, but even at the time, even in 2014, when Ethereum was first developing a lot of the stuff that they developed, the problems that we've seen since then were predictable and were predicted. And you can find mailing list posts about that. So I'm not convinced that this extra expressivity is inherently just like a reckless thing to do. And it's impossible to do in a safe way. The other issue that Bitcoin Script has is that you really can't reason about it despite being such a simple language that can't do a whole lot of things.
15:58The things that it can do have all sorts of really weird edge cases and surprising things. And even now I've been working with Bitcoin for like 15 years. And every year or two, still somebody will notice some weird quirk of Bitcoin Script that I wasn't aware of. And in some cases, I don't think anybody was aware of because there's just such, there's so much obscurity, both in the fact that the op codes are defined with respect to C++, which is a very complicated, very weird edge casey kind of language and using the C++ standard library, which also has weird quirks, but also just the code itself is very weird and crusty.
16:41And let me give one example of that before I get back to Simplicity, which is that all the numeric op codes that I mentioned, I mentioned that Bitcoin can do 32 bit arithmetic. So all of the numeric op codes in Bitcoin are limited to 32 bits. So if you put a 33 or any larger number of bits into one of these numeric op codes, it will just fail immediately. Your script isn't valid. You're not allowed to do that. Except zero and one are special numbers. So with op if and not if and dup if, there are three kind of conditional things.
17:14With those, you pass it a number that's supposed to represent zero or one. And the rules for what is zero and which are one are kind of interesting. So all bit zero is zero, right? That's a false. And no matter how many bits you get, you're supposed to provide zero bits, like literally an empty string. But you can write any number of zeros, that's fine. Except the topmost bit, the most significant bit is allowed to be one. And that's still a faulty value. Okay, so you've got the kind of, and what that actually represents is zero and negative zero.
17:45In Bitcoin, you can express negative zero because it uses a sign magnitude system. And that specifically, and everything else is true, everything else is one. And this specific instance of numbers in the truthy, falsy op codes, if not, if in this stuff, those have no limits. You can go past 32 bits, you can go up to the full 520 byte limit. And so a lot of people kind of feel like they've got a handle on all the weird behavior in Bitcoin Script. They're familiar with the numerics.
18:17They're familiar that they have a 32 bit limit. They're familiar that sign magnitude and like the uppermost bit indicates a sign and you can therefore express negative zero. And that's different from zero. And by the way, if you search in interpreter.cpp, there's a comment, there's an op code for comparing numerically against zero. And there's no op code for comparing like literally against zero because the literal one wouldn't fire on negative zero and Satoshi was worried about bugs. So search for the word wise guy. And it's one word, wise guy.
18:47And this is a comment in the code that Satoshi left about exactly this saying, if some wise guy tries to use negative zero to break things. I just, I like that comment. So I try to bring it up when I can. So Simplicity, why, why Simplicity? What can it do that Bitcoin Script can't? Well, it can validate any computation. And so any, any program that you can run in finite time that just manipulates pure data, Simplicity can express. It's not limited to 32 bit arithmetic. It's not limited really in any way, except for how large are you willing to make your transaction, which I guess in turn is limited by what fits in a block.
19:25So, I mean, there are, there are limits that come from the size of your transaction, but, but there are no limits other than that on what you can compute. There are no, you know, only 32 bit numbers. There's no like minimal if rules and all these kind of crazy rules that exist in Bitcoin. The other thing it can do though, which maybe might alarm people is it can do transaction introspection. It can do covenants. So just being able to compute everything doesn't necessarily give you covenants, right?
19:54You need some sort of connection to the blockchain. You need some sort of ability to look at your transactions and In principle, those are independent ideas. In practice, as we've seen, they're not. And the reason that they're not is that in any useful scripting language in Bitcoin, you need the ability to check signatures on your transaction, right? Like otherwise, what is your script system doing if it's not making sure that your transaction is signed, right? But it turns out that the signature validation opcode, whatever that looks like, kind of leaks information about the transaction into your script.
20:36And this is why OP_CAT is so controversial, right? This is why OP_CAT creates covenants, because cat itself is a pure function. It takes two objects, it sticks them together. So how, in some sense, how could that enable any new transaction introspection abilities? And the reason that cat can do it is because you can take a signature that goes through the signature checking opcode. Using cat, you break the signature up, and using the hashing opcodes together, you can basically reverse engineer what the transaction would have had to have been in order for that signature to be valid.
21:10And so same story with Simplicity. Simplicity can obviously check signatures, because otherwise it couldn't do anything, or otherwise it wouldn't be useful in a blockchain context. And it can do any computation, so therefore it supports covenants. But we went one further, and we directly added transaction introspection. So directly in Simplicity, you can look at each of the inputs of your transaction, you can look at each of the outputs, you can do, you can look at your fee, you can figure out your fee rate, because you can determine the weight of your transaction.
21:41You can, I mean, you can directly do covenants this way. And this is useful for a whole pile of things that maybe we'll get into, although we've discussed covenants to death, and we have only so much time today. But okay, Simplicity can do any computation, and it can do covenants. And then the second big thing that Simplicity gets you, the script does not, is that because Simplicity is defined not as a series of opcodes that manipulate these opaque stack blobs using C++ and the C++STL, but rather defined in the terms of these nine combinators, which are extremely simple, and you can, in fact, implement them off of the t-shirt, and I have.
22:26They're very simple, you can implement them in any language and have a very high assurance that they'll be correct, even if the language you're implementing them in is not one that has a specification or a formal model or anything. But importantly, we have implemented it in verified C, in the subset of C, which is supported by the CompCert compiler. And that means that Simplicity can be formally specified, and it is formally specified. We have an implementation in C, we have an implementation in Haskell, we have an implementation in Rust, and most interestingly, we have an implementation in the Rocq theorem proving assistant.
23:02It used to be called Coq for various historical reasons, and they have reversed that finally after.
23:08Vlad CosteaYeah, yeah.
23:10Andrew PoelstraIt's actually, it's kind of cute, right? So the word bit in French means dick, right? And so as kind of all these French researchers were kind of bitter about, like, having to dance around this world, this word, whenever they did computer science. So they chose the word Coq, which in French means rooster, but of course in English means dick, as the name of there. And this is funny, and they let the joke last for, you know, many decades past, we'd all gotten used to it.
23:36And then they finally reversed it. Because, you know, it is, it is a little frustrating for me to have to say the Coq theorem proving assistant every single time. So I appreciate that. Now it's, now with Rocq, now with Rocq, the Rocq theorem proving assistant. We've got a, we have an implementation of Simplicity in there. And what's really exciting about this, two things that are exciting, I'm just going to keep forking, everything's going to be two things here until, until we have an exponential, or we've taken exponential time.
24:05The two things that are exciting about having a formal specification here, are from an implementer's perspective, you can be assured that your script does what you want. Okay. You can implement Simplicity. You know what it's going to do. You know that you're not dependent on some weird obscure aspects of your language, or that maybe there's some property, maybe there's some way that these different combinators interact with each other that you didn't consider that have surprising behavior. Like in Bitcoin, say, with the SIGHASH_SINGLE bug, which, for context, there's a way in Bitcoin where you can cajole it into signing, not the hash of your transaction, but instead a string that is 256 zeros, 255 zeros and a one.
24:51And it turns out, had it been 256 zeros, it would have made Bitcoin transactions easy to forge. But fortunately it was not. So that was a miss. And none of this was intended to be there. It's just like an accident of C++ turning into a weird thing. None of that in Simplicity. We've got a formal specification. Because it's so simple, simple to implement, not, not so much to use as we'll talk about, you can implement it in multiple languages. Whereas Bitcoin Script, it's like basically culturally forbidden amongst a large set of the Bitcoin community to try to write your own script interpreter, because nobody's really sure what the total set of behavior that the Bitcoin Script interpreter has.
25:35Right. So unless you literally copy and paste the code out of Bitcoin Core and just use that verbatim, which is the premise behind the libbitcoinconsensus library, and now the libbitcoinkernel library, which are, which come out of core. It's literally the code from core that's just compiled with a minimum of supporting stuff. If you try to write your own thing in Rust or in Haskell or whatever, probably it's going to be wrong in some subtle way. And then if somebody is using this in production, then they can be forked off the network.
26:08And as a long time ago, in like 2010 or so, Coinbase had a bug bounty where, and they were using Bitcoin Ruby. This is way back. It's like it would have been 2013, 2014, I think. They were using Bitcoin Ruby. And whenever you found an area where the Bitcoin Ruby script interpreter differed from Bitcoin Core, you could file that under their bug bounty and they'd give you a Bitcoin because that is a bug that could cause them to fork off. So I got, I got a few coins this way before they, before they finally started.
26:37They stopped using Bitcoin Ruby. And sadly, I just got an email saying they're shutting down the bug bounty program as well. I hadn't used it since then, but they're not, they're not giving people free Bitcoins anymore for just like a shooting fish in a barrel kind of, kind of issue. So anyway, with Simplicity, it's not true, right? Like we at Blockstream have like five implementations, both because we can be assured that they'll be consistent with each other. And secondly, it's so easy to implement. Like it's unbelievably, like I literally, as I said, I did it off the shirt once without even, uh, reference to any of the other implementations, but that's cool.
27:12The other reason having a specification is cool, and this is really what's relevant is that as a user of the language, it means you can write a specification of your contract. So you can write contract code where, provided that you formally specify it and provided that you use Rocq or Lean or Alloy or one of these proof assistant systems in order to prove that your specification meets the code as implemented in Simplicity and as executed on, on the model of Simplicity, then you can produce machine checkable proofs that your code will do what you expect of it.
27:50And even short of a full specification, you can produce machine checkable proofs of much simpler claims, right? You can produce a proof that the witness data for your program, no matter what, will be within a certain bound. And that one actually you don't even really need formal tools for because that's, that's built into the Simplicity interpreter. These kind of, this kind of bound checking, uh, you can produce a formal proof that it's impossible to spend to, to satisfy the program without a signature from some specific co-signer, uh, who's supposed to sign off on every possible execution.
28:21Uh, you can prove that if a certain, like given a certain set of keys or given a certain set of keys that you don't have, um, what your resource bounds change into basically whatever your business logic is, if you can ask a specific question about that business logic, then you can prove. In a machine checkable way that your code satisfies that. And then whenever you change your contract code, you can regenerate the proof, assuming that it continues to be true and get assurance that all of your updates have preserved all of these properties.
28:52And this kind of ties back quite nicely into the discussion about OP_CAT and the discussion of like fears of Bitcoin, uh, being extended, right? Is that a lot of the fears around Bitcoin being extended are that. It's very hard to predict how different Script opcodes will behave, right? When they're integrated, like cat is the most simple thing in the world. And yet, surprise, surprise, because of the way CAT interacts with the CHECKSIG opcodes and the hashing opcodes, it does, uh, well, it enables covenants, right? I mean, who would have, who would have expected that?
29:28In fact, we thought that this wouldn't be the case because we came so close so many times to getting covenants pre taproot using this ECDSA, uh, pubkey recovery trick where you run the signature backwards and, and, uh, and in fact, you can get a simple form of covenant, I think, with the ECDSA signatures and ANYPREVOUTut. And I came so close to using that in the SIGHASH_SINGLE. Anyway, in taproot, we, we fixed, fixed that the, uh, the Schnorr signatures that Taproot uses commit to the public key.
30:00So you cannot do pubkey recovery. You cannot run the signature backwards in any sense that would let you go from a signature. Uh, into a public key or, or into a nonce that looks like a, um, that somehow has your transaction data embedded in it, at least not without knowing the transaction ahead of time. And then it turns out there's, there's another way. You don't actually have to run the signature backwards. You can just like limit the signature in a bunch of ways. And I have a blog post called CAT and Schnorr tricks, which I wrote a few years ago, which explains how to do this.
30:32And it turns out you can in fact do covenants. Okay. Um, that's one category of fears, right? A related category of fears is like, maybe OP_CAT just like blows up this, maybe it's possible to crash nodes using OP_CAT. And we have pretty high assurance. I'm, I'm very confident that's not the case, but the original OP_CAT did that, right? Because you could use OP_CAT and OP_DUP to like take a single byte and you duplicate it to get two and you duplicate it to get four and you duplicate it to do eight, just doing dOP_CAT, dOP_CAT, dOP_CAT.
31:04Um, you do that 64 times, right? And now you've got two, two to the 64, which I think is 16 trillion trillion or something, uh, bytes, uh, which is a lot more memory than any node has. And then you can take out, take out nodes, right? How, how can we be assured that that kind of thing won't happen? Well, in cat, we added like size limits to, to the implementation. So, uh, you take two script elements that have a fixed size. It outputs some fixed maximum size.
31:30You output something with a fixed maximum size. Surely there's no problems there, right? Um, well, does cat by itself? Yeah. This is true. I'm very confident. That's true. But then we see like cat and signature aggregation or cat and op success and cat and, um, blind signature. There's all these different proposals that people want to bring into Bitcoin and together, the interactions are just very hard to reason about, right? And so with Simplicity, we can wrap our heads around it. Like the kind of like, can you use these two things together to blow up the system kind of questions?
32:06You can answer that with Simplicity and you can ask it in a way where you have a machine checkable proof, not, not an informal argument that, uh, that possibly has flaws or overlook stuff or whatever. And, um, and so that's why we think that Simplicity is a good direction to go, right? If we want to extend script, I mean, first off, Simplicity is huge. It's a whole new script interpreter. Like we're not going to propose it for Bitcoin tomorrow and get a BIP number. And even if we did, not a chance is it going into Bitcoin this year or next year or this decade.
32:41Right? Like I think in the 2030s, that's, that's a more reasonable timeline. So, so I'm not proposing Simplicity right now in this podcast as something we should get into Bitcoin, um, as like the way to get more expressivity and the way to get covenants and the way to get quantum-hard signatures and the way to get all these things, even though, uh, and ANYPREVOUT, even though it does give you all of these things all at once, um, it's, it's too big for that, but as a future direction for extending Bitcoin Script where we're not adding individual.
33:10Like very simple, but nonetheless, very scary op codes. I think Simplicity is, is the direction that we want to go to because Simplicity is something that we can reason about. And maybe there's even a direction where we attempt to move existing functionality from Bitcoin Script into Simplicity. So say users of the chain are still using Bitcoin Scripts, but rather than that Bitcoin Script being executed in the script VM, they're being executed in a Simplicity interpreter. And I mean, this is just a very simple example. This is also kind of a multi-decade project, but if you get enough of script into the Simplicity interpreter, now you've got a version of script that you can reason about.
33:48And that's, that's kind of cool. Uh, or when you're proposing things like ANYPREVOUT or CAT or CTV or all of these new op codes, one thing that we can maybe encourage people to do is to write an implementation of these op codes in Simplicity. And even if you weren't going to use the Simplicity in the consensus logic, because that would be kind of like a lot to have this whole new interpreter, you could use the Simplicity as a specification, but a formal specification that you can then answer questions about like, what is the behavior of this op code in various edge cases and stuff like that.
34:26And so let me, let me add one more thing to this long rambly answer, which is that another reason people worry about script expressivity is this, is they see the experience on Ethereum. Okay. So they see very various bad things related to, um, efficiency and defining resource limits and Simplicity just solves those. Like they have no worry about that. Uh, you see things related to rich statefulness and having this giant key value store that is very difficult to store and very difficult to update in a way that has predictable resource usage.
35:04Well, Simplicity doesn't have a key value storage. It doesn't have any of those problems. So those, those are all easy and that they were technical mistakes that Ethereum made were obvious mistakes and even in 2014. And the people worry about MEV, right? Like MEV is a big thing. What if we add expressivity and now people are doing complicated contracts and now miners are able to reorder the transactions or insert like transactions in between other transactions or, um, modify witness data or somehow just like take value out of things in a way where there is a centralization effect where miners are doing all this crazy complicated analysis in order to try to get the best block, where the best block means not the block with a high-fee transactions, but the block with the transactions they can manipulate, which they have manipulated in the best way, right?
35:56Like that's, that's the fear. And so Simplicity by having all of the design elements that I've talked about today, the idea here is that Simplicity will encourage contract developers. It will make the path of least resistance for contract developers. One in which you can reorder and manipulate transactions, like it's just by its nature kind of forces you to think carefully about what's going to happen and makes it quite difficult to write the kind of transactions that after they're off your system, once they're out in the peer to peer network, have different behavior depending on what happens, you know, what the miners choose to do and what else happens in the peer to peer network and all these kinds of things.
36:41And that philosophy I think it should be reassuring to the kind of hardcore ossificationists, like we don't want to extend Bitcoin in any way, right? Well, okay. If you believe we shouldn't extend Bitcoin in any way whatsoever, I mean, that's obviously you're not going to like Simplicity, but I would submit that you should like Simplicity or you should hate Simplicity less than other proposals. So that's similar functionality, but in this ad hoc and in this predictable way. But if you're somebody who would like to add more functionality to Bitcoin, but is very nervous about doing so and wants to go very slowly and wants to be extremely cautious and wants to be very limited in what we do in order to avoid stumbling into these kinds of MEV traps and horrible centralization situations that we see on other chains, then I think Simplicity, despite letting you do any kind of covenant in any kind of computation, Simplicity is actually the kind of direction that you want to go in because it gives you these tools for formal analysis and for helping people reason about that.
37:47Vlad CosteaThanks.
37:50There's so much to unpack here. And I do want to ask you, I think my first thought was to ask you about the timeline of launching Simplicity because it took a long time to develop. And maybe by this point, it will be hard to get people to convert their Solidity contracts into Simplicity to deploy on a more, how should I put it, robust layer, as opposed to Ethereum. And also want to ask you about OP_CAT because I think the biggest concern about it is that it's so easy to write code that is inefficient.
38:26You just concatenate random other opcodes and then you can even confuse people who are experienced in programming with Bitcoin to not understand what it is that this piece of code that you wrote there is doing. But before that, I gotta plug some sponsors. It's been 30 minutes and I do have to do this. First of all, Citrea, which is trying to bring the EVM to Bitcoin with a ZK roll up. And as far as I know, they have made the first, what's the term, optimistically verified ZK proof.
38:59They have put that in the Bitcoin blockchain and they are planning to launch later this year. The purpose of this is basically to get some of the liquidity that is right now locked into wrapped Bitcoin on Ethereum, which is custodied by BitGo. And there's like 100,000 WBTC that's locked in there and it's much more than Liquid and Lightning and Rootstock and everything else combined. And yeah, that's their goal. They're going to provide services for borrowing and lending your coins. So basically you can do stuff that was possible with BlockFi or Celsius, but without the institution itself, only with code.
39:45And it's pretty interesting. You can test the code today. The website is Citrea, which is citrea.xyz. And I think they have a version of it that runs on the Bitcoin test net. If you want to see how this is going to work. Ideally, this could have been so much better if we had some kind of covenant soft fork, which we did not have, and they had to rewrite their setup to find some workarounds. And they're going to launch this year anyway, in spite of the lack of progress that we have seen.
40:17And I'm curious what you think about Citrea, if you had any time at all to look into how it works.
40:24Andrew PoelstraWell, I haven't in specific, but optimistic roll-ups. I mean, using optimistic roll-ups is obviously not the optimal thing. As you say, like, it would be better if we had covenant opcodes, if we had a more expressive scripting language, right? You could develop this in, I mean, you could use directly verifiable zero knowledge proofs and stuff like this. But hey, optimistic roll-ups are a hell of a lot better than wrapped Bitcoin that are sitting on the Ethereum chain, like backed by Bitcoin. whose behavior depends on EVM, right?
40:57So that's, this is very exciting. I think it's a super cool project. Yeah, I wish them all success in pulling some of the liquidity back and experimenting in this way. Yeah, I haven't looked into them in any detail.
41:13Vlad CosteaWhat about drivechains, BIP 300 and 301? Paul Sztorc is basically the guy, I know you're one of the co-authors of the sidechains white paper from 2014. And Paul is basically unhappy that Blockstream did not deliver the two-way pegged sidechain and went for the federation route instead. And he's trying to build this miner-protected kind of sidechain, which is the drivechain, which can be part of Bitcoin. But BIP 300, but you can also do that with OP_CAT, I think. I think it was Super Testnet or someone who did the research to come up with this.
41:52And right now, they also have the testnet version of the code on layertwolabs.com/download. I think it runs on the signet, actually. And you can see that they have a big block version of Bitcoin, which is prunable. They have a Zcash fork, which has shielded transactions by default. They have a fork of Ethereum, and they also have a fork of Namecoin. I think it's called BitAssets or something. Anyway, I think it's pretty exciting. It's part of the vision of Bitcoin maximalism to which I ascribe, and which I think should happen.
42:28And I'm curious what you think about this idea.
42:33Andrew PoelstraWell, you're probably correct that you can do it with OP_CAT. And that makes me a little nervous. So historically, right, so the reason that Blockstream did the federated peg instead of the two-way peg, right, despite saying in our sidechain white paper that we're going to do two-way pegs, and the whole paper was about two-way pegs, and then appendix A in the paper, it wasn't B. I think A might have been the pay-to-contract construction. And one of the appendices was like, oh, by the way, you could do the federated peg if we didn't have the support on Bitcoin that we needed.
43:02And then after we published the white paper, we got a lot of pushback, largely from Peter Todd, but also from other people, saying that the incentives here were really problematic, both for our system and for Bitcoin, where if you have, essentially, in order to implement a two-way peg, at least in the SPV way that we were originally envisioning, and that the drivechains largely has continued with, it creates a situation where if there is, let's say that you can redeem a coin on the drivechain once it's been confirmed on Bitcoin for more than 100 blocks.
43:41Well, then if the total value in drivechains exceeds the mining reward for 100 blocks, then suddenly it becomes economically incentivized for somebody to try to rewrite 100 blocks, even though that's crazy and takes a billion dollars, if by doing so, they could steal a bunch of coins from the drivechain, then maybe they want to do it. And whether that's practical in real life, like, can you get enough hardware to do that? You would need more than 50%. I'd have to run the numbers to do it in like a realistic amount of time, right?
44:17You need more than just 51%. I guess with 51%, you could do it in the time 200 blocks takes, probably. But you can't do it with like 50.01% because then you'd still be erasing, like you need to catch up because of the old chain. Anyway, you go try to rewrite all these coins, it's incentivized, whether you could do it in practice, I don't know, whether anybody would, given the amount of chaos that it would cause, I don't know, right? There's the second order, kind of like, do you want to blow up the system that you're trying to rob?
44:47But for both the drivechain and probably more importantly for Bitcoin, you really don't want to have these kinds of incentives present. And that's why, well, to Paul's credit, he's an economist, Paul just kind of leaned into it. Yeah, these are the incentives. And we're going to kind of build up a whole system of incentive management to attempt to mitigate this and to kind of make it so that actors, if everyone is acting in their own self-interest, then the system will work as designed. But as designed, I would argue, continues to have these kind of failure modes that I think would just be quite bad for Bitcoin.
45:35But maybe you want to respond to that, or maybe we want to get back to Simplicity. But those are my thoughts about drivechains, basically, is that I really, I really wish they were possible in a way that didn't have these problems. But I don't, I am unconvinced that they are.
45:49Vlad CosteaWell, the way that I think about it is that it's almost like a farmer decides to set his crops on fire to collect insurance money because he figures out that there's more money to be made from insurance than from doing honest agriculture. But at the same time, if that happens, he's sort of doomed for the rest of his life. Nobody will want to do business with him. Nobody will want to work these crops or whatever. So the benefit, which is short term, might actually end up to worse consequences.
46:20And the way that you described it, that maybe that they don't want to blow up the the system that they're robbing is also a good point, because maybe by the time they're able to reorg a hundred blocks, the price will go to zero or something. So.
46:38Andrew PoelstraYep, all good points. That's a good analogy. But ultimately, what we're discussing here is an attempt to predict human behavior in the presence of incentives that are different, depending on which layer you look at it, right? Like the first order incentives are like, sure, they should just try to steal the money, right? And then the second order is like, well, will the money be there? Will it be worth anything when they're robbing it? And then there's like a third order incentive. I mean, we go back and forth all day kind of trying to argue with it.
47:07Like what, what somebody would do. But I worry, I worry if it becomes possible or plausible for somebody to do this kind of attack without losing a tremendous amount of money, which is the case today, right? If you try to rewrite a hundred Bitcoin blocks today, that's going to cost you, I don't know, I guess about 600, 700 Bitcoins, a crazy amount, to be honest. And without going too far afield, drivechains aren't the only way that this could happen, right? So Vitalik has a famous P plus Epsilon attack blog post, I think, from 10 years ago or something.
47:57What's it called? It's called the P plus Epsilon. P plus Epsilon.
48:05There we go. Cool. It shows up 2015, January, 2015, where the premise, let me check that I'm talking about. I think I'm talking about the right thing here. The premise is that you could write an Ethereum contract, which says, show me a fork of Bitcoin, a hundred blocks deep, which is easy to validate, right? You can just check the block headers and show that there are 200 block deep forks. Show me such a thing, and then the contract will pay you out more money than it costs to create it, right?
48:37So it's possible for people to build incentives outside of Bitcoin that will wreck up the incentives of Bitcoin, right? And so I don't want to pretend like drivechains are this uniquely, like, if we can just avoid drivechains, then Bitcoin is going to be fine from an incentive perspective. But the drivechains I feel is part of kind of a class of proposals that just by its ordinary operations, if it's successful, will lead to a world where the incentives are less stable. And maybe I'll just close with that, like less stable, I guess, is my fear.
49:24Vlad CosteaI think that drivechains, just like your other idea, which was to add Mimblewimble on an extension block, is going to end up in Litecoin. Seems like they're seriously considering adding BIP-300 to Litecoin, which might be a good way for us to observe what's happening, because there are some real incentives there.
49:45Andrew PoelstraWell, yeah, I agree with, yeah, I look forward to seeing that. Yeah, I think we can agree on that. Although I will say, I don't think the Mimblewimble extension block was my idea. Maybe it was.
49:58Vlad CosteaYou were the first person to mention it.
49:59Andrew PoelstraWas I? Whoops. Okay. To be clear, I don't think that... All right, let's try to get back to Simplicity. But today I would not propose a Mimblewimble extension block. I would become much less... My view of extension blocks has certainly soured over the years in which we've thought about them.
50:24Vlad CosteaAnyway, let me plug the third sponsor and then I'll get back to Simplicity. This sponsor is actually a member of the Liquid Federation. They support LBTC and you can go to sideshift.ai to swap your BTC for LBTC or if someone pays you on stablecoins, which is usually the way in which I plug it. I think it's a bad idea to hold on to that in the middle of a bull market. So you can get the free market money instead that you can actually own and that for which you can actually verify the supply and you don't have to trust that some sort of custodian or issuer is going to allow you to redeem because Tether can also censor you.
51:08Anyway, you go to SideShift if someone wants to pay you on stablecoins to paste your Bitcoin address and then you're going to get this stablecoin address that you send to the person who wants to send you the stablecoins and there's going to be a swap that's happening and you receive what you want and the sender sends what they want and it's a very cool tool that gives you peace of mind. Of course, there is a fee for this, but it's not very high and unfortunately they don't support privacy coins anymore and I don't think they support the US altogether due to some regulation issues.
51:44But you're smart if you're listening to my podcast. You know what to do. If it's not supported in the US or if you want to watch porn in the UK or whatever. Or in Texas.
52:02Andrew PoelstraThere's a law against that? There is an age verification law in a dozen or so states, including Texas where I live and that's why I know that one. But yeah, there's similar...
52:10Vlad CosteaSo do you have to enter your ID or something?
52:11Andrew PoelstraYes, some websites just block it completely because there's no reasonable way to let people enter their ID. But a lot of them... Yeah, you go to one of these like enter your ID dot AI websites where they're storing your driver's license and doing God knows what with it and yeah, it's real even in parts of the US.
52:33Vlad CosteaOh, man. Anyway, SideShift.ai is the URL and let's get back to Simplicity because I want to ask you because this one has been in the works for seven years and don't you think it was delivered a bit too late?
52:54Andrew PoelstraSo no. So let me talk about the timeline here. Well, no, but not for the good reason. So I'm not going to say no, it's not too late because it's still totally easy to port your stuff from Solidity and from Ethereum on to Simplicity. I'm going to say no, it's not too late because it was never really easy to do that. So the timeline here is that you could argue that Simplicity started in 2010, 2011 when Russell O'Connor was first talking about MAST on the Bitcoin Talk forums.
53:28And MAST is the premise where you have a whole bunch of different scripts and you just reveal the one that you want to use. And this eventually made its way into Taproot like 10 years later, more than 10. And yeah, about 10. And the idea behind Simplicity is arguably like what if you took this MAST concept and you just designed a whole programming language where the whole language is this tree or actually a DAG of different kind of subprograms that you're clipping together. And the way you would turn it into a whole programming language is by saying, well, rather than just doing MAST where if you've got two programs and you're taking one or the other, you can think of this as conditional composition.
54:12What if every form of composition worked this way? What if you would also use a Merkle tree to describe two programs that you're composing directly where you take the output of one and the input of the other? What if you used it for composing two programs that you were running in parallel where you're doing both of these things on the same input and then combining their outputs so much? What if we were to use this? If you were combining these things recursively where somehow a program could go back and call itself.
54:42Well, it turns out that if you have a recursive, it turns out that if you have all those ways of combining things, then your actual base program that you start with can be dead simple. You can get away with these two little functions, the identity and the unit. So that's where the nine combinators come from, by the way. You have the identity, you have the unit, and stuff and other things. So you could argue that Simplicity has been happening for well over 10 years, but technically Simplicity started, I think, yeah, in 2014 or 15 or so when Russell joined Blockstream and started working on Simplicity full-time.
55:23So it has been a very long journey from getting Simplicity from basically a half-baked white paper to a full white paper, a full tech report, multiple implementations, and a deployment on a production chain. And in that time, that was basically the entire timeline of Ethereum being launched and taking off and people developing all these smart contract things. But Ethereum made a lot of design decisions along the way to make things very accessible to developers. Right. One was just having Solidity, which kind of looks like JavaScript, and before that, serpent, which kind of looks like Python, which I think you can still use, having these very accessible developer languages.
56:06Another was to build off of this EVM foundation, which is this kind of opcode-based language. You're doing one thing after the other. It's a very familiar programming paradigm. It's very easy for developers to get used to and to build stuff with. And then another was to have this kind of rich statefulness where every contract has its own local storage where it can store amounts and retrieve them and have maps and hash tables and so forth. And so you can make like BRC20 tokens that have these giant tables of every user's balance and stuff like this.
56:43But then also, what I think the word rich refers to there is that you can have contracts that can call each other and look up each other's state. And so you have this whole interacting network of state. And by writing contract code that kind of in real time looks at all of the state and changes its behavior based on that, combined with the account system versus UTXO, which itself is a kind of state where every account in Ethereum has this quantity, the amount of ether that's on it.
57:18And that's a form of state. You can also look it up. You can also manipulate it. So you can have multiple contracts that are all kind of floating around the mempool that drain coins from the same account. And if they drain more than the total amount, then at least one of those contract executions is going to be invalid. So everybody just kind of goes in the order that they appear on the block. Writing code like this is very easy to do. It's very easy to write. It feels like writing JavaScript.
57:47It's easy to kind of model in your head. Here's what's happening in what order, and you throw it out there. And then, of course, the consequence is that, is your transaction valid or not? Well, you find out when it gets in the block. And even validators in the mempool can't validate these transactions and cache the results because the result might change based on what happens in the block. And so even if you can imagine an alternate history, right, where we deployed Simplicity somehow back in 2014, let's imagine Liquid was around in 2014 or 15, contemporary with Ethereum.
58:21And let's imagine that we had Simplicity complete and we deployed it there. We still would be in a situation today where it's so much easier to kind of build crazy reckless things that the Ethereum developer community is going to be much bigger and have this kind of like Cambrian explosion of all these cool, crazy experiments and all these things like Flashbots and these reentrancy attacks and all these things that would kind of appear. And there'd be an arms race and lots of exciting things happening. And where we're seeing interest in Simplicity today is from people who were kind of burned out on this ecosystem or kind of like, whoa, that's kind of crazy.
59:03And I think even if we had launched 10 years ago, it still would have taken this amount of time for a lot of people. Even a few years ago, when we talk about Simplicity, I mean, for one thing, people would be like, well, is that a real thing? Talk to me when it's deployed, right? But the other thing was people would say, like, this is so much easier to just do in Ethereum. Like, why wouldn't I just do it on Ethereum? And those kind of attitudes have only changed somewhat recently, at least for a large part of the population of people who want to do smart contracts for, I mean, a few reasons, right?
59:39And the big one is probably just that we have this experience of Ethereum doing crazy things and deploying this way where they've designed their system to be very easy and very fast to deploy really big things. And then another reason, of course, is that the Ethereum ecosystem, well, for a long time, the only people who wanted to do cool things on a blockchain were the kind of like YOLO reckless people who were attracted to Ethereum, right, for more serious people to want to have programmable money in a non-trivial sense.
1:00:13It took a long time for those kind of people to even stop looking at Bitcoin with suspicion, right? So as we've seen more and more kind of mainstream onboarding, we started to see onboarding of much more cautious people who are still interested in doing this kind of thing. Is Simplicity too late? No, no. I don't think. I mean, certainly it's taken a long time, and it's taken longer than I want it to have taken, but I don't think that we missed a boat. And I also don't think that we really could have been much earlier and hoped for any kind of adoption, basically, because all of the cool things I've been talking about as far as being able to verify machine checkable proofs and having a formal specification and being able to verify whatever come with a cost, which is that Simplicity is a fair bit more difficult to use, right?
1:01:02I mean, Simplicity itself is almost impossible for a human to write directly. And we've actually had a series of people at Blockstream who tried to do it and then immediately decided it would be easier to just write their own programming language. That's where Simplicity HL came out of, right, is Sanket. Sanket did that, and then Chris Lewe kind of took over, and now we have Andrew Cann taking over, extending this thing in the directions that these guys each want to take it.
1:01:33It really comes with a usability cost, right? You've got to do a lot of design up front. A lot of things that are kind of simple to deploy but hard to reason about, like having a whole bunch of state updates that all just kind of happen in some poorly defined order, you've got to deal with that ordering in Bitcoin and in Liquid, because we're in the UTXO model, and you can't arbitrarily reorder Bitcoin transactions unless they're independent, right? Any transactions that are in the UTXO model, you can't arbitrarily reorder Bitcoin transactions unless they're independent, right?
1:02:02Kind of spend the same coin in the sense of having one UTXO that goes from a transaction to the next. You've got to figure out an ordering for that, right? And that is inherently hard to do, right? There's all the things happening in Bitcoin today have been struggling with this. So having connecting Lightning payment channels, that's the whole deal of Lightning is building these payment paths out of these independent channels that are feeding coins through a series of UTXOs. ARK is another super cool thing that does this kind of like tree-based thing, and then you have these logarithmic proofs and lots of cool stuff.
1:02:42But their whole deal is like, how can we structure these unconfirmed transactions? All the iterations of BitVM have been attempts to reduce the lengths of these chains of transactions that you need to show in the unhappy case. There have been a few projects to try to formalize this and how to reason about large chains of transactions, but even independent of Simplicity as an ecosystem, this is still a hard problem that we've been struggling with. So could you build like an AMM or something on Simplicity? It's definitely possible, but it's going to be so much harder than it was to build on Ethereum.
1:03:25So no matter what, you've got to really be motivated by these benefits you get in terms of formal specification and machine checkable proofs and ability to reason about it, because you're going to have to be doing that reasoning upfront and your thing's not going to be able to even get off your own computer until you've answered a lot of questions that in Ethereum you can kind of just shrug and say, well, the miners will answer that. Right.
1:03:57Having said that, so when I look at the DeFi ecosystem and think like, how can we bring that kind of stuff to liquid or how can we bring, bringing it to Bitcoin also raises a question of how do you deal with multiple assets and stuff? Because Bitcoin has only one asset, which is Bitcoin. And we really want that to be the only asset, or at least like by far the majority of all economic activity on Bitcoin needs to be in Bitcoin. Otherwise you have unstable incentives again.
1:04:24But when I look at the DeFi ecosystem and think like, how can we build cool financial products? How can we have this kind of stuff on Bitcoin? I see a very long, slow process. I don't imagine that the kind of people deploying AMMs today are going to be like looking at Simplicity and then deploying an AMM next year. Right. I think there's a much longer, a much, much longer path to doing that kind of thing. When I look at what we can do with Simplicity, I look at the stuff that is in the short term, the stuff that's not terribly interactive.
1:05:00Right. So can we build vaults? Can we do SIGHASH_NOINPUT? Can we do a much more interesting business logic? Right. Rather than Miniscript, like here's a set of keys and hash preimages and time locks, how can we combine them? Right. Can we do things like here is a multi-sig where it's a two of three, unless the fee rate is particularly high and then it becomes a three of three kind of thing. Right. Cause then everybody has to sign off on a big fee or a multi-sig that some sort of like fee dependent multi-sig that decays based on how old the coins are on the premise that like, presumably if you haven't spent the coins quickly, it's because you signed a transaction and the fee rate was too low.
1:05:39Can you sign a transaction in a way where third parties or somebody who you delegate to can bump the fee, but can't otherwise change the transaction? That's extremely hard to do. And I mean, you basically can't do it in Bitcoin today, right? If you, if you take your cold keys out and sign a transaction and then later wants to change that transaction in some way, you've got to take your cold keys out again to do it. Whereas, and the way that you see bumping is this child pays the parent, but which is often the right way to go, but it's can be complicated, but it would be better to use in a lot of simple cases.
1:06:14It would be better to just use RBF, but you can't, you can't do it without resigning a whole transaction and pulling your cold keys out. So I look at these kinds of problems that we see in Bitcoin today, and there's some fairly narrow technical problems that are quite difficult to solve in Bitcoin that Simplicity can immediately solve. And then there's some larger problems of people building really big and complicated things and struggling, like, how can we reason about this? How can we be assured that this is not broken or have surprising behavior?
1:06:47Like these are these huge things like BitVM or smaller things like Arc or even smaller things like Lightning. Can we bring Simplicity in to try to formalize some of this stuff? What if we want to have quantum-hard signatures? Well, we need a new opcode for quantum-hard signatures, but with Simplicity, we could just have people using quantum-hard signatures today and get some feedback on like, what are the trade-offs between size and validation speed and security properties and stuff that people are willing to deal with?
1:07:17That's where I see Simplicity shining, right, is at least in the short, like the long term. Yeah, that would be awesome. You build this like whole cool financial product, DeFi construction with a formal specification and a machine checkable proof that your code meets the specification. Like that is a dream. I don't want to downplay that, but it's a huge, long term, expensive project to do. And you've really got to be motivated by wanting to do that in order to do it. Meanwhile, in Bitcoin, we have all these problems that are technically way smaller that Simplicity would be able to help with, right?
1:07:51And that's really what excites me is these kind of little things at the edges of the frontiers of Bitcoin Script development.
1:08:01Vlad CosteaIf Simplicity was to get implemented to Bitcoin, how many of the wallets and functions that we have like multisig would have to be rewritten and adapted for this new language?
1:08:14Andrew PoelstraYeah, so of course nobody needs to. The way we would deploy it, of course, is that it's there and you can use it. But suppose people wanted to use it, like how much would be a rewrite? And from here we can kind of look at, I think the most illustrative example would be Miniscript right before this. Where Miniscript is not a change in anything on a consensus layer, but Miniscript is a change in the way that you think about Bitcoin Script, right? So Miniscript is a subset of Bitcoin Script that is designed to have a whole ton of properties that are machine checkable, similar to Simplicity, except it only does three things basically.
1:08:48And unlike Simplicity, it doesn't ground out in these one line basic mathematical, it grounds out in like five or six Bitcoin Script opcodes, which is like five layers of sketchiness below your formal system. But what we saw is that we developed Miniscript, Sanket, and Peter and I, I want to say in 2018, maybe 2019.
1:09:16And it was pretty fast. I would say in six to 12 months, it was usable. We had a demo and we're like, here's how you can do lightning HTLCs way more efficiently than, I just got to plug my phone in here.
1:09:33Here's how we can do HTLCs way more efficiently than we were. Here's how we can do the Liquid, like, multisig contract more efficiently than we were. And that one was embarrassing because we'd done a whole ton of in-house optimization of this. And then when we came up with Miniscript, like Miniscript just beat it because our compiler was doing a more general search. Here's how we can do the flop construction. Everything that we knew people were doing in script, we knew how to do in Miniscript.
1:09:57And then basically no already deployed system. I think Liquid uses Miniscript now. We started with the Dynafed transition, but for the longest time, Liquid didn't change. The Blockstream Green didn't change. Lightning still hasn't changed. Everything that had like a fixed script that they'd already vetted and deployed and had in standards, like nobody. But then several years later in, I want to say 2013, around 2022 to 2024, basically, a whole bunch of wallets picked us up. So we saw Ledger, I think, was one of the first ones.
1:10:37And then these new like Liana and AnchorWatch and Specter was one of the very first ones, actually. All these kind of wallets and wallet companies and people started exploring using Miniscript for what it was meant for, right? For exposing to users, here's how you can build a tree of like, here are the keys that I need and under what conditions. And here are the time lock backups and stuff. And there was a whole bunch of work driven by Rob Hamilton, where we had to define specifications on top of Miniscript.
1:11:07We have these things called MinTs, M-I-N-T. So somehow, I think, Miniscript templates. That's what it is. Yeah. Which define like, here's a standard construction for some decaying threshold where every time lock, there's like one less key that's needed to kind of constructions and stuff like this. And it took a while. It took several years for people to even start using it at all. And Ledger was one of the trailblazers. And their initial implementation, from a user perspective, was like, terrifying. You had the little screen like scrolling by like a 500 character thing that was mostly random.
1:11:42It was, I'm really grateful that they took the plunge and that they did this because we had to get to the learning, but it was terrible. And it took a while for us to figure out the usability. It took a while for anyone to do it at all. And then it took a while to figure out how to figure out the UX kind of questions. And then it took a while for people to do it in the more general way where they weren't just like, here are, here's a thing we were already doing, except now we're using the Miniscript library.
1:12:09Like here's something, here's like real new user capabilities. So, okay, so your question wasn't how long will it take, but like how many people will need to rewrite it? And I would submit that fewer people than with Miniscript. There was Miniscript, the people who needed to rewrite their stuff were the people trying to do complicated multi-party kind of constructions. And then Miniscript is actually sufficient for a lot of that kind of stuff. It will let you do decaying time locks, which are really decaying threshold signatures, which are really like the big thing.
1:12:53And so where Simplicity would first come in, well, first off, using Taproot, you can kind of combine Simplicity and Miniscript and old school script. Where I would expect we'd see people using Simplicity for a little while would be, maybe they don't like the time lock opcode because it's got a one year limit or because it's got, oh, this is a bad example because that's built into the transaction structure. Maybe they don't like the check multi-sig opcode because it is like a fixed, or the check-sig opcode now, because it's kind of a fixed threshold, right?
1:13:28You have a whole bunch of keys and they have a single weight. And you can't say that like one key counts twice as many as the other, at least not easily, not in Miniscript. You can't say that one key is needed only under certain other conditions, like who else is signing or what is the transaction shaped like, or how much money is moving, stuff like that. So what I would imagine is that people will take Miniscript and kind of bolt on kind of subsets. So they continue to use Miniscript for most of their pub key and hash preimage checks and stuff like that.
1:14:07And then they bolt on some extension to Miniscript that under the hood is using Simplicity in some very narrow computational way, basically just to replace an opcode that isn't in Bitcoin. And then where people would need like the full power of Simplicity, where they're like writing their whole script in Simplicity is where you've got some like fairly complicated business logic that maybe previously you were writing in some really bespoke HSM control language or something. And you want that to be enforced on the blockchain. And it's got a whole bunch of if statements and conditionals and all these different rules that are like different destinations and templates and stuff like that.
1:14:49And so who has to rewrite it? I would say basically just like enterprise HSM kind of like consumer wallets. It's hard for me to see, at least for a while, consumer wallets having any real users. Right. I can see it being used for complex enterprise policy kind of things. I can see it being used as a specification language or as a way to prototype new opcodes and stuff like that. And I can see it being used as like part of cool experiments that are maybe bigger than opcodes.
1:15:28So maybe things like arc or bit VM or a stark verifier or whatever. Maybe people building those things up.
1:15:48So I would say, unlike Taproot, which let you do a lot of existing things people were doing, but more efficiently. And unlike Miniscript, which let you solve problems related to multi signatures that people really were chafing at. From a user perspective, I would say that it's hard for people to do that. I don't think Simplicity is going to cause a lot of shakeups. I think the places that Simplicity are used are mostly places that are pretty far away from an ordinary Bitcoin user's experience.
1:16:23Vlad CosteaWould you say that Simplicity is a replacement for soft forks to add opcodes or is it complementary?
1:16:35Like we still need to add OP_CAT if we get Simplicity or is it enough to build everything that we need?
1:16:43Andrew PoelstraOh, that's a fun, so okay, there's two questions here. So one is, would we literally want to add OP_CAT or new opcodes to the pre-Simplicity Bitcoin Script? And the answer is probably yes. Maybe not OP_CAT because all the things OP_CAT enables are like complicated computations and stuff that like really, Simplicity is better suited for Covenant logic. Simplicity is better suited for checking Merkle trees. Simplicity is better suited for pulling apart signatures and applying constraints to them. Like really all the things that people want to use cat for, I would say are in the general computation category.
1:17:25But would we want a new like quantum signature check opcode and put that into script even if Simplicity was there? And the answer is probably yes, right? Like script is easy to use. A typical script only does like one or two things. So as much as I complain about it having no formal model and being really hard to reason about, if you're doing like a single signature check, it's pretty easy to reason about a single signature check, right? And then why would you, like, easier to just avoid all of the infrastructure of Simplicity and just use script directly for something like that?
1:18:01And we would probably want a quantum, like a quantum-hard signature for users like that who don't want to take the plunge into this giant general computation world. Now having said that, I would expect that any opcodes, if we had Simplicity deployed, the only opcodes that we would add to Bitcoin Script would be ones that had been prototyped on Simplicity and that has seen real world usage. And we could get some feedback that way. And then we could learn like what are things, what are people prioritizing, what are people willing to spend their fee rate on?
1:18:37Like what, of the different competing quantum signature things, we could have some iteration and like let one of them win in a blockchain context, right? Instead of trying to take general purpose NIST competitions and stuff like this and hope that what's best for the rest of the world is what's best for Bitcoin.
1:18:56So we would still see old opcodes. There's a related question, which is if we had Simplicity, would we need to change Simplicity itself, right? Would we want to modify, if Simplicity can really do anything, would we ever want to add new stuff? And the answer to that is also yes. So one thing we haven't talked about really in the last hour and a bit is jets.
1:19:21And what jets are basically, they're similar to opcodes in spirit. They're chunks of Simplicity that can be wholesale replaced with optimized C code. So if you were to do a SHA-2 verification or a SHA-2 hash in pure Simplicity, you can do it. But if the validators run through all of the like billions of Simplicity combinators that are involved in implementing that would take several minutes or something for something that should take 200 nanoseconds. So instead we have an implementation of SHA-2. In fact, the implementation of SHA-2 in OpenSSL was implemented and proven in verified C to match the abstract mathematical model of SHA-2.
1:20:09So what we can instead say is every time in Simplicity you see the SHA-2, this whole tree that represents SHA-2, which you can recognize immediately by its Merkle root. Then... don't recurse into the Simplicity and evaluate it. Instead, back out, call some C code, do it in a couple hundred nanoseconds instead of a couple minutes, right? And then, and now it's something practical. So in Simplicity, as we've deployed it in liquid, and as we would deploy it in Bitcoin, we have a whole family of jets like this.
1:20:36We have SHA-2, we have Schnorr signature checks, we have various time lock parsing computations, we have arithmetic of all forms of all bit sizes from one up to 256. We have multiplication, division, modular arithmetic, Euclidean division, some things related to EC math, like all these things that are jetted up. And so if somebody were to take Simplicity and implement a STARK verifier, as the StarkWare people did, right, they would have to use the bare Simplicity combinators and the jets that we've already provided. And in practice, they're finding that their STARK verifier winds up being like a few hundred kilobytes in size, right?
1:21:15It's just a massive thing. And there's some optimization they can do for sure. But like, really, if people are doing a lot of STARK verification, then we should jet out large chunks of the STARK verifier, right? Maybe we should have a jet that does a whole STARK verification, that will be pretty big. But at the very least, we could have a jet that like works, does arithmetic in the field that they need, or uses a particular hash function that they need, or does a particular polynomial Fourier transforms that they need.
1:21:41Like we could jet out those components, and then each time we added such a thing, it would make their script that much smaller and cheaper. So in Bitcoin, basically the way the world would change is that rather than having all these things that are impossible to do, and you need a soft fork to make them possible, with Simplicity, everything will be possible, but you might need a soft fork to make them economical, right? Like everything would be possible if you're willing to make a large enough transaction and spend enough money.
1:22:10But for them to be used by most users, by ordinary wallets, you would want to jet that out. And then do you jet that into Simplicity, and or do you just add an opcode to Bitcoin Script? That's kind of a fun question, and obviously it would be a case by case kind of debate, but I think it wouldn't always fall one way or the other. I think there's totally still room to be extending the existing script system.
1:22:39Vlad CosteaYour closing statement sort of reminded me of something that's called Collider Script, which is a paper that got published last year, I think in November. And what it does is to prove that you can basically fulfill the same functions that OPCAT brings to Bitcoin, but at a very high cost.
1:22:58Andrew PoelstraYeah, absolutely. I was part of the Collider Script paper. And yeah, essentially the premise there is that by generating carefully constructed SHA-1 collisions, you can emulate OPCAT in Bitcoin. Sadly, you can't. So several years ago, there was a major SHA-1 break where you could do it for $10,000 on AWS. Sadly, we can't use those collisions for this purpose. You got to do them the hard way. But even the hard way turns out to cost, I think we computed that if you were to tape out an ASIC, and so let's ignore the development cost of the ASIC, you could run the ASIC for like $50 million in electricity and then generate OPCAT this way.
1:23:35But it's possible, right? And with further optimization, maybe we can get that $50 million number down by, I guess it would need to be several orders of magnitude before anybody would do it, but it's possible. And Simplicity obviously would be less extreme, right? But yeah, it's a very similar premise, right? And it's kind of interesting that we found even in the existing Bitcoin Script, there are these kind of trade offs where things are possible if you're willing to spend a lot of money, and we need soft forks to make them economical.
1:24:12But in Simplicity, it would be on purpose.
1:24:19Vlad CosteaIt's pretty cool when you think about it that whatever you think that is enabled by these covenant soft forks can be done, but with a very high cost, both in terms of fees or how much you pay and also computation. Yeah, yeah.
1:24:40Andrew PoelstraAnd in Bitcoin, we really try, we're running a little low on time, I do have to drop in 10 minutes, but in Bitcoin, we really try to connect those things, right? You really don't want validators or developers to have to think about two dimensions, you don't want to have to think about your CPU and about your memory usage at once, because that's really hard to find an optimum. And in Bitcoin, there's this really cool property that basically every opcode takes one byte to encode, and every opcode costs roughly the same amount as any other opcode.
1:25:18Or rather, there's a cap on the maximum cost of any opcode. And it turns out that with the exception of signature checks, the most expensive opcode you can do in Bitcoin is a SHA-256 without an optimized CPU. And it turns out that if you made a transaction with nothing, like a whole block with nothing but SHA-256 calls, it would be okay. Like nothing but, I think the worst thing you could do is keep hashing the empty string or hashing a single byte, whatever you're allowed to do over and over.
1:25:50And so that's two bytes per.
1:25:55So, historically, we had kind of two budgets. There was a kind of normal opcode budget where everything, every opcode cost you one weight, one weight. And coincidentally or not, it turns out your block size was set up so that even if you use your weight, worst case for the SHA-2 opcode, so the validation time would still be reasonable. And then we had the separate opcode, the separate budget for SIGOPS, for checksigs. Because if you had a full block of nothing but checksigs, that would not be cool, right?
1:26:26Every checksig is something like 50 microseconds to do, right, times a 4 million weight unit block. Let's convert that to seconds.
1:26:38No, it's only 0.2 seconds. Maybe that's okay. Or maybe I have some issue with zeros. And 2.2 seconds is pretty bad for a single block. So we had the SIGOPS budget where within a single block you couldn't do more than 20,000 checksigs. In Taproot, we, and this was a problem for Miniscript, right, is that we had to think about what is our weight limit. We also had to stay inside of the SIGOPS budget. We also had to stay inside of the opcode limit that really had no business existing.
1:27:06It didn't serve any purpose beyond making people pay for weight. We had a couple other limits. In Taproot, we got rid of all of those. And the way we handled SIGOPS is we said every checksig needs to have 50 weight units associated with it. And the cool thing is, like 50 is somewhere in the transaction you need to have 50 weight units for every checksig that you use, or somewhere in your script. And the cool thing is that a normal checksig user puts a signature before the checksig, and a signature is more than 50 bytes.
1:27:35So a normal user doesn't even notice this limit. But a crazy user who is doing like OP_DUP on a single signature over and over and then checksig on all the duplicated signatures in order to get a one-byte signature, that user is now unable to fill a block with those. Now they can only fill 1/50th of a block with those, right? That's the rule. Every checksig that they use has to use 50 bytes. And so now the maximum block time, maybe it's 0.2 seconds. Now it's 1/50th of 0.2 seconds, which I guess is 0.254 milliseconds.
1:28:09And Simplicity retains that. So one of the big problems that Ethereum has had is that their opcodes vary wildly in what resources they use. Some of them are CPU-bound, some of them are disk-bound, some of them do random lookups, some of them call into other contracts, some of them, well, none of them do network access, of course. But like there's all these different opcodes, there's wildly different weights that they've struggled to assign gas costs to, and every single opcode needs a different gas cost. And in Bitcoin Script and in Simplicity, we've been able to retain the one-byte, like the size of your transaction is what you pay for kind of model, which is pretty cool.
1:28:46And in Simplicity, we had to kind of steal the Taproot idea, where a validator takes a Simplicity program, which might be encoded very compactly. They scan through the compact encoding to find out what the real weight is, which is how many CPU cycles are involved. And then the transaction needs to be large enough to support that weight. And if the transaction is not natively large enough, they've got to stick some zero padding into the Taproot annex or something like that. But this was an important design goal, and it's a really cool property of Bitcoin, that there's one property you need to optimize, which is the size of your transaction.
1:29:19And we retained that for Simplicity.
1:29:24Vlad CosteaI really want to ask you a controversial question before I let you go. Like, I know you have five minutes. Can you name three altcoins which are not scammy and are actually interesting, at least from your perspective as a mathematician?
1:29:38Andrew PoelstraOkay, so which ones are interesting? That's actually easy and not too controversial to answer, of course. So, like, Monero and Zcash are the first to come to mind, because they have some really cool privacy tech that are built into there. Siacoin, there's an old obscure one. Siacoin I kind of like, because they do file storage in a way that is like dead simple cryptography. It has kind of a goofy reputation, IP address publishing kind of system built into it. But the premise is that you can buy, you can rent, you can upload files.
1:30:17You have a file you want to back up, you encrypt it, you split it up using erasure coding or whatever. And you upload it to all these different hosts and then the hosts have to provide on chain these kind of proofs that they are storing. These like random cut and choose proofs that they're continuing to store your data and then they get paid out of some sort of bond output. So there's this cool technology in all of those. The Mimblewimble coins, I guess mostly Grin because that was the first one.
1:30:41That was also pretty cool technologically.
1:30:45Who else is doing cool stuff?
1:30:51I actually give Litecoin some credit for deploying confidential transactions. So that's cool. I'm glad that somebody is deploying CT. Although Monero did it first. So I already said Monero.
1:31:00Vlad CosteaI don't think they have CT. They have Mimblewimble. Oh okay,
1:31:04Andrew Poelstraokay. I think they wanted to have CT and maybe they haven't done it yet.
1:31:13Okay so then the second part is like which one of these are not scams, right? And I will say that Grin and Monero I think were both sincere in their goals and like really strive to be legitimate altcoins. Both of them, actually interesting, both of them I would say had the same failure mode where they both have an infinite issuance. Which I think is just, I only have a couple of minutes but I don't think it makes sense to have an infinite issuance. An infinite tail emission in a world where Bitcoin already exists as a finite supply, right?
1:31:51Because then you've got a, but you know what, neither of those coins did an ICO. I think did Grin do an ICO? I don't know. Okay yeah, neither of them did an ICO. They both kind of did their best to fund their development in a reasonably equitable and transparent manner.
1:32:12Yeah I have nothing in particular against those two coins.
1:32:16Vlad CosteaI mean Monero does have that start with Bytecoin and all of that story like I don't want to get into that. But it's like an honest community fork from something which was supposed to be pre-mined and have some shady connections.
1:32:32Andrew PoelstraYeah that's a great observation and yeah and unfortunately I've got to drop in a minute but that's a great point. Is that Bytecoin 100% a scam and Monero came out of that. That's a much better community.
1:32:44Vlad CosteaAlso I wouldn't say that Zcash is scammy because it's still 100% compatible with Bitcoin. And what they were able to do with eliminating the trusted setup and making their ZK verification more light so that you can do it on mobile. I think it took a decade for them to get here but I have a lot of respect for what they accomplished.
1:33:06Andrew PoelstraYeah, yeah, yeah. Great points. Great points.
1:33:11Vlad CosteaThank you very much. Where can people find out more about your work with Simplicity?
1:33:19Andrew PoelstraWell simplicity-lang.org is our main landing website that's got links to all our documentation. We have a book that's half written about the Simplicity HL language. You can find our developer playground. You can find links to all our GitHubs there. That's simplicity-lang.org. It's probably the number one resource and that's where we'll be posting updates. And of course active development happens on GitHub which you can easily click through to from there.
1:33:47Vlad CosteaThank you very much Andrew. I still have to mention three more sponsors but you can go. I'm not gonna hold you.
1:33:55Andrew PoelstraAlright I'm sorry I've got another call now. Thanks for having me. It was great to see you and I am gonna drop right now.
1:33:59Vlad CosteaThank you everyone for listening up to this point. Thank you Andrew. And I gotta mention Edge Wallet and Andrew is gone unfortunately. To everyone who's listening to this, you're a hero. Thank you very much for it. And I hope that you're not dropping out just because Andrew did because I do have to mention that Edge Wallet is really interesting. And it has this duress mode that you can use when someone's looking over your shoulder or when you're traveling. And you might get asked by TSA to unlock your wallet to show what's inside.
1:34:37Basically you have a secondary pin that you're gonna type and it's gonna open another wallet where you can have zero funds or you can just have $10 that you put yourself. And that will help you not get robbed. I think that's the whole point. And also it supports a lot of assets and enables in-app swaps. So if someone sends you something like let's say Dash and you don't want to hold it, you can swap that into Bitcoin within seconds. But of course it will take a few minutes for the blockchains to provide all of the confirmations.
1:35:14And you can download Edge Wallet from edge.app. And there's also NoOnes.com which is a peer-to-peer exchange where you can interact with the global south and empower this mission by Ray Youssef to make all the lions from Africa and from the Middle East and from South America have access to this global economy. To get liquidity, if you have gift cards you can sell them, if you want to spend your coins there is this debit card. If you want to use the spot exchange you also have that option.
1:35:48There is a lot to be found on NoOnes.com and I do like the mission of it because Ray Youssef takes the profits, goes and builds schools in Africa. And he seems very determined and committed to his purpose of eliminating this disparity, this cleavage between what's happening in the Northern Hemisphere and what's happening in the Southern Hemisphere. So check it out, it's NoOnes.com, N-O-O-N-E-S.com. And last but not least there is Bitcoin.com news which has rebranded, now it's not the green website anymore, it doesn't promote or display the green Bitcoin.
1:36:29It's actually orange if you check it out right now. And I do like the fact that they have very diverse news and you find news about gold and silver and about Bitcoin markets outside of the US and what's going on. I do respect the journalism that they're doing and I like that they're not entirely focused on what's happening in the US as other publications seem to be. And yeah, there's a lot of news that you can find there if you just check it every morning. You can find the essentials, they have a section about mining, they have a section about geopolitics and economics and it's very interesting.
1:37:13Of course you're gonna find something that you're not gonna agree with, that you might label as shit-coiny, but you can just curate your own feed and navigate to find whatever you think is interesting. So the URL is news.bitcoin.com and thanks to all the sponsors for supporting the show, thanks to Andrew for joining for I think it was about 90 minutes. And I hope that you guys who have been listening to this learn something new about what Blockstream is doing and what is this Simplicity and whether or not it's really simple as the name suggests.
1:37:49If you have been here for all of this, maybe write something in the comments like COQ, which is cock, write that. It's like this joke between cryptographers and if you have been listening to the interview you know because Andrew told the story about it that the French decided to tell a joke. Because for them beat, B-I-T is the way that they pronounce penis and they wanted to also pull this joke on the English speakers to have a language that's called cock, C-O-Q. And yeah, write COQ in the comments if you have been listening up to this point.
1:38:35Thank you very much and I'll see you in the next one in which I'll be interviewing the CEO of Bitrefill and the creator of PPQ.AI. It's very interesting and it tells you a lot about the state of Bitcoin adoption. Thank you for being subscribed to the Bitcoin Takeover Podcast.