Practical Zero Knowledge Proofs

Pragma India · 7 Dec 2023 · 29:53

Three builders on a practical zero-knowledge panel describe ways to get private or provable computation onchain: Inco, an EVM using fully homomorphic encryption so state changes while data stays encrypted, Stackr, a micro rollup framework where developers write a state machine in ordinary languages, and Kakarot, an EVM written in Cairo that becomes a ZK virtual machine. They discuss trade-offs, including FHE being far slower than plaintext and one speaker doubting that ZK systems justify their cost. Advice for hackathon builders is to use ZK only where it fits and reuse existing libraries.

Speakers

Topics

From Pragma India, hosted by ETHGlobal.

Transcript

[Music] all right so I'm going to start off by saying practical zero knowledge proof is a misleading title because not everything is ZK here so I'll kind of make the first question to Remy um in a couple sentences uh tell me about what inco network is and what's behind powering it so hi everyone I'm ready so I'm the founder of inco Network inco network is a evm with onchain confidentiality and this is leveraging a new cryptography called fully homomorphic encryption I'll maybe uh you actually we'll come back to that in a second um

contct for you what is stacker and uh how is it different from other zik rollups uh hey everyone my name is kotuk uh I'm building stacker uh it's a micro rollup framework and with microw we are taking an approach of going back to the roots and defining what Ro rollups are and should be and uh with that uh it enables like uh people building rollups in general purpose languages and we are offloading the uh the the execution part from the verification part from with that amazing I'm liking the concise short answers we will leaves up a lot more room to actually go dig in and finally tell us about what you're working on So currently working on kakarat kakarat is a basically it's an

evm written in Cairo and because it's written in Cairo CYO is a provable language basically whatever you execute in Kyo you can generate a proof which turns kakar out into a ZK evm the kakara team itself we're not like working in low cryptography aspects so yeah kakar is a layer two uh it's an EV in Cairo that will settle on ethereum and now maybe for the audience that doesn't know what Cairo is can you also just give us that context on yeah so Kyro is a it was is a language developed by the starkware team which basically it generates execution trays that can generate Stark proofs so it's yeah it's a is a a domain specific language that

can generate Stark proofs amazing so you have the ZK snarks and then with Cairo you get to do ZK Starks yes uh coming back to Remy so what is FHA and uh give us a slightly more better intuition around what does homomorphic encryption mean yeah so FH is a different type of cryptography compared to ZKA uh f is lattice based the way to think about FH let me give you an example which is imagine you have a picture you encrypt that picture and send it to me I have your encrypted picture but I can still make modifications on your picture so let's say I can add some values to the RGB values or you know subtract or multiply I can essentially change the

pixels on top of your encrypted data and by the time I send it back to you and you decrypt you have this automatic filter new filter applied to your original picture so EV essentially is a cryptography that allows you to encrypt data but also do all sorts of operations mathematical operations Transformations on top of encrypted data so what we're doing here is we're adding FH into an evm the idea is that today all the EVMS are completely transparent and un public and so for us by enabling confidentiality on chain it means that you can store things directly in encrypted matter directly on chain and so for example if you to build a poker game you can directly store encrypted

hidden cards on chain and if you were to let's say build any defa applications or any applications that require State transition on top of inced data this is where we can use leverage FH to do state transformation so what this essentially means that we can enable composability on top of inced data directly on chain so imagine if everyone here submits the hidden price of Bitcoin we can still compute the average price of Bitcoin in a hidden man using FH without having to decrypt during this entire process and more broadly speaking I think gaming would be also quite interesting because today when we build gate on evm chains everything is public all the game States

player stats uh but for us fundamentally we can enable Noble types of games that have to do with bluffing you can sabotage you can spy on people you can consider resources uh the idea is bringing this kind like more Web Two like experience to web 3 uh if you think about this today when people come to web 3 they will often realize that they can only build use cases that make sense on a transparent database but this is not how web 2 Works what if you want to build a poker G right what if you want to hide some information so this is where I think for us the idea is we want to bring novel experiences and um allowing people to build applications that are a little bit more flexible in terms of what to hide and what to leave public and this is fully cryptography

based so you know there has been other type of solutions uh leveraging either securing Clips or ZK based up chain for us what differentiates us is that this is all fully having fully on chain which makes it very easy to build any applications that require any coordination um yeah no that's amazing um maybe I'll just ask one more clarification there could you also give us an intuition around how does the doing operations on encrypted data differ in fhe versus something when we hear this is ZK based does that mean you have to decrypt it does that mean it's it's never public or it has to be publicized what's a good way of thinking about that yep that's a really good question so everything you do ZK

typically happens up so from the data you're trying to hide to the pro to the Circuit uh ZK fundamentally is a pro compute so all lot the state transformation has to happen offchain over PL Tex what's different about FH is this can happen directly on chain on top of inced data so this is where you know if you to do any coordination use case that require any composability with DK it will become a lot more complex because you need offchain coordination but also offchain basically computation over plane Tex to generate new Z proof FH on the other hand anyone can just submit a hidden transaction directly on chain the share private layer directly happens on chain so you don't need any offchain you know coordinator um and and

yeah it's all cryptography based yeah amazing uh I also don't want this to be like a one by one thing so obviously you all in the same uh ecosystem feel free to add on or disagree or agree whatever you want to do um my kind next question is for you kek what is a micro rollup here and why a micro rollup instead of just going to some Z rollup that already exists right so I think uh in the current space we have like a particular mental model of what a rollup is and how how apps are developed on top of a rollup uh but at at some some point we uh kind of we are forgetting that why do we need a rollup like the rollup is used to uh uh have uh an offchain compute model which which does some stuff and

it's verifiable onchain uh we are building rollups which are like chains uh we are deploying apps on those chains and those are limited by the VM of the chain so how we see rollups is that okay you do U you build a state machine and that's what stacker allows you to do you build your own State machine uh and you build that state machine according to your logic and whatever your business logic is whatever the computation that you want to do just give us a a more specific example of what that would look like okay so right now if you want to do a token transfer right so you you write a smart contract which is an erc20 smart contract that runs on an evm based blockchain or or something else uh but how about you ingrain that token transfer logic within the state state

machine itself so the state machine does nothing but token transfer and does it very efficiently and you take that state machine and you make it provable and that's how you achieve like extreme level of of compression and also extreme level of cost Effectiveness and obviously like the throughput is also a byproduct of it so if I'm understanding this right does that mean I don't need to necessarily write solidity code yes so you can kind of build these rollups in any general purpose languages you like uh rust you like JavaScript you like go you can do whatever with it uh you just Define your state you define how the state is modified and uh the SDK takes care of it so that it it rolls up into blocks all the blocks goes uh to another layer so we have a verification layer in between which is kind of like a

pro Marketplace so it it runs for uh in between all the applications and L1 and proves uh the computation uh through through through different methods and you can tell how you want to compute those proofs and that goes on chain amazing and uh I'll say this in the nicest possible way why did you do it on Ciro that's a lot of work to make evm compatible DSL uh tell us about what the challenges were I don't really this a negative way but like that is very complicated so so why did you decide to spend the time to make a evm compatible DSO yeah I I I think the first thing was that it started as an interesting challenge it didn't start oh like let's let's build a company and and and and like no it was like oh this looks fun we

have a onewe hacker Hacker House and hackaton why not try to do this right um and ended up where we are and and as we went uh what we realized is that the first is that Cairo is a hard language to start with but once you get the grasp of it like there's not much you can do it's it's like very limited similar to how solidity compares to JavaScript like once you get a grasp of it like you know like you have the whole map so like you it's hard to start but once you start like you can get good really well really pretty fast and the second thing is that if you want to build a zkm today like ZK sync scroll polygon zkm all of these

teams they are building in circuits directly that's much harder than writing in Cairo itself so and there's a trade-off right like kakarat is almost like an like a VM on top of another VM so it's an evm on top of Kyo VM so there is an overhead and there might be um some like inefficiencies compared to riding circuits directly but there is a lot of um also positive tradeoffs such as it's much easier to audit uh the kakarat zkm has a code base of 10,000 lines of code you will find a lot more um Cyro Auditors than pure circuit Auditors and the second thing is that we

can move faster for example when the push zero up code was released and our code base was five lines of code it's it's like writing on a lower level language instead of having to deal with pols and all the math stuff and so we really believe that dsls um has a bright future especially like with applications that can be provable in parallel and you can fast iterate um back provable backends and also there's one thing like even this this was from the Cairo team is that they they first started doing circuits for decks uh nft marketplaces um but then they realized

oh every time we do an application we need to do all these cits and we need to like do all these pols um and it and it's really hard so that's the reason why they they thought um they developed CYO is like okay we we rather have more time and less efficiency then have to um spend more time and and and be a little bit more efficient and what they realize in the end is that even though they had this overhead the Cairo version was more efficient than the pure circuit and that's because because when you have a more human readable language you can you can uh design algorithms that are more efficient than when you're just doing circuit so it's like let's say you're

you're writing a program in bits like you like you can be a lot more clever and and efficient if you're writing in Python for example compared to writing in bit so like there's some advantage of their cells and and we believe that on the long run because we we can move fast and we can implement things and iterate things faster that's where our advantage is awesome um so I guess one followup that I have then is if Caro is already a abstraction on not writing a lot of the circuits and and polinomial math um what was kind of the reason that you wanted evm there you want just people to just deploy same contracts there or is there a different

answer or does it enable more things I guess is uh for us having that choice is what allowed me to be here uh Ean ecosystem so we we truly believe in the power of starks we but we also truly believe in the like what is being already being built in the Ean ecosystem like all the technologies that that that are being developed so we wanted to like we saw like a market that wasn't explored and say like why not right yeah no that's great I was going to say um are there any limitations of zvm here on top of Cairo or is it 100% compatible and we can do everything that I would be renov have all the up cods and we have eight of the nine Freon PES and we are just missing one which is the EAS

pairing it's a little bit harder because of the Cairo uh Feud the size of the feud of Cairo but I think that's a matter of time and I would say that the the only like pain point or the biggest challenge would be how to make it efficient not just 10 20 TPS but how can we get to hundreds and thousands of TPS which is the goal of our rollup so I but I think like the starware team is doing a great work there's like every year there's a lot of development on the ZK space so it's just a matter of time amazing uh Remy you also chose to uh to do ZK or sorry evm for FH tell us about why evm is important in the context of encryption yeah so technically we could

build this VM with different languages like salana or even move uh evm is To Us by far the most adopted uh you know solid is by far the most adapted Smart Control language and also by far you know all the etherum tooling ecosystems like manam Mas hard hat remix is also by far the most adapted tool sets uh so for us it was kind of a noban to you know just start with that and uh the idea is also generally when people come to a new ecosystem uh it's always quite a friction point to learn new tooling uh you know also getting new wallets and understanding you know new debuggers and think as as so you know just being able to reuse existing tool sets are pretty

well adopted is uh to us is quite um a a practical way to approaches yeah amazing um you interestingly chose to not necessarily have an opinion on evm compatibility because you want to enable a lot more so so maybe my my question is different which is uh tell us about more real world use cases that you think will not be enabled if people have to worry about learning solidity yeah of course I think uh yeah I have a opinions about zkm but yeah uh so for let's get into it let's get into we got time all right so uh what I feel is that uh what's our mission as a as a web3 uh developer Community uh is our mission to build the best tech possible or is our mission to

get web3 the maximum adoption out there so obviously nothing is right or wrong over here we can definitely build the best tech out there we can have amazing cryptography we can have amazing systems which um which are which are really good and preserves privacy and solves almost all the problems with centralization but at the same time at what cost like if you're Building Systems like zkm or or we have like the Solana system which is very very compute in intensive and very uh difficult to manage uh does that really reach out to masses so that's that's where I kind of like differ uh in that I mean like obviously ZK VMS are a great solution uh but again uh it it's like the the adoption part which is the problem so ZK based systems are very expensive and imately the cost is Bor by

the users so is it really worth it so that's that's my take on it no that's totally fair so so in in this case maybe show us like what a what a hypothetical use case would look like on stacker and who would be responsible for what in that in that example right uh again uh going uh a little bit deep into like the thought processes so there is crypto and then there's web 3 right and most of them um like most of the times it's kind of an overl but crypto is more of a of a application based thing and web3 is more of a thought process that uh the process of decentralization of un ownership of of giving things uh in Control Data getting in control of people so for with stacker like that is

the part where we focused on which is the web three part on bringing uh existing applications which are uh which are centralized have have some limitations and bringing them and opening up the data part of it or the execution part of it so one one example I keep going back on again and again is U is the right sharing app uh platform so right now it's centralized everyone um is on the mercy of the companies on on finalizing the prices the drivers are not getting paid well the people are not finding drivers so how about we decentralize that part of it wherein uh the right sharing part or the the the place when in you request a right and the driver accepts it make that a matching engine that's something which can be put on chain and uh I mean like obviously uh we need to get there to

make it more accessible to other people but that's a very nice use case so there are a lot of web two based applications which can be uh ported into the web3 space so another example could be uh like the ticketing tool so for conerts and all people just stay there in line and nobody knows about it and what's the process and uh if there are even tickets available and Nobody ends up getting tickets and otherwise it's just on Black Market just at bloated up prices so everyone knows that so that's a very good use case for like making things transferable uh transparent and like making things more accessible and also if we think about uh social consensus around it like where the community of fans who are who are very very into that and they're not in for the business or the money part of it they can become the

validators of verifiers of those systems so ultimately it's about like the sequencing part all of those things can be handled by the community the social consensus kcks in and everyone just has an ownership of their ecosystem so those are the kind of use cases which I feel we should think more of and we should think uh building more of yeah no that's uh that's amazing like uh nobody disagrees here I assume like I we have a Counterpoint this this is exactly the where the place where you want to be I I have I have a question um how does it work on stacker so in which language you code and like how the proof is generated yep so right now we have uh three layers so the first layer is p engine obviously the second and third layer is basically what we are building the the topmost

layer is the application you define your own State machine you define your own uh uh steps of how uh how the state is updated when you get an input and then you just like that's one system wherein the user interacts with the application and that's all that's completely web to you can even run it in a centralized environment then what happens is you take that state machine you compile it into a approvable format so right now we are going with pessimistic verification so it's a it's in a sovereign uh landscape but it can actually go into like much more provable like actual cryptographically provable things but we want to stay with the social consensus so what happens is the applications now collects all the transactions uh and the verifier layer knows about how to generate the proof for that system so the application during deployment it

shares its state machine with the verifier it's kind of like running a full note for the application and then whenever a transaction comes in like it batches it up and sends it to the verifier the verifier re-executes it uh in in a in a secured environment and that's kind of like a different uh trust model uh as compared to completely L1 versus completely offchain uh but again once the proof is generated there is a committee of of verifiers they attest on it and then that goes on L1 so that also allows you to build like different kind of uh user experiences so the application Level confirmation is is instant uh then the confirmation between the application and the verifier takes a little bit of time and then between the verifier and uh L1 takes a little bit of more time so you can build more

experiences around it and basically choose which which application wants to wait for what something like that so I guess one thing that I feel like both of you have kind of brought up and and I I believe it's also applicable to you Remy is the fact that there is a a separate layer of I need to compute this heavy operation whether it's just the proof or verific actually no verification proof generation or verification of can I replicate this thing um but it seems like it's growing toward where we need either a centralized Marketplace or just a Marketplace approvers who have a lot of hardware and a lot of compute to just make sure everything is correct and that kind of looks like Bitcoin to me again is that the direction we're going in is that a good place for us to be in or we

just betting on some Advanced cryptography to just kind of simplify that computer in the future like what exactly does like the long conversion look like here cuz it feels like it's not becoming more accessible if if anything it's creating more silos it's supp for everybody so so for us it's uh because we're doing FH ideally we want to use more specialized fpgas that can compute F very efficiently so to give you a sense doing operations on top of Cipher Tex which is the way you encryp data in FH it's 10,000 times slower than PL Tex so for this you need specialized as6 that are optimized for these specific mathematical operations and so the

reality is yes we will start small so today with CPU we can probably do five to 10 TPS and then down line with the specialized fpg this is where we can actually scale to 100 to a th000 TPS and obviously by doing this this also means we have to use specialized Hardwares that are initially going to be costly but as we've seen since you know 2 every five years or so generally Hardware cost would decrease by 90% so in the same way I think you the next few years once we switch to the specialized Hardware you will be the price point that's going to be the highest and over time we would expect this cost to decrease over time and um generally I think long-term decentralization the idea is you could end up with um specific validators a set of validators maybe in the hundreds that

are going to be uh know doing all this work but everyone should be able to at least run a light node or light client to be able to verify but also just you know some transactions very easily down the line I think that's to me is seems to be the Practical approach for most networks outset of Bitcoin and ethereum yeah I would like to add on that I feel like there's I agree like that now there's like it seems there's there a stronger un need a stronger Pro to to generate the proves but now there are like Technologies such as a parallel proving coming so which you can distribute the the job in a decentralized way and besides that what I see coming I think before Z K being efficient enough to be able to prove on your own phone is that let's say even

though you have a one one stronger approver if you can generate a proof now you can have thousands of validators that can run on each one's phone so I think even though we're going to a place where one prover will do all the job but now everyone here in the room probably would be able to become a validator because now you just have to verify the proof and then the the the ecosystem itself would be more the same guarantees exist yeah uh I I agree with that like we are going back to like a compute heavy landscape but I also feel like once it gets more mainstream like U if you think about it 5 years ago the the AI part wasn't like uh what wasn't that popular and we still struggled like training our

models and all of those things but as it gone uh as it went more uh consumer so company started coming up with chips that were specialized uh in in AI computer and like apple did such a great job with building their processor so I feel like once cryptography and all of those things getss more mainstream uh consumer Hardware would also get much much better so I personally see a future wherein we don't need chains anymore everyone is doing just peer-to-peer transaction everyone is running a light client in their mobile phones and they just send transactions over air drop or something whatever I I don't know uh but we'll be able to generate proofs on on the hardware level itself and once we get more uh again like once we get more attention and more uh things into it we'll we'll get better Hardwares so that

might not be as crazy to think about doing ZK proofs on mobile devices maybe 10 years down the line or something I mean that would be a be an incredible World um and our phones are getting incredibly faster as well so there's also that and it's like that twice the amount of speed up every two years or something so um amazing well I guess maybe for my last question um one thing that all three of you have in common other than kind of idea your love and and passion for privacy encryption and making real applications is the fact that all of you have kind of been through e Global and gotten your start from uh a lot of these things here and when I kind of look at who's actually hacking at eth India tomorrow

and this weekend um the most common theme I see is people want to do ZK related things and uh and that means we're going to see a lot more experiments we're going to see a lot more people just trying the craziest thing they can think of and just kind of slap ZK on it and uh and also a lot of these things are going to be done for the first time CU we're still figuring out what the right tooling is or what is it is impossible what's actually computable within the limits of of EVMS or anywhere else so what advice would you give to any of the hackers who are trying to play with ZK related toolkits um whether it's kind of don't do this thing or don't spend time on X or what what did you end up doing when you were building stacker or inco or or kakarat

um how would you make them use their time properly this weekend yeah I can share um like I think I participated in around nine eat globals and I plan to participate more because it's so much fun and and you always get to learn a lot and my Approach have always been whenever I I go I come to e Global hackaton I try to set a goal that right now I don't believe I can achieve and what I do is I try to Leverage The the amazing Community there is so basically I go with with a project that oh I don't know how I can do it but I'm sure there's so many mentors so many sponsors there that can can help me achieve that and what I

usually do is that okay let's say I want to learn about ZK I go who are the ZK sponsors I sit right next to their table and keep asking questions nonstop I remember that one of them even like they they went to another room after sometime but like but in the end we became good friends so like Leverage the community like I think this is one of the most powerful um like dance like Comm like you can peck on so many smart people's brain who have been in the ecosystem for so long and they are there with you like many times a lot of the sponsors they were already like going to all nighter together hacking together so yeah I would say like choose the topic that you don't think you can achieve pick the

brains of the community and yeah yeah uh I think I have two points to say so one of them to to kik's point was uh don't just slap ZK on something uh just because you could uh use the right tools uh there are so many things which can be solved in a more efficient way without using ZK so just just keep in mind that that should be the case that you're not doing it for just for the sake of it so uh that's one and the second thing is if you are really uh if you really think that uh ZK is something which you can go forward with and and have have it in your application there are tons of projects which are doing it uh they have libraries and something so don't start from scratch try to research and find out some tools there are there

might be some Niche tools which which you just need to dig into to uh so you might spend more time Reinventing the library so just just spend a little bit less time on that and try to find more things and U just just use that and you make sure that your project whichever like the hero element of your project is that's the focus and not the underlying Library behind it Sam yeah for me similar to Deno I probably done more than nine hackathons uh for me I really love hackathons because it's where all the smart people are concentrated and I've been in space since 2017 I'll say like this space is unique because every six months or so there's always something new that primitive Noel Concepts like proof of stake or even like comstruction that kind of reshapes landscape a little bit so being part of hackathons if you talk

to sponsors to each other we can quickly find out you know what are some Noble things that you can do or build that that's new and can push the space forward so um yeah and then if you want to play around with FH so for us it's directly integrated to the evm uh it's abstracted away uh we actually built a fully Mafia game a few months ago it's Global NYC and this is a f on chain information game so this is a novel type of experience so if you want to play around feel free to try out inco for the haathon as well and uh yeah we'll also be there so building building something fun amazing well thank you all three of you for this amazing conversation and uh we'll see you all this weekend thank [Music] [Applause] you