A security-in-depth approach to verifiable off-chain computations
ETHCC 7 · 8 Jul 2024 · 23:30
Thomas Bertani argues for a security-in-depth approach to verifiable off-chain computation. He describes a proof layer behind scaling, cross-rollup composability, oracles and coprocessing, and says Vitalik's vision of Ethereum mainly verifying a ZK proof is still far from today's practice. His approach combines several independent proof systems, such as multiple zkVMs and trusted execution environments, so one compromised system is not enough, with the mix changed through configuration. He says the project is a public good with no fee and does not suit non-deterministic computation. He also describes a bridge aggregator using about 20 bridges for redundancy.
Speakers
Topics
From ETHCC 7, hosted by Ethereum France.
Transcript
Yeah, no problem. Hello everyone. Thanks for having me here today. So I will be speaking about like a security-in-depth approach for off-chain computations. So first let's have a look at the scalability roadmap. So we know that on Ethereum, but also on other chains, there is like a road of on uh you know for scalability, which is leveraging basically uh the separation of um the state into several layers. So we have layer twos, we have up chains, and they all somehow inherit the security of the base layer of Ethereum, for instance, as a layer one.
This needs to have proofs or something that basically you can use to challenge the state, uh potentially legal state and solve disputes. So this is in general something that here um I'm trying to abstract out with this concept of the proof layer. The proof layer today doesn't really exist, right? We just have many proofs um that are being used for a variety of things, but in general it's really critical to to have them in order to have all the best security properties we want with blockchains. So let's look at some of the use cases uh that proofs are required for.
So one we already mentioned, like scalability, so basically vertical scalability. So um layer twos, layer threes, and so on. Another one is like uh um the composability across different layer twos, or let's say shared sequencing conceptually. Something else that was mentioned also by Mark earlier is the concept of oracles. Like how do we bring in external data with some kind of guarantees? We need proofs. These proofs could come in different flavors, but at the end of the day, we need something we can back our data with and something that is objectively verifiable. That's why here I'm just defining proofs for clarity because we always mention proofs, but we never define them as sort of a portable verification of a statement.
And the third one is like co-processing, which recently has been trending a lot as a topic, which basically means designing systems that can work together with blockchains so that you can offload heavy computations while retaining the transparency and maybe also some privacy properties there. This tweet from like a few months ago from Vitalik started many, many discussions. Committing just a ZK proof for their state, and Ethereum basically doing nothing else, literally nothing else.
Maybe just verifying a single ZK proof potentially for uh for each block or epoch. The problem is that today we are really, really very far from that. So on paper, we want to achieve it. In practice, um often we are compromising security because the end user normally doesn't care that much until it's too late. And protocols don't want to compromise UX, or maybe don't have all the primitives they need to actually implement this kind of security. So how do we get there?
Let's look at how things are today. So the proving landscape in general, we can split in three parts. So we have the proof production process, like how do we generate those proofs. Then we have the proof verification process, like how do we actually you know submit those proofs for verification and make sure they are accurate and enforce their correctness. And the third part is basically uh the implementation, like how that uh how do those systems work, and what are the implications there? Do we have problems in uh the code base in the libraries in the assumptions uh that back both the production and verification of those proofs?
So in the proof production, there are some issues um like basically inefficiency driven by um I would say mostly fragmentation. Like there are many different proving systems. Here I'm not just referring to ZK PROS, ZK Pros is like a big primitive. You may know, for example, uh that the trust implications of like uh Starks, SNARKs, or even just you know reduction to GROT 16 and stuff like that, they they they come at a cost. Um, and trust assumptions change, but on-chain we don't have much freedom. So we are sort of constrained and we need to work with what we have today.
So there are some issues there basically, and in many cases, there are also lock-ins. So there are some algorithms also with like um those those proofs I mentioned, um, which actually depend a lot on the library use and they are not easily interoperable across libraries or across projects. So while on paper it's it's possible, in practice, we are we are not quite there yet. Um with proofs, I'm also like referring to more in general, other kind of like um backing of our statements. So also TE attestations, trusted execution environment attestations, to me are just proofs, right?
Um of course there are different trust assumptions, but still um they are proofs. So they inherit the same problems here. Uh as for the verification, there is a growing demand. Um proofs will soon basically be everywhere to achieve what we have just seen. Um but yeah, we have you know block gas limits basically. Um so and and verifying proofs are very expensive. So sure, we can use pre compiles, we can optimize stuff so that it becomes viable to verify some of those proofs on chain. Um most ZK proofs verified on chain now are just you know GROT 16 um on Ethereum.
So there are compromises being done there. Um but in general that there are some issues um also you know on gas cost, for instance. If if we spend potentially millions of gas for verifying proofs, uh and there is a very volatile uh gas market, uh then clearly there are big implications on the cost to run a system. Um the third one is like implementation, like there is like a big um attack surface in many cases, and like the code and the algorithms that are being used are often little understood, and there are actually complexities in auditing them properly. And people are often um like at least based on our experience, you you will see in a bit on some of the work we have done, most people reuse existing libraries uh that other projects are used.
And if you go deep and deep and deep and keep digging, at the end there is always a tiny library with a big warning on GitHub saying please don't use this in production. And actually everyone is using those library. So avoiding vendor lock-ins is very important because if you have dependency from a smart contract level or both on-chain or off-chain, basically, on some proprietary interfaces or proprietary standards that just a single project uses, then there is too much at stake.
This project could just you know disappear, or you could have zero-day vulnerabilities, even in the algorithms they use, or maybe just in their implementation, because maybe their code in theory looks good, but then in practice, you know, maybe some years later, we find issues there. So it's important to avoid vendor lock-ins so that it's easy to basically switch to alternatives if there is any available. Another one is security in depth. So security in depth is something that in my opinion, there is no good reason not to do, not to um like uh uh aim for in this space, but it is underused. So we need desperately security in depth.
Well, security in depth means having different layers of protections backing the same fact, the same claim. So if we uh we if we can use, for instance, at the same time, trusted execution environments and ZK proofs and other kind of guarantees, there is no reason to just use one. The only downside today is basically cost and uh latency and worse UX. But if we can actually solve those and use them together, there are multiple layers of protections. So if one of these gets hacked, we still have the others. And this is very important.
Like let's even let's keep in mind that even with ZK proofs that many see as like the ultimate solution for everything, um, there is lowness today. It will improve, clearly. I'm uh I'm very optimistic there. Um, but it's very expensive, and many of the algorithms used are not even even quantum resistant. So I mean, let's keep in mind longevity is very important with blockchains. Uh indeed the third value is future-proofness. Like we need to design systems that will like keep working for years to come. Because if we have an external dependency and our code is immutable, what happens if it gets hacked seven years later?
Right? Um, it may create systemic risks that we had not foreseen when we first deployed the contract. So these are all like important elements that we try to implement when we um lodged Ashi. So ASHI is like an abstraction layer uh that tries to basically follow these principles and solve the uh this problem of fragmentation just for a single vertical, which is basically um cross-chain bridging. So it's just one very limited use case, it's not a general purpose solution, it just works for cross-chain bridging. And it doesn't do much.
Basically, what it does is just saying um if you need to send a message from chain A to chain B, don't use single protocols like um, you know, warm all hop, uh, layer zero, or I mean, all the existing ones, um, use an abstraction layer which is extremely thin, completely on chain, and basically send the message redundantly, security in that approach. So use maybe three solutions you like, you may pick three existing ones, send it repeatedly. Sure, it may look inefficient, it's more expensive, but if one of those gets hacked eventually, you still have the protection from the others. So it's like saying, let's promote the use of a multi-sig for bridges.
So we still need bridges. ASHI doesn't work with bridges, it needs bridges. It currently is integrated with 20 bridges. Um yeah, this abstraction layer and is sort of an aggregator that promotes redundant uh redundancy is very important. This is something that like last last year uh the Uniswap uh independent uh bridge committee considered like the best option available uh on paper for like uh uniswap in general for everyone for cross-chain bridging, but they discouraged its use because it was too recent. It was like a code base that had been released just a few weeks earlier, and it was not butt-tested.
So that that's a very good argument, actually. We need code that is butt-tested and that we know will last for a very long time. So today, Ashi has improved a lot since then, and it's actually under audit uh for the integration with the Gnosis chain canonical bridges and also on the laxo main net canonical bridges. So Ashie will soon be integrated within you know those um layer ones, basically, um, to back the security of their bridges. And underneath, it's still using existing cross-chain bridging solutions, but not just one, it's using more than one, so to avoid the central points of failure. So, with ASHI, at least for one vertical, so for a limited use case, what did we solve?
Well, some problems, like we can avoid lock-ins into single bridges. We can like uh uh lower the risk of vulnerabilities being there in the complex of chain systems, uh blockchain uh like bridges used for validation of cross-chain messages. Um so we reduce systemic risks in the end. But there are many other problems, like fragmentation and costs. Can we actually reduce them in a more general purpose way? And this is something that we asked ourselves uh actually back like early this year in January. Uh we were trying to improve ASHI, and we noticed you know, that basically it was very difficult to actually solve this problem, and that there were no solutions on the market that could help much.
They all had some kind of like centralization issues or trust assumptions that we were not okay with. So let's look at the proving universe. Today, the proving universe has like many co-processors like ZK VMs, the EVMs. You may have heard of SP1, RISC 0, JOLT, and so on, or others, uh like uh proof cast accuracy, and there are many others also with TEs that the names you surely know. Um there is a proving infrastructure, like people that can actually generate proofs. Um, for example, like um Gavulo and others, um, also bonsai and so on.
Um there are proof aggregators, they can basically socialize the cost by generating a proof of proofs. Um very promising, uh a lot of complex work there happening, things that like electron labs, Nebra, aligned layer, and so on, um, in different ways. Then we have proof bundles like single proofs from different like systems, like proving authenticity of web API calls, like HTTP calls, or like zero-knowledge light clients, um, or you know, you you name it, like many use cases where you have specialized proofs uh for something very specific. Uh and then we have layers to create basically um crypto economic uh security systems like eigen layer and so on, and we have blockchains.
Um are we missing anything? Well, we believe um that basically some properties that are critical for a non-fragmented um proving universe are actually currently missing, and by reusing those components I mentioned along with something else, we can actually have a much safer and more future-proof solution on blockchains using proofs. So, this is what we have tried to um like take home with Safe Junction, um, which is like a new project that we have as has been in the working since uh basically January, February. Um, and that tries to achieve abstraction um and it helps with uh indexing and querying anything provable, basically.
So let's look at how it works. So the idea is to generate um sort of a database for proofs. What does it mean? Like a system that looks and feel to a developer like if it was a normal database. So you can read it, you can add data, you can read data coming from existing records, and you can reach conclusions, maybe you know, with views, and you can do map reduce, you can you you can do some light post processing on data as if it was a database. But clearly, if you are using data, if you if you're using blockchains, it's because we are not okay with centralized systems and with traditional databases, so we want something that basically looks and feels like a database, but is basically as trustless as possible.
Can we actually achieve it? That's the challenge here. And what Save Junction tries to do is really taking this home. How you write a piece of code with like an SDK called T Rust, and it looks like a normal Rust code. So it's like if you were writing Rust code for your own machine. This is similar to the value proposition of some ZK VMs if you have built with them. The difference is that you are not using anything specific to any proving system. So you're not using like crates, optimizations, um precompiles, um compilers of any single component of this.
You are using the TRAST SDK, writing code once, auditing it once, and you can execute it, uh, you can compile and run it on any proving system that is supported. Currently, we support you know SP1, um RISC0, AcuraSproofcast, so both these TVMs and ZKVMs. So the idea is run it once, um write it once and run it multiple times with different uh proving systems. This is critical because this is what enables the security in depth approach. Like you can define what you want and then back it with multiple proofs. Um then the interaction process is as follows.
You write your TRAST code, um, you basically ask for it from your contract, and then an off-chain system, which is really our database, um, is executing redundantly your query against the database, reading state from different proofs, and returning a single aggregated result on chain. So this is something that is basically interoperable and that needs to work with aggregators, it needs to work with proving systems, it needs to work with ZKVMs, with TVMs. It doesn't do any of that.
It simply uses them and tries to orchestrate them in a way which is meaningful and that gives you good properties and that promotes redundancy and security in depth. So, in conclusion, what we can achieve with this like database-like structure, which we call the safe junction engine, um, is a system which is completely chain agnostic because it leaves off-chain, so the commitments can be sent on any chain, and that basically um gives you the security of proofs without the downsides. So you don't see the fragmentation part, you don't see the lock-in part.
You don't have to rely on the trust on any single component. Behind the scenes, the engine uh has this basically main pieces internally. So on the top left, you see the work aggregators do. Like think of this as you know, Nebra, line layer and so on. So they will be there. So we can include facts, meaning uh statements backed by proofs, from those systems. Then we give like tools to define in t-rast, agents, and views. So agents are just off-chain like code snippets that basically run whenever you want, and that can reference data coming from either blockchains or from this database state.
Views are the equivalent of views for traditional databases. So they are a primitive where you define a map reduce in T-Rust and you can read data from different proofs from different um like yeah, proofs in the database, and reach some conclusions. So, for example, something you could do is use it for to improve ASHI. So you could say things like, okay, the aggregation part, checking if the underneath bridges I'm sending the cross-chain message with, um, checking if they are equivalent, if there is consensus, could finally happen off-chain with the backing of several proofs. So I don't depend on the security on any single system.
And I can retain the same properties of like avoiding vendor lock ins, future proofness, and security in depth that we wanted to achieve before. The difference is that now you have like a much lower gas cost on chain, so security becomes like viable again, let's say, and interesting again. The problem is that today people are not willing to pay for security until the money are already lost. So this is why it's important to lower costs and to make this something more attractive from like uh gas optimization perspective. Use cases are many, so you can see some of them here.
I mentioned them also at the beginning of the presentation, so I think I have maybe a minute left. So if there is any question, take it. Thank you. So thanks uh for the presentation. I was just wondering in order to bring this security, how much is the cost, like estimated costs that somebody has to pay? And does this approach work for non-deterministic compute?
Um so it doesn't work with non-deterministic compute in general. I I mean there are exceptions, but uh if you want non-deterministic compute, you would need to work with a single proof because you will not find consensus, right? At least in uh the let's say simple case. Um as for the cost, uh safe junction at the moment is being built as a public good, so it doesn't have any fee. Anyone can work on iterations, so you don't have any additional cost compared to working on you know the generation of this proofs, depending on the security you are looking for, you can change the configuration, like one line of code and decide if you want, for example, to generate proofs backed by many ZKBMs, which may take more time and maybe have higher you know prover costs, or if you want maybe to have multiple T's, quantity or some TEs and one ZKBM.
This depends basically on your use case and how much security you need. So this proportionally affects costs, which are basically at the moment just for the most part, uh depending on the you know proving machines. Understood. So for non-deterministic cases like ML uh machine learning and uh LLM training, etc. Which uh proof or which method of proof you would you recommend? So in general, um it depends on the algorithm, but uh in some cases you can find aggregations that make sense, or you can try to execute it non-deterministically and then try to see if you can reach a single conclusion. Um so this is one way.
Um another way would be like just basically not using the security in depth property, which is a pity, but clearly I mean depends on the use case. If it's not possible, then it's not possible. Um but you can still have all the others. So for example, you can write your code once, even non-deterministically, and today maybe you can execute it more cheaply on TEs. Maybe tomorrow once CK VMs will be faster without writing any line of code. You can change the configuration and switch to ZK VMs, and it will just work. Thank you.
Related talks
- Zero-Knowledge Proofs Panel
- ZKMPCML: From Memes to Reality
- Verifiable Inference: Don't Trust, Verify
- ZK12: Towards Verifiable FHE in Practice - Michael Walter
- Keynote: Programmable Cryptography and Ethereum
- ZK14 - Making verifiable FHE practical - Daniele Cozzo (IMDEA Software Institute)
- Encode x Worldcoin Educate Series: ZKML & MPC Uniqueness Checks
- Programmable Cryptography and Smart Contract by Shouki Tsuda | Devcon SEA
- Verifiable Computation and Multi-Party Workflows | Fernando Castillo - Dober