RISC Zero zkCoprocessor: Cheap and Easy Off-Chain zk Proof Generation With Onchain Verification
Ethereum Denver·Wed, Oct 9, 2024, 12:00 AM
Offload expensive computations from smart contract to zk coprocessor, off-chain zk-proving service that allows verifiable computation. zkcoprocessor computes code off-chain, generates zkproof (SNARK), and sends it back to the smart contract for on-chain verification. APPLICATIONS FOR ETHDenver 2024: #YearOfTheSpork ARE OPEN APPLY NOW https://ethdenver.com/apply
Transcript
[Music] okay hello everyone welcome to risk zero workshop and today we're going to learn about general purpose Z KVM then about Bonsai ZK proven service and then we'll finish Lo with a ZK co-processor this is our proven service that allow easy offchain ZK proof generation with onchain verification so let's get started so what we'll cover today we'll go over first with zvm architecture then terminology terminology then we go about features what make risk Zero stand out across other other ZK uh products we quickly go over example to show you how easy it is to get started and run and generate ZK proofs on risk zero and then we go over ZK cor processor we'll see how seamlessly you can integrate bonai within your ethereum application so ZK processor um is very important because Z KVM and boai together connect as a co-processor to the smart contract application so and this unlocks quite a lot of powerful new applications on ethereum so you can upload comp potentially intensive uh functions to Z KVM and then get back very small ZK proof that you can verify on chain so risk zero was started in 2021 and is focused on revolutionizing the Internet by creating the infrastructure and tooling necessary for web three developers around the globe to build zero knowledge software we are bringing general purpose Computing to the zero knowledge ecosystem enabling users to trust programs run anywhere while allowing developers to use their tools they already know and love so we made a socket that usually developers have to construct to generate ZK proofs and actual VM circuit doesn't change from program to program it stays the same but you have two inputs that you have to send to your soet it's program that you want to generate the Z proof on and input data and then a socket will take these two inputs and generate Z proof for you circuits is within a ZK VM so it's part of of VM let's look let's look at um Z KVM very very high level overview and let's start with a normal VMS virtual machines that we all know how the architecture of them is very similar you run VM on some type of host and you send a program that you want to run on Z KVM and the input data that you want to run this program on and virtual machine takes these two inputs generates it and provides you some with some output output of your program with the zkm we have uh very similar architecture your on KVM on a host and then it takes two inputs a program that you want to generate a zero knowledge proof of and input data for this program and Z KVM run this run this um generates the uh run this program generates output of this program and on top of it it also generates a proof that corresponds to this program and to this input data and all of this data is part of the receipt and we'll go we'll Lear just in a minute what the receipt is but this is a definition of verifiable computation where you just show someone a proof and this proof verifies that you run some program with uh some private data and that's it so risk five Implement imp uh risk zero Z KVM implements risk five standard open source microarchitecture and why we implemented a so uh that implements risk 5 um microarchitecture uh micro processor so advantages of that that instead of making our own domain specific language that's difficult to Lear usually difficult to Lear for the users or write in our own compiler our users uh can write can write their programs that they want to generate a proof of on any languages that llvm or GTC compiler support uh first we start focus on Rust to make sure that we provide the best diomatic developer experience for our users and then we extend to other languages and there is also zik snarks so this part is a bit Advanced so if you're new to zkv to zero knowledge it's okay if you don't understand so we use Stark proof to generate uh to generate proofs in parallel so our risk five circuit generates uh Stark ZK proofs and then we use recursive circuits to recursively aggregate many uh Stark proofs together into one Stark and then we use growth 16 circuit to convert Stark proof into snark what it does it provides you with very tiny proof snark proof that you can verif Pion chain so risk zero ZK proof is growth 16 snark which is quite exciting so let's go a little bit deeper inside the KVM architecture but still have like high level architecture so rust compiler takes rust code and generates object for llvm llvm generates bite code and it also generates this risk five binary and this risk five binary is the input for Z KVM executor takes this binary and generates execution tra or session and then Prov takes this execution traes checks it validity and then generates a proof which is inside the receipt that will go in a minute so right now you can have 256 megabyte of data inside the KVM so why it's important and what can you do so developers can uh can run Ras code inside the KVM and prove execution was done correctly and the second the uh the KVM makes verifiable computation easier to get started with so uh let's go quickly about terminology terminology of the KVM is very similar to almost identical to Virtual Machine terminology so you have a guest which is a program that you want to generate a proof of at this uh program that you send as the input to the KVM then you run the KVM on the host and the host is in charge of the KVM and um portion of the KVM that actually generates the proofs the socket we call it pro so we have gas program that you want to generate proof on you have host where you run your ZK uh Z KVM on and pro is a part of the zkm that actually generates uh grow 16 snacks so receipt that object that you get from the KVM it provides you with a valid execution of a guest program and it also contains two object inside it contains Journal public output of a guest and a Seal Seal is basically growth 16 snark basically Z case uh proof of correct execution of the guest program that you wanted to uh that you pass to the KVM so now let's look again at the KVM architecture so now you can see that we pass R code that we pass to the KVM is a guest code and uh then the KVM runs inside the host and this is the proven this is that part that generates our uh ZK C uh ZK snarks and receipt receipt is the object that you get that contains uh ZK proof and public output from your guest program so now we go to excit W in part continuations and this is what differentiates risk Zero from other ZK Solutions available on the market we have continuations so continuations enables you to generate proofs on Parallel clusters on another Solutions you can generate on one CPU with the risk zero Z KVM you can you can run your proofs on Parallel clusters this is very exciting so before continuations came around there was a limit how large your program was so that you sent to Z KVM how large was your guest program and it was around 16 million cycles and after the uh continuations the largest proof uh program that we sent was 10 billion cycles but theoretically run two trillions so so it's very large and it's very exciting so this is means that risk zero Z KVM allows you to generate ZK proofs of very very large programs and also it runs very fast so another part proof composition proof composition make it possible to verify proofs inside the proofs so using proof composition you can create a proof that attests anything uh to anything that has previously been proven so here you see that you have output you run the the KVM the generator seat and this uh Pro um ZK um snark growth 16 snar can be program inputs for next KVM so it allows you to generate proves of approves which is again super exciting so let's go through a very basic example to show you how easy it is to get started with the KVM so I want to go uh through example that I want to prove you that the number that uh a number is a composite number so composite number is opposite of prime number so I basically means that composite number have at least Le one devisor that is not one and it's not itself so from a user perspective on the left side you have the guest code that actually checks that numbers that we pass are not one otherwise it's prime number it multiplies these two numbers and it sends product to back to the KVM and this is host on the right so host host just like run run the run the Z KVM and it's also responsible for sending data to the guests so let's look a bit closely what we need to know first we need to make sure that we import uh functionality that interacts with the host environment over here then we read the data that was sent to from the host then we do our multipli then we do our very very intensive computations and then we commit the public output to the journal so this public uh this output is a product that we want to uh our composite number and this is part of the journal so on the host side host host is responsible for getting the data so we just pi two number numbers then host is responsible for preparing this data and sending it to the guest program before we actually start executing the guest program so it it it it put this data into guest environment then it takes the Prov and it takes the Prov to validate uh B pro guest binary and it also provides the input data Pro a generate receipt and here you can see how you can use a uh how you can extract output from the journal and this is how you can verify your receipt this this is you can send this receipt to third party and third party can verify it easily so this is QR code for quick start guide I highly recommend you to scan it to get started so if I don't want to run in Z KVM locally there is a remote option and this is bonai bonai enables the boundless computation with Bonsai instead of generating proof of your own Hardware you request Bonsai to generate it for you so Bonsai is highly parallelized highly performant and horizontally scalable uh solution and is based on ZK Pro Z KVM proof engine and this is a very very high level overview of bonsai where you can have a guest which is part of your TR um trustless software or part of uh smart contract you request bonai to generate approv it send you back a receipt and receipt contains ZK proof and the journal so this is the most exciting part ZK uh corpor Tess so we want to make sure that zero knowledge proof integration into ethereum is possible with minim minimal developer effort so this is high level overview of risk zero application on ethereum using Bonsai so first the offchain component of your app whether it's uh whether it's D client or server sends a proof request to Bonsai and then bonai generates a receipt and the app publishes the receipt on chain to your app Smart contract and uh um and your uh smart contract call the risk zero verify a contract to prove uh to prove the validity of this receipt if it's successful the journal is trustworthy so let's look closer around this risk zero verifier the verifier contract has IR risk zero verify interface which provides with two objects provides with a receipt data structure and verify method so IR risk zero verifier Implement uh is implemented by risk zero growth verif verier contract and this contract is stateless and immutable verifier so please scan this um QR code for the docks for the ZK core processor and if you want to learn like more about risk zero growth verifier this contract is deployed on Folia and you can find address at this link and you can choose this contract or you can deploy your own so last lastly this is a link for risk zero information about hackathon bounties links to documentation documentation to Z KVM Bonsai ZK coprocessor links to Discord telegram channels where to find US during the actual event all this information is here on on this on on this link thank you very much and I'm looking forward to see you all thanks
Automatic transcript — names and jargon may be misspelled.