What can you do with ZKPs with Barry Whitehat
ETH Seoul 2022 · August 2022 · 24:44
Barry Whitehat of the Privacy and Scaling Explorations team at the Ethereum Foundation shows what builders can do with zero-knowledge proofs, treating hash functions, Merkle trees and proofs as black boxes. The talk explains how Zcash uses a Merkle membership proof and a nullifier to prevent double spends, then how Semaphore generalizes the idea for anonymous signalling, private voting and anonymous social media. It closes with hackathon ideas and urges projects that appeal beyond DeFi and NFTs.
Speakers
Topics
From ETH Seoul 2022, hosted by Kryptoplanet.
Transcript
thank you everybody for coming uh today i'm going to talk about what some things that we can do with ckps and like some of the background for why i think that this is important is that like at the moment there's a lot of applications on ethereum but those applications appeal to like a relatively small set of the of the like global population a lot of people are not really interested in nfts and defi and like i think with good reason i mean it it's compelling for a bunch of people but for a bunch of other people it's not and like i see these arguments happening sometimes and i think that like instead of trying to argue with people about like why crypto is is better we should try and find use cases that are compelling to them so today i'm going to talk about like some
of those potential use cases and show you some examples of some things that are that are kind of out there and we can we can use right now cool so before i do that i'm going to need to talk about a couple of different primitives and like like my idea here is that i want to keep this talk high level so i want to apologize to the crypto cryptography experts who are here today we're not going to get into like deep cryptography instead we're going to blackbox out these components and try to try to use them to build interesting things so yeah um yeah so we're going to box them out and like like when i started building things with ethereum i didn't learn how easy
the essay signature scheme worked i didn't learn about marco patricia tree i sort of black boxed those things out and i said oh here's a cryptocurrency i know uh signature only i can make a signature and other people can verify it i know that data that i store in a smart contract is going to be available and that's all that i needed to know i knew what it did but i didn't know like all the inputs and i didn't know exactly how it did it and this was a very like good way for me to be able to learn and build things without having to spend like a year just studying and learning about all these different things that said like it seems like there's two paths here like one path is to like go really really deep and learn like lots of crypto and the
other path is to sort of black box things out and and and make things with them with crypto and like both are definitely valid paths but i'm going to focus on the path of like black boxing things out and trying to to build things and use things because i think that that's like a fun way to get started especially if you're if you're like more of a beginner in the cryptography side okay so yeah the first thing i need to talk about is a hash function so basically what a hash function is it takes this like ordered data here on the left hand side it it performs some algorithm and it it mixes up the data so much that on the other side you're not able to find out what the original data was so like it has like three guarantees the first guarantee is that you can't
find like two sets of data that leads to different data on the other side or that leads to the same information on the other side so this is called collision resistance uh the second is that like you can't go backwards uh that means that like with the data on the outside on the on the on the right hand side you're not able to go back to the left hand side and the third thing is uh what was the third thing yes the third thing is that the data on the right hand side is smaller than the than the data on the on the left-hand side okay so so this is what a hash function is and i'm going to talk about hash function today but like the best way to think about it it's just like a blender it's like you put the data into the
blender you run the blender it gets all messed up and mixed up so that you're never able to go back to the original data that was put inside and it also takes up less space because you blend it up it all it gets smaller okay so the next thing that we need to talk about is a merkle tree and a merkle tree is a way of using these hash functions to sort of create a commitment to a large amount of data in in our in our use cases we're going to have this big set of users and we're going to want to compress that set into like the smallest possible representation so to do this we use what's called a merkle tree and the advantage of using a merkle tree rather than just putting
everything into our blender and running our blender is that it's easy to go back it's easy to it's not easy to go back but it's easy to to show oh this piece of data was in the original set uh it's easy okay so so here's a merkle tree and here's how it works so at the bottom layer we have our data and then our beta our data is 512 bits for example let's take that and and then the first thing we do is we hash our 512 bits so that we get an output that's 256 bits and that's our first layer and then we take our 512 bits from the second layer because we have two 56 bits on the first on the left hand side and 256 bits on the right hand side and we hash that together again and we get another 256 bits then we take 256 bits
and 256 bits hash it together and we get our final what we call our merkle root and this is called a merkle tree and and the top node is called the merkle root which is which is like a a succinct representation of all the data that we have on the bottom layer and the advantage of this is that like a user who knows the the the value of like the bottom layer is able to provide a proof not a zero knowledge proof but like a uh just regular proof that that that they know that data so we're going to use that a little bit later the third thing that we need to introduce is a zero knowledge proof so a zero knowledge proof is basically a way for someone to make a proof about
public and private information that normally when i want to prove something to someone i show them all of the data and they say oh they run some algorithm and verify that it's correct and then we're done but like this is limited because i need to show them all the data so zero knowledge proofs allow us to hide some of the data and that's the advantage here so you can see this example i have here so this is basically a zero knowledge proof that proves that i know the product of a and b oh no sorry this is a zero knowledge proofs that proves that i know an a a public a that multiplied by a private b equals c okay so we have our public input a our private input b our check which is a
multiplied by b equals c and our output is c so this is what the prover sees now an important thing to remember about ckps is that the prover knows all of the data everything that goes in they know it and this is like one limitation that we need to consider anyway this is what our prover sees let's look at what the verifier sees so the zero knowledge proof kind of blacks out some of the inputs to the circuit so let's notice a couple of things first of all they know the public input and output this is important because we we need to be able to reveal some information to them and this is how we do it by having public inputs and outputs the second thing to notice is that they know the algorithm that's
being checked that they're aware of what's happening what checks we're performing and this is also important because if they didn't know what checks we were performing we wouldn't be able to if they didn't know what checks we were performing we wouldn't be able to they wouldn't be able to trust that the actual proof that we're giving them okay so this is what a zero knowledge proof is we abstracted away all the complexity of the math and this is a tool that we have so let's use that tool to to see how some things that exist in the world work so the first thing is the cache so zcash is a cryptocurrency that uses zero knowledge proofs to allow users to send private transactions and the way that it works is
that let's let's look at this at the zkp that they use so this is like our original example this is what the prover sees this is what the verifier sees let's talk about what the prover sees so this prover sees everything the prover says that for some merkle root this green block in the input i know a merkle proof a public key a private key and a nullifier such that the public key and a merkle proof results in the merkle root this marker proof is not a zkp it's just a certain set of hashes that they perform
so first of all we check that the membership is correct and then we need to check that the public key that they own this leaf so this is basically we convert their private key to a public key and the final thing that we do is we reveal a nullifier and the nullifier and the nullifier is important because it prevents double spends so let's look at what the verifier sees so the verifier sees the merkle root it sees that the checks that are performed and it sees a nullifier so the merkle root is basically the list of all of the users who are able to send a transaction the checks are the membership check they see that but they don't see any details
about the membership check because if they did they would be able to see oh which user was they'd be able to see their public key to be able to see their market route and the marker proof to be able to identify exactly which user it is so we have to hide this information the second thing we need to hide is a private key because if they saw the private key and the nullifier they would be able to like sp make a proof for that same leaf and number one we would lose privacy because they would be able to calculate the public key and they would be able to find the public key in the merkle tree the second thing that would that that would happen is that they would be able to steal this money they would be able to make a transaction to spend it
somewhere else so we have to hide both of those things and then we reveal the nullifier and the nullifier is super important because it prevents double spends so let's talk a little bit about the verifier algorithm so the verifier algorithm when the verifier gets this proof first of all it checks that the zkp is correct then it checks that the merkle root is is a correct merkle root that it's a correct list of users that are able to send transactions once you check it confirms that check the second thing that it does is it checks the nullifier has not already been used because we have a one nullifier per user limitation here that's that's enforced by this hash once you spend a nullifier you're not able to spend another coin and the verifier enforces this by storing a list
of all the nullifiers and if it sees the same nullifier twice it will it will it will reject that proof if there's a second proof with the same nullifier it'll say no this is not valid reject okay okay so so nullifiers here are important to prevent double spends cool so let's talk about like some generalizations of this idea so the first thing is is is is samafor and 704 kind of generalizes this protocol because in the previous example you could only make one zkp as soon as you made one zkp your nullifier was revealed and you couldn't make another valid ckp if you did the nullifier would be the same so semaphore generalizes this and it
allows us to re-reuse public keys so this primitive allows us to make uh a bunch of interesting things we can do like private voting we can do anonymous social media we can do a whole bunch of like interesting stuff with this which i'll talk about a little bit more soon so the next example i want to talk about is is like another generalization and improvement on the idea of the maybe it's not an improvement it's more like a specialization and this is called rate limit nullifier so this is a special kind of nullifier that we use to limit the rate the messages can be sent so 74 lets you prove that you're part of a group and rln enforces a rate limit on that group so
like the idea is that we have an epoch during the an epoch can be like one hour one minute one second during this epoch you're able to send one message if you send more than one message your public key gets revealed and you get slashed so how can we do this the way that we do this is is we use shamir secret shares and basically the idea of shamir secret shares is that we have a private key it is that we have a private key and we encode that as one point on our line then every time we make a proof we remain we reveal one point on this line and the idea here is if you have two proofs on the line you're able to if you have two points on the line you're able to
interpolate the rest of line you're able to find the whole line once you find the whole line you're easily able to find the the private key okay so let's use this in our tkp so here's another zkp this is our this is our approver's view our prover sees everything so it's very similar to the to the z cash ckp that we talked about a minute ago we have our merkle root we have a marker proof our leave on our private key we prove that the the the leaf is in the private key and then we reveal a schmeer secret share of the private key and the way that we do this is just a multiplied by the message plus the private key equals the output okay so here's what the verifier sees so the
verifier will see the market route the membership it won't see the details about about like which leaf it is but it will see the message that was signed and it'll also get the share will also be revealed and so the share is is is kind of stored every time the the the peer-to-peer every time the verifier receives uh rln proof they will basically say every time they receive a proof they'll basically get the share and then they'll check to try and recover the private key of that of that leaf with all the other shares that they've received and if they are if they can't do that they'll they'll generate the user's private key and they'll reject the proof they'll also share that private key with everybody all the other all the other
verifiers in the system and they'll say this user sent me an invalid proof or this this user sent me more than the allowed number of messages they're no longer allowed to send messages and all the other verifiers will accept this and continue with their continue with their day okay so let's talk about some some applications of this so this is skitter skitter is a is a social media experiment built by this anonymous person called sukino and basically the idea is that it uses semaphore to make proof that you're part of a group and every time you make a post on this social media group a social media application it's you your polls are not connected to your
identity your polls are connected to like i said a one one of a bunch of groups uh yeah so they they have this really fun social media experience it's very fun to think about like what are the implications of this and like how will how will this be used in like social media in general so let's have a look at some stuff so here's a post uh this is a post on on skitter there is so this is from there's there's a couple of groups on on on skitter right now they're mostly uh about twitter followers uh we have like a centralized bridge to export this credential and the idea is that it's like a way for us to
experiment it's a nice way for us to build these like groups but like some of the negatives are that like it's it's centralized and like the reputations are really very meaningful um but it's it's it's nice to use an experiment and it can lead to some fun kind of interactions so yeah so this is this is a pulse from someone with 500 with more than 500 twitter followers who is talking about oh they really like the new feature on the site the dark mode and this is and this is another member of that group who's who's saying that oh the the feature is the feature is a little bit a little bit tricky to use sometimes uh so like what do we know here well we know that like this came from like to
twitter more than twitter five more people with more than 500 twitter followers okay so let's talk about the anonymity side so the anonymity set is a set of people who could have made a proof so when we talk about ckps we we always need to be careful about the anonymity set we want to maximize the anonymity set but we also want to main to maintain some signal we want users to be able to if we have like a completely anonymous thing where where posts are not connected to anyone in any way it can be like a very low quality experience for people that like it's just possible for people to send thousands and millions of messages and it's hard for it's hard to
like use that to yeah it's hard to use that as a way i i that that can lead to some difficult social media experiences so let's talk about the anonymity set so we have like three groups uh the the gold group which is i think more than 2 000 twitter followers the silver group which is like between 500 and 2 000 and the bronze group which is more than 500. so these are different groups but at the moment they're very small there's like five three and six uh so the anonymity set is is currently starting to grow but it's still it's still so small that it's like not it's it's more like growing then it's ready for people to to use and be confident about their privacy when
they're making posts so it would also be nice to add some decentralized groups here like poep or or or bright id like the more groups that we add can lead to more interesting discussions and like we can also have like custom groups and interesting things like that that might also be fun cool uh there's also user accounts so you can make a post here as like a user and and there's no ckp involved so you're able to have conversations with like these anonymous groups and you're able to like discuss with them and and and kind of see what they're yeah you're able to talk with them and have discussions and interactions uh another feature that has is instant messages so we use rln to make
to make ckp we use oral n to limit the number of messages any user can send and this allows us to have like private direct messages so you're able to chat users are able to chat to users groups are able to chat to users and groups to groups is coming soon is not here yet uh so this is a conversation i had with a 7000 with a member of the 7000 twitter followers group uh but they haven't got back to me yet so i i don't have any advice to share about getting more more followers on twitter so hopefully soon uh yeah so you can you can dm me on skitter if you like i'm i'm there we can we can start to have some chats yeah
uh um we have yeah there's a couple of other like interesting social media applications that i want to mention here as well there's hey anon from xerox park which i'll talk about a little bit more in a second uh there's people working on interesting groups like seismo and hello they also have some groups and like one thing that we need to have is like a browser plugin so that we're able to use the same public keys private keys with different applications like just like metamask you don't want to make signatures on uniswap and sushi swab and share your private key with the actual application because if they steal your private key they can just go take all your money or take all your reputation and just go and do whatever
they want with it so that's not good so we need to be able to hide the private keys of the users and that's why a browser plugin is really important cool okay so there's one more application i wanted to mention as for the for the hackathon purposes uh because it seems like there's some fun things that we can do here uh yeah so this is here's a link and basically what this is is it's a starter project that allows you to verify ecdsa signatures inside the ckp and why is this interesting well you noticed earlier that our anonymity set was very small for the twitter bridges and this is because we have to have a public way for people to sign up
and like when we have a public way for people to sign up uh you're able to see who signed up and who didn't you don't know who performs what messages but you do know the set of people who are inside the group who could have done it so if we use ecd as a signature verification inside as ekp it becomes easier because then the anonymity set can be everyone who is in the participating site so let me give you an example to try and make this a little bit more clear so let's say that we want to make a group of every ethereum user ever what we do is we need to go to ethereum we download the the list of accounts in the in the in the state and we basically say that this is every valid ethereum user ever and what we do is we put them
into a merkle tree and then we create our circuit and our circuit is basically checking that the ecdsa signature is correct and and and that they're they're part of the merkle tree so this can lead to a whole bunch of interesting applications and one of them is hey and on which i mentioned a minute ago so hey and on is this like uh it's a series of twitter bots that will kind of copy and paste the the zkp's that they receive and this is this is interesting but one of the limitations is there's no nullifier and when you have no nullifier you're you're not able to have when you have no nullifier you're not able to you're not able to [Music] we could have a lot of problems with sock puppets with people with the same account just pretending to be from different different accounts and
this could lead to some problems um but we're working on ways to to make the to make the ecds8 nullifier generation better and yeah we're working on ways to generate another farm from ecdsa and we're hoping that we'll be able to we'll be able to use that feature soon because yeah like i'm really excited to have a whole bunch of different groups of like different different kind of sub sections of the ethereum community able to like discuss and talk from that group i think that would be really nice we're able to do that already but it involves us kind of like verifying on chain the signature and that limits the anonymity set the benefit here is the anonymity that's bigger and as soon as we have nullifiers it's going to be really really nice okay another thing that we can do with
this is we can use the ecdsa signature verification to compress the amount of signatures that is that that that you need to put on chain for optimistic roll-ups like you you all may have heard of the bls wallet project which is a project to compress bls signatures into into the smallest possible call data footprint and like the reasoning for this is that call data is the only thing that matters anymore execution is basically free so we want to minimize the call data as much as possible so bls wallet tries to do that but we could also do that for ecdsa with a zero knowledge proof so this is a nice this is a nice kind of scaling project that you you could also work in okay uh here's a couple of cool ideas do something cool with semaphore uh reach out to the mentors jake is here in the
blue t-shirt and one sub is here also on the blue t-shirt at the back okay so you can reach out to them they'll be happy to help once the bose also wrote this this library so he's pretty knowledgeable about the sdsa signature verification uh yeah so other things will be fun it would be nice to add more groups to skitter at the moment it's just like three twitter follower groups and one like global user group so it'd be nice to add more users there or more groups there just so different people are able to to talk and and like interact it would be nice to make a version of hanon that's that's like a message board or more like a message board and it would also be nice to have like direct messages there too just so you can have some private conversations as well you
can have a private conversation with someone who's part of that group without knowing like which person it is and that that might also be fun uh and you or another one is just go with your imagination make another application that yours uses your knowledge proofs i think there's a whole bunch of of interesting things that we can do and i also think that it's super important that we do it because we need to make applications that that like are interesting for like a broader set of the global community i think at the moment where our our kind of focus is very narrow and we need to broaden that focus in order to show people like why what we're doing is interesting and that's really up to us i think if people don't get it i it's hard for me to blame them i i always think that okay well let me try
and show them something different something that is maybe more compelling to them so that's my talk thank you very much if you're interested in joining to to work with us you can check out our website here or or or join our discord and yeah thank you so much any questions
