Angelo of RISC Zero @ ZK Hack Meetup in Lisbon, 10 Oct 2024

ZK Hack Video Archive · 10 Oct 2024 · 28:46

Angelo Capossele of RISC Zero introduces Steel, a view call proof library powered by the RISC Zero zkVM, at the ZK Hack Meetup in Lisbon on 10 October 2024. The talk is framed as a journey about love and relationships that leads into the library. It is the second of two talks at the meetup, which was organized in partnership with vlayer and RISC Zero.

Speakers

Topics

From ZK Hack Video Archive, hosted by ZK Hack.

Transcript

[Music] all right guys can you hear me well cool so I'm Angelo I work with the risk zero and uh I was really trying to figure out a way to be me so I decided to try take you on this little journey right about love and relationship kind of I mean relationship are tough right I I bet you you you guys had the tough ones someone relationship no uh definitely

good ones right otherwise you would not be smiling right now mix but but in general they they are tough right I I love this quote from uh Dr uh Aon I hope I pronuncia him correctly but it basically comes from this theory of self-expansion and kind of says that when you are in a relationship you you in order to to get the most out of it right you really need to embrace uh the resources the the perspective of of each other so that then when you can take you know challenges together you get the best out of it right and and typically this uh brings to you know a healthy and long

lasting relationship so now you will be confused because of what the heck is this why are we talking about relationship now uh I will show you why so typically relationship start with the attraction typically right not all the time but sometimes they do and uh in the case of blockchain right um if you think about uh where blockchain is coming from you really need to try to you know uh um put the the blockchain hat right or or feel the the same shoes right it was originally designed as a settlement layer and uh of course you know blockchains evolved over time right but

you know intrinsically they they they still have uh uh the original challenges of course they they get improved right but uh I would claim that still we have some limited execution capacity and I'm talking about you know the the ability to execute a certain amount of computation obviously you know uh depending on the consensus all the nodes need to compute the same computation over and over until they reach consensus and so you have a it's basically Ain resource right to to the amount of computation that they can all compute before reaching consensus and you know advancing the state and this also brings uh the some of the scalability tradeoffs

right so you you have latency right you have also Hardware requirements that are blockchains that you know try to uh play this game rather than the other game and also you know also related to latency and you know other Hardware or networking requirements you have limitation on the Block and some of the blockchains also have you know uh privacy issue so think about uh or or maybe if I were to be blockchain right and then someone comes around and and basically whisper into my ear all my secret desired everything I always

wanted I I kind of feel like you know it's like game mom baby right so so Z comes and and basically you know promises this uh this moving the execution of chain to achieve a really high level of scalability and then it can be done with a very efficient way of verifying the proofs and they can also be you knowk can also be used to announce privacy then is it's like blockchain is U gets very euphoric right it's uh it goes into the second stage of a relationship where you basically start dreaming and see at the partner is like the perfect uh match like there is nothing that can go wrong

and uh you stop listening and be objective it's I think objective is is a really good uh phase I think everybody should experience even if you know the the outcome might be well not the one that you expect in fact in reality most of the time this is not looks like nonetheless if you really believe in this relationship you go on right and and you start a so- calleded early attachment phase and this is like one of the pH that I I really like because it's the the most natural one where you you know try to to get to know each other a little bit better you you start you know learning what uh you know the other

likes that dislike the pros and cons and uh and if you are still really into the the relationship uh depending on you how things evolve uh you might eat some crisis I I I bet any of us have experienced some crisis during a relationship right and in this case you know the the crisis can come from several aspect uh you know in the case of performance might might be because uh of you know proving times are too long or you know the the proof sight is too big it's uh it really it can can take several

aspects right but if it's uh you know if it's really it's not just a flint then you finally get the best right the Deep attachment pH and uh we kind of really believe in this relationship right so one way to to look at this to to strengthen uh this this uh we we think successful right Destiny uh it it's to really do a full stack commitment right and boundless uh is is is that right so we try to eat hard uh on every layer right from the from the execution in state-ofthe-art performance uh one of my favorite is the

integration with this really cool uh Dev tooling that helps you know uh people to to Really uh leverage the benefit from from each other right and then uh one also important thing that kind of touched to the you know the the self-expansion theory that I discussed at the beginning which is basically uh proving and in the case of ZK right uh I I I believe personally that that it should embrace the atos right of the blockchain and you know this de centralization this openness right so even the proving should be uh such that anybody can can basically participate into uh uh generating and and requesting

proofs right and and also it shouldn't be a limit to the blockchain but actually an an additional added value right uh and that also is achieved by making uh the consumption of the proof right of the output of this uh first of all cheap and second of all usable everywhere otherwise it's uh it's kind of pointless and then you get the crisis uh so this is basically a more practical view of what boundless is right you can imagine like from the from the lower um layer with the verifiable execution uh it's currently um we we have uh you know the risk zero Z KVM I

don't know how many of you know it uh or they have use it already it's pretty cool pretty fast and it's always improving and then we have also plan of course to to improve its architecture with a with a 2.0 version but we we also you know are open to uh to see the adoption of other uh you know dkbm on this layer and then you go up and of course you need to have a layer that make use of these uh nice um proofs right so so the ability to verify should be everywhere right so we deployed verifier contract in any chain or well most of the chains uh and then the in the middle layer is is the one that uh

you know I recall the the centralization um eils and and and openness so B basically we we envision the the the the proving layer to be decentralized where everybody can participate as Pro and uh also uh everybody can can request proofs right and there is no Central Authority single Authority single point of failure that could break this a nice game and then we have the super interesting integration tool I think we have seen one also in the previous uh presentation that kind of sits in that uh or or less like ler from my point of view which is basically the most important clue right to take some of the or most of the benefit that ZK can bring

to to any you know web three app uh in a seamlessly fashion right so one one example is z which is a block producer and then we have also blob stream zero which instead is able to uh verify the Celestia da attestation on on on chain right and then we have the basically uh main uh topic right of the rest of this presentation which is steel right so we we are going to get to to Ste in a second and then you have the top layer where you have you know the L1 you have you know rollups or you have co-processor whatever you want to do basically so talking about uh steel or

in general talking about integration toing right one question that uh I was always fascinated was uh how can we unlock provable smart contract execution oh basically I'm I'm I'm asking how can we create a good match between what is already in in blockchain and and and you know how to make it more viable using ZK and uh I'll go a little bit back historically because I don't know how much you know about you know how the the the storage Works in in ethereum and how you could uh basically at least start getting probably access account and

contract storage but long story short basically you can imagine you can s think about the the storage of smart contract right as a mapping of slots and values don't know if you were uh listening the previous presentation that the you know he mentioned uh with the kind of you know scary expression uh about slots it's not that they are you know ugly or or anything I like them they are index at the end of the day but uh the problem is that it's not the trivial to find them right and unless you I don't know you like uh going like you know

looking for mushroom or you know that kind of activity it's not like the best time to best to spend your time right so of course there are tools to to help you with that but I think we we can do better but in general the idea to you know historical uh way to to achieve this will be basically to find this storage slot and then use a really nice um method right that uh uh the the EIP uh 1186 standardize uh that is materialized with this eth get proof which is basically you give this you know slot index and uh and then this this method gives you back a sequence

right a a list of hash vales basically that you have to Ash together uh to prove that this slot belongs right to the State against uh when when fixing When selecting some uh some block number right basically it goes back to the to the RO to the root of that state and then you can perform this verification within a Z kbm or whatever right we can generate a proof for this so this is basically yeah the the long story short of this uh primitive now this kind of sucks right because again from a de point of view it's U it's not ideal and then of course depends on the taste of the the

person maybe there is like developer that just loves to do that super fine we are all different uh but one uh one other question is uh can we just uh for instance for instance query solidity functions I mean at the end of the day we want to know stuff about ethereum and the way you interact with ethereum is you know by a solidity right you write you read so in order to do that you will need to to do what to prove the execution of a given smart contract function right uh executing in the EVN you basically you just need to prove that and ter now that this is like not easy I mean not not not difficult at all

it's super easy right so uh this is basically what steel does right using uh powering by powered by the the the ZK VM it allows you to to integrate uh with with solidity you can literally just write solidity to to you know query uh any any any new call right uh without learning any new language maybe a little bit of rust current uh but in the future you will not need that uh and then one important thing is that you suddenly have unlimited compute and by that I mean that uh since you are executing of chain you do not uh need to rely anymore on the limit of the

computation amount right that one transaction or one block can can hold uh that also translate into reducing uh a load of gas to be French all right so so basically um what a developer can do with this right they can use exist existing U smart contract logic which you know it's sometimes in in the real world is super important because there are companies or you know application that they have invested and they have spent so much money they have audited their code so they would really love to keep executing that uh rather than

reimplementing the same logic into some other uh you know uh language also you can uh uh prove not only the latest date but also you know historic uh date um yeah you can basically query historic blocks right to get you know the state with respect to that block uh and you can also if you want you can just you know optimize a subset of your uh uh logic right uh with uh with that right in general one thing that I really like about this is that it it it unlocks uh materializing and and deploying application that otherwise would be just

impossible because of you know the current limitations and this uh you know it's something that uh makes uh first of all blockchain happy but most importantly everybody happy so how it works uh well the three is that um if you're not familiar with the the dkbm how it works basically you have you have a guest code which is basically the the code that runs into the the zkm the code that gets basically Prov right and then you have the the OST side which instead is basically the driver that fits the input and then takes the takes out the uh the result right from from the execution and uh using the host you can uh run a phase

that we call Pre FL which basically what it does is it it runs the the new call for you and uh it stores all the information the storage all the accounts that have been involved during this this call and for each of that uh basically you know storage and and account it it basically retrieve the proof of inclusion via this eth get proof uh so that uh then once this uh environment is fed into the guas the guest can actually verify that the entire environment where the then the next actual view call is going to be uh called is is uh as Integrity right with

respect to a given uh block right and then uh here is uh sort of an example the the guest side of of this is basically you have two ways to to actually do that right one is to use uh uh uh the soul macro of alloy that basically allows you to wrap into this uh you know Sol just solidity code right so here we we are looking at at the very classical interface the ic20 the balance off right basically the the only important thing about this is that it's a simpler more human way to retrieve a function selector which is

basically this bunch of you know uh data that uh uh the evm then needs to understand to understand what code to execute practically speaking we want to basically call the balance of a given account right and then get back some some balance right so you as as I mentioned before right what what the guest does it reads the input that are provided by the by the host right uh among the the this evm input which is basically this prepared environment that the host as as provided with the help of some RPC right uh provider and then in this case we have the contract address

that we want to query the uh the balance right as well as the account of of the you know uh the owner that that we want to know the balance of right and then we literally just call the ah sorry sorry important thing the last the last line is actually the mag where the magic happens right uh which is is basically uh making sure that the state the all this environment given by the OST has Integrity with respect to the to the committed uh uh route right and then uh you are sure that you are working on a safe let's say environment and then you you run this uh you call right uh and you get back some some result which in

our case is is the balance right so you can do whatever you want now at this point I was uh uh very uh imaginative and creative so I decided let's check if this balance has at least one uh token right that's a it's a pretty common scenario and then uh you commit uh committing to the journal we call the journal basically the output right of U of the uh of the of of running the the execution right of the guest code uh and we commit to the commitment which is basically contains the you know the the cryptographic insurance that the state was was correct so basically the the

root has right and the uh the block has and then then the the block number I guess also there are also other techniques other way to to commit using the the Bitcoin chain but we can talk about that later and then in this case you also want to commit to the to the contract right because otherwise you don't know who uh account you have U um uh sorry what contract you have used right it could be the you know the my toy contract right uh so you want also to let the the verifier know which contract has been has been created uh and that's basically it now in the on the o side instead I already mentioned basically

everything that is happening here uh but I will just recap it uh you just do some alloy boiler plate Shenanigans to to get some uh uh provider by the way allo is super cool just say shenan against too often um and then um you basically uh create this uh this environment right so basically uh you you you prepare the the RPC node that needs to be used to do all these uh all this query uh first of all the you know the the real query that you are interested in and then then also use it the same provider to get all the uh eth get proof for everything you need and then you actually uh run is pre-flight which does what I just said

uh and then uh basically that's the input that you're going to use to to Feit the the guest now once everything is done uh you can use it on chain right uh you what typically the terminology we use here just to to to help you understand what is happening here the journal data is basically the output of of the execution right and the seal is is is the proof that's just call them like is right so what you do you you decode your your journal and then you check whether you know the contract uh matches what you were expecting and then you also validated commitment meaning that in this case you want to be sure that the

state that you have used is actually a state that belongs to you know the change or or or the chain or it's you know the Integrity of of the claim basically uh against the you know that chain and then uh you verify the real proof right the ZK proof and then you are free to do everything you want right like you can go crazy uh as as much as increasing the count right so I I mentioned the the commitment right uh that you need in order to make sure that you are using uh a valid uh State and uh we currently support few techniques the

main two are either you use the uh the block cash so that you can on chain use this op code block cash which basically give you access to the latest 256 uh older blocks right the it's super easy and cheap to use the drawback is that uh you only have access to you know on ethereum basically the the latest 50 minutes right of state which might not be enough if your proof takes more time to generate for instance right so a different uh uh approach then is using the Bon block rout commitment which basically comes from the you know the pent chain the the Bon chain uh where

you know long story short in this case assuming you know the chain that they're using supports this you have one day always one day if you need more uh there are uh mainly two techniques one is to just refresh your proof right and the second one is to uh deciding which block you want to commit at the beginning before generating the proof then you save that block to whatever you know contract whatever state in the chain and then you can you know take all the time you want you can drink a coffee you can you know go for a run you can do whatever right and then once you are ready you can uh submit the proof and then use the uh that commitment because

you have already saved it previously right right uh so long story short you can turn any computation into a very compact proof we use um R 16 uh to basically publish uh and verify uh the final proof on chain and one cool thing is that uh you can also you know have different proofs and then aggregate them all together with a single grow EX impr Pro so the cost that you pay to verify a proof is not anymore the cost of you know verifying R 16 which is basically ping operation and some you know

elliptic multiplication but it's basically a bunch of cat because it will be just a proof of inclusion against a root that is actually the grossing syro right talking about something interesting um what can you actually achieve with this okay okay imagine that when I say iming there are real application that do this and even more you need in your contract somewhere to run something like I don't know half a million or you know in this case for 100,000 as loads operation that is uh that is something right it kind of uh

consumes roughly 1.2 billion gas which is equival as filling 30 blocks which at the like this morning price which is not even that crazy it will cost you around 34 is, but with still you can achieve the same with under 10 bucks it's you know money is not uh it's kind of relative right might care 10 bucks 35,000 the same right but uh nonetheless uh you get to do that in one single transaction rather than waiting

you know for 30 blocks and try to you know out compete all the all the other you know people that want to write into some transaction the same block so so even practically speaking speaking even if you don't care about money it's it's super convenient right uh and then you you get proof that can be verified the worst case right with the 300K of gas in the best case is just aggregated so it's a bunch of ketchup and this is just one example then I let your imagination do the rest right uh I'll give you this uh useful links uh we have a blog post here about boundless and then we have this so a

recent announcement the when I'm talking about you know uh cool tooling I also say production ready meaning that uh the auditing phase has been already done so what what we are giving you is something that is is reliable right to some extent of course you know buxs are always out there uh and then there is a recent uh uh publish steel docks which super cool there is like a little screenshot here uh but yeah you can copy these these links and have fun with it so that's basically it than [Applause] [Music]