ZK Keeper by Andrija Novakovic- 03 02 2022

Learn & Share with PSE · 2 Mar 2022 · 43:29

A research presentation on ZK Keeper. The session explains the construction, its security or performance properties, and where it fits within modern privacy and proof-system research.

Speakers

Topics

From Learn & Share with PSE, hosted by Privacy Stewards of Ethereum.

Transcript

meeting room now so there's 12 of us let's get started I think it's a good good time to get started uh yes yes I I also think that so um yeah before I even start uh talking like about why we need this uh ZK keeper extension and everything I just want to say like uh it's not just me uh uh tukino was really helpful uh and now I'm a bit out of it and like Omar block away and not sure doing great job uh on like fixing stuff adding new features and uh if they want to also talk about something later uh I uh they're welcome

uh so yes um oh one thing okay I'll share my screen um and so I think like uh to understand why we need this it's really nice to have um like a potential security issue on turn on the cash uh so uh just tell me if everyone is seeing the screen or like if someone is not synced to screen uh so what's happening here I don't know if you're if everyone here is like familiar with uh tornado cash but the idea is to have a uh that Anonymous uh untraceable uh

deposits and withdrawals so I'm not gonna talk about that today I just want to show where potential issue can be and that's happening like in the exact moment when you want to deposit something so uh okay uh you have the option to store this note uh on your computer like securely and everything like that I'm not gonna show that so uh the potential problem can be here uh I started depositing this note and uh this note uh secret uh you can refer to it as a private key for this particular protocol uh uh there is like potential issue

because it's displayed here in browser and if I like try to inspect this element and see what's going on there uh we can see that that nodes exists exactly here in this HTML so uh if you somehow have any malicious software on your computer like some Library some malicious extension whatever uh you can be a really good Target for this so uh in order to explain you what's going to happen uh so every extension that is running uh has something like uh

okay let me just go like Google it should be enough so uh if we look at what's going on here every uh extension that you have like here you can see ZK keeper you can see matamask and stuff like that has something called injected script and uh so every extension will inject some JavaScript code in your browser on every page okay so the problem with that is that if we look here you have that injected script here and if you have any malicious software on your computer what can happen is that someone will write the malicious code in this injected

script which will listen to event well like when you press deposit button or and they will just like take this secret from you so even if you store it securely do whatever you want in at the moment where you click and create this note this private node uh somebody can steal it so uh this injected script can be really simple it will just parse this HTML take this uh private input and send it to some remote server so uh the hacker will be able to deposit to withdraw your money so uh was this enough clear what's the potential

issue here and like what are we trying to solve uh okay like if no questions I'm just gonna continue so uh now when we have this uh the idea was uh to have like secure extension and uh what can extension give us so I'm not gonna die if a lot into how extension is working but there is like two main parts of the extension there is something called background process and you have this injected script which is like middleware between what's running in the browser and it's it's helps that the browser code is communicating with that

background process so uh again not gonna go dive uh deep there but like that background process has another context of this browser process so it has its own memory its own references everything uh like is decoupled from browser so the only way to communicate with uh that background process is by sending messages between this like uh front-end pages in browser and that background page and that's why we use this injected script so they're like bridge and only thing that had happened is like just to exchange

messages with your background process so from this point where I stand I cannot reference uh memory of the background process I cannot take any state of it I can just listen to some message of background process and it's really important because if we can hide some stuff in the background process then we should be much more secure than doing anything here like on the front end of the browser to say like that so uh the ZK keeper I was trying to build it as like really similar to what's metamask is doing it's just uh simpler because we don't have that many features

for now and I'm gonna give you like a fast walk through how it works and what it gave us so there is like the first and Main uh the main goal of it is to to be more secure and also it should enable people to integrate easier with other protocols so uh imagine like for every depth you must create you you if you need to like write some code to uh handle signing transactions and all the blockchain stuff which metamasks or other wallets really uh abstract for you in a nice way so uh the main part here is to like remember that we have this

background process and this front-end side and we can just exchange messages between those two and nothing can like reference its memory so uh what we should do is to instantiate our private keys or like private data Fitness data however you want to call it in the background process and we should expose it as less as as like if if we can expose it just is like as short as possible so that's the way to be the most secure like as secure as possible so what's going to happen here uh let me just give you an overview of how how code works so if you look at the

uh the basic uh structure of code you have this UI part which is the like actual UI of the extension you have the background which is like the most interesting part for me and on which I worked the most and you have this content scripts which are as we said something that is injected in your page and serves as a bridge between a front end of browser and background process so here I'm not gonna go uh a lot in the details it can a lot of stuff is happening here but I want to show you like uh how like just so you can feel that in this background process

uh we have uh like uh like creating uh we are creating proof and if you can see here we have this witness so uh Fitness is what's actually private for us and if you see here we have some identity parts that we don't want to show and that if somebody takes uh this identity parts for you it's exactly the same thing as someone taking the private key or your of your note for the through another cache so we want to hide it and so this Fitness never goes out of this extension so if you look here it lives in this background

and it will never get out so uh all the private data is held on the background in the background process right there and never gets up so here we have a lot of now uh stuff regarding like identities uh we have like uh let me mix of metamask like how we handle the multiplier requests and stuff like that um I think it's not the main part of this presentation but uh some some things that uh are like the most important is that we can handle a lot of protocols one of my ideas also and it should be really easy to integrate to

another cache with this uh just as another protocol here and we have like really nice way of communication between front ends and uh and this background process so uh the protocol itself is really abstract and you can integrate uh as much as you like and uh and like if you if you have your own protocol you can just take this code base and add your protocol with uh like with just core functionality and everything should work so uh you can also like connect to metamask uh also I'm not gonna go into that part because I think it's not a part of the

presentation but you can create your identities you can connect to our interrupt on which from our works which I think is also out of scope of this presentation uh but yeah we have a lot of features right now and I think more of them coming so uh another interesting part here is that uh I was also thinking like this was the I was really new to this so I was trying to figure out a lot of stuff how to do and uh one of the concerns was like What if uh okay uh when you have this background process and you must store some data so when you store the data they must be stored on your computer on your hard disk and you

must store all the secrets identities everything must be stored so uh what if someone steals your computer like uh okay you if the data is on your disk and someone has your computer he will be able to like take all your private Keys private data and everything and uh what is done like all the data on disk is um stored in encrypt it's encrypted and uh the password is also not stored so the only uh the only way to decrypt the data is to know the password you set the first time you create the extension okay you can

change it later but like you have the one password you set and that's the only way how you can decrypt the data from disk have it's for some time in this background process and when you log out or shut down they will uh be like like encrypted again and uh delete it from like uh Ram so uh you're completely secure on that way and also we have the features similar to mask like this approval service where uh it's not enough to connect everything for every proof you want to create you must approve it uh and uh it should like really mimic the security of metamask and what's going on

there so uh there is a few stuff that you need to run which I'm not gonna go through now if someone wants to experiment can ping us in a CK kit chat uh whenever so what I wanted to show is how how easy it is to set up a demo and let's say like we for now have the Ireland and semaphore but later we want like anybody can like Ping us and we can integrate their own protocol into this so uh I just want to show you like this demo uh so if you want to have like SEMA for application for some Anonymous voting or whatever or uh we will be releasing the chat uh on

top of Ireland really soon and what you can do is uh you can just download the extension um see which protocol you want to use and you need just to build the front end for it so you really don't need to bother with any security with any storage caching needle cryptography all the functions are hidden and they're inside the CK keeper it will do it for you so everything you need to do is just to build the front end of the of your dub as you like and to use just like one simple button like

just one simple function to send all the private the public data to the CK keeper API pods so here like uh uh you can like call generate proof from uh I'm not gonna go in uh difference of this proof but you can see that semaphore proof was generated successfully so if I show you this page and how it looks and what's going on there uh it's really simple HTML so there is nothing uh regarding the any of these protocols that you should know like in depth in cryptography you can just integrate create the voting app create the chat up create the some dial

stuff or anything you like and just imagine like having the tornado cache and a lot of protocols here you can just use the tornado with simple interface again deposit withdrawal but your note will be really secure and you will be able to get it but it will never be shown in this like front end where malicious software can uh inject the code and take it from you so uh yes uh this is really ugly now because this is just a simple demo what can be done uh and this is like used for purpose of testing but uh as you can see like this identity commitment in our

protocols is something similar to what's the public key uh in the like blockchain manner in metamask and stuff and uh that's the publicator which is visible but secrets that are creating this identity commitment are never can never be seen uh neither here neither in the front end they're back there in the background process staying secure so you can have like multiple identities create multiple wallets uh change the uh network to use everything you would like uh we should have features for like to have the activity of what did you do with your identity which proves you were

creating and uh there is a lot of small features which are just making the ux better and making it similar to all other security extensions that we have now but I think they're like out of the scope of this presentation or like not interesting in a way uh not the the core feature of the CK keeper so uh yes uh I don't know like if you have any questions what else we can look for but uh all in all this was the short introduction to what we have in CK keeper and I hope that after this uh some people

will ping us and maybe we can integrate more protocols into this uh it will be really awesome or just like if someone wants to build a deck on top of it we will also be very happy uh yeah thank you this is a great intro um I I feel like you're a natural presenter um I'd love yes I would like just call if Omar bagoy or nasif they're here uh if they want to tell something about this uh sounds awesome because like they're also the main part like they're they they built really cool features and Integrations on this so

uh it's not all me also tsukino if he's here I don't know um yeah I saw Omar on the call earlier but I don't see him now yes I also done him so no okay no worries like uh if anyone have a question like for what's oh here is uh yeah I just wanted that I'm not sure if you have mentioned that like we also plan to like add more features and like make it make the lyrics better so for example like up like I didn't more identity

management features and that kind of stuff which we plan to do like in the next few weeks uh yes thank you like as I said uh sorry I'm a bit out of the loop of what's uh happening in the keeper but uh I think this is really a good project and we did it from our own initiative which is I think really cool and uh yes like we're open to questions now I have a a question uh it's I I remember first time I heard this ckp keeper project was from Omar when we talk about

UI kid uh so right now we are working on the UI kit for all the team to make UI easily so I wonder how can we Leverage The ZK Keepers to a UI kit you know what I'm asking uh okay me and UI are two different worlds many people are going to have a better knowledge on that what should be done so the question is like um like how we can apply UI kit on ZK

keeper right yeah so like the view I I I I don't think this is the greatest show I think we'll need some help there I I don't I haven't looked into UI kit and I don't know like how that looks like but like if we can get some kind of like UI design help this I think that would be great yeah so I have a brief question about I guess creating private keys so in ZK

approve we create a private Key by having the user sign some data there's some structured data and then with the hash of that as the private key um I'm just kind of wondering how could we or is that a good fit for integrating with ZK keeper because I imagine or I know it's better to have a private key because then they could share it across across machines exactly exactly so we have like a multiple strategies of creating the identities uh the first one was like the most obvious one to just have random bytes which will create the the secrets and uh the the thing that we have integrated if you yeah you can still see

my screen so when you uh you're creating identity I have nothing connected now so sorry like this is not complete demo but when you want to create uh identity from interrupt uh that's what exactly will happen so you have your wallet connected and you will sign the message and hash of that message with the nons will generate your secrets so you can uh have deterministic value of your identity secrets and you don't need to to like uh if you want to transfer on another machine it's deterministic you don't need to like uh export it save it something somewhere

secure on some Flash and then uh then return it to the and then input it in another machine yeah cool that's what I was wondering great this looks like a cool product no guess like if you see this random uh if I just create it it's like not connected to anything uh but yeah if I went like to create it with uh interrupt and I can choose provider like GitHub Reddit uh there is nons of it it will be deterministic so yes what what other kind of identity types do you support in that menu uh so for now I think we just have this

interrupt identity and random uh but yeah as I said like my idea was to have like just just have input from people so we can have like real private Keys we can have like tornado notes we can have like all different kind of uh private Keys like uh in in a sense like your identity is actually private key so when you have all type of private keys and which can be used in the similar manner so uh I know that I was like looking at the Z copper code and I know that you have a uh your own wallet if I'm not wrong so it can be nice if we can integrate it in

one big just you know it can be called yeah just like a general layer to Key Management yeah for sure exactly exactly sorry I joined a bit late uh what is web 2 provider do uh so uh I think like if Omar here he will give you a like better uh introduction to that so it has nothing to do with DK keeper neither SEMA for neither Ireland it completely interrupts uh interrupting where you want to join some group uh and in order to join some

group you must have like a verified Twitter GitHub Reddit or any other like that to provide your account where we have like strategies how to calculate your like reputation so imagine like uh we say in order to join this group for voting or anything else you must have some uh Twitter reputation which exceeds some threshold which means you have uh enough followers uh enough uh tweets enough retweets you know flakes uh and all kinds of stuff which can build your reputation so that you have again your real identity like you you are the like one person uh so that you cannot join

and like civil attack the protocol with multiple random identities oh I see yeah that that explains clearly thank you so no words no we still haven't deployed it uh we are actually like the nasian plugway are finishing uh latest tracks on integration with uh rln chat and uh after that and some UI

UI stuff I think it can be ready to be uh pushed on the to be downloaded on everyone's machine as like from the Google Play Google Store okay thank you no worries any other feedback questions and uh sorry if I have a new application like a new zika application and that needs a new identity format how do I add to uh DK

keeper uh so when you you want to have like new uh application which relies on different protocol or like identity like uh can you just give me a better picture of when you say you have new type of identity what that means uh that's uh uh uh uh okay they say I I have a new uh tkp and it needs identity it uh it needs user to keep a secret value and also uh another authentication of a very uh

like a social media website that nobody use and then uh so let's say uh if if I want to create the identity for the user to uh can I like specify a format or I have to submit a pull request to the CK keeper uh yes I would like welcome any pull requests and uh also to help you so just to give you a quick a quick Overlook uh we have this our package for identity management uh where identity is uh okay sorry you you wanted to send something

and I interrupted you can you yeah yeah so uh um sorry my question is more like like um like how how do a new application integrate into the the keeper like uh I assume you have a standard or or the format for uh for like the application to add fields or or like um like uh the identity format is hard coded and and they have to like some in

them uh change in the code base I see like so uh our first goal was to like so that we like let's say personally integrate more protocols uh but if I'm not wrong what you're asking is about how will we handle something similar to metamask snaps so I think we still don't have that good mechanism that someone just uh comes and changed something but the the whole extension is pretty much modular so if you have some special use case you want to have you can uh just

make the pr and create your like your new scheme and new type on the the structure that we have already like you you will have a small amount of work to do you will have just uh to to add a few more types for like how your private data looks and if you use other protocol just to add how to proof and how the like actually how to prove and what's the weakness for that protocol okay I I see that's your idea thank you just like maybe there is a better

solution for that but we we really started with like just enabling what we have for now uh we still didn't think that far away to how to enable people to integrate their own protocols like in a live manner uh if it's even possible uh so yeah we we keep to security a lot like uh imagine uh where you have some Provider from which you are getting the numerical proofs and stuff like that so you can constraint do you want to like fight list that uh server uh to approve that server to get the data from and

stuff like that so uh because like you're directly like let's say for the circum proofs and stuff like that you have some Fitness circuit files uh which are hosted somewhere so you're actually downloading that code into your machine so uh like we should have some white listed list of servers that people at least trust that won't add some malicious file there and something like that I see yeah yeah that that makes perfect sense yes

with this page that you're displaying um can you re-explain the relationship it has to the browser extension uh uh which page uh sorry this one I'm sure with semaphore and rln on the left yeah of course of course so um you can see that here like if I go to these sources we have this uh ZK keeper which has some injected JavaScript content which enables this front-end page to communicate with the background page

okay so the background page is the one which stores the private data weaknesses and generates proof so uh in metamask Ed uh it's uh hides private key and uh science transactions for you uh to say it as simple as possible and here if you want to develop your own app on top of the protocols that we are supporting you can just create the simple front end for it and just uh just specify one function which sends all the public data in order that the proof can the valid proof can

be generated so you don't need to download any libraries for handling the protocol you don't need to care about cryptography security where you store data how you handle it the extension will do everything for you you just need to create the simple front end so if you see this there is no state in this front end it just uh the simple button which okay for now takes uh two random strings but imagine uh that you are sending some vote here or you're chatting so you'll have some text input here when you will say hi everyone and you will just say generate proof uh extension will

generate proof you will approve it and your proof will be returned in the browser so nobody from that proof nobody can deduce got like it's your knowledge your secret date did it clarify the stuff yeah I guess I'm also curious do you imagine um more people interacting with this as like um you know iterating their own versions off of what you've already done or um

installing the browser extension that you've created once it's ready I still haven't think about it and I think neither of us who are like on this but I think that this like presentation is really good way to start discussing on it like if the people has their own have their own projects uh how we can help how we can integrate should they uh make like the Clone disk repository and uh change it a bit to support theirs or should we add more protocols into this code base like I'm really open to everything and I'm really unexperienced with how all uh

all advices and opinions are really welcome cool yeah I'd love to know if anyone on the call if they're thinking about um how this could relate to a project they're working on uh yes it will be really good uh yeah I mean like I already said we can definitely use this with ZK approved uh it will be really awesome if you if you want to we can like reschedule another call to talk about it because it will be a bit of spam started right now

uh yeah uh about like that particular integration but I can see we are like managing to to uh do it yeah and there is trial saying C Corp replacement yeah I'm really happy like I really admire the Z corporate project like I I had a chance to to be on that like for two weeks I didn't do any code but just with learning and uh yeah that's the one of the best products I saw uh so I will be really grateful if we can do anything together just kind of interesting to know uh what

was your biggest challenge when you develop this uh solution so yes uh like the biggest challenge was to start because I was just reading some chats of like Barry girl to Kino and uh I don't know if sorry if I'm missing someone uh and I didn't know anything about how this works so the hardest part was to like just figure out which pieces comes where and uh like that's why tsukino was really like helpful uh he he explained me how the basic architecture of of the extension should work and how we

pass the messages through different processes so yeah uh that was the most challenging report I think also if someone wants to volunteer and try to integrate to another cache into this it will be really cool because I'm really low with time in the last couple of weeks months uh but it should not be that hard at all I think I already looked at it with someone I think it was you interesting uh but yeah I think it's it can like we can

do it in really simple Manner and uh and it can be good and earlier in the call you were talking about um um how how malicious code can be injected and like that as a value um proposition to this and I guess I'm curious like um do you have any uh like anecdotal stories

that relate to why it's important to work on Solutions yeah I I would say like I really don't have like personally because like I'm just like one year after graduation and uh a few months in like all the cryptography stuff but I know that like uh a lot of times the like you can find malicious code in npm libraries uh uh all times like there are some uh scripts which are trying to find the private data uh also like uh imagine like just if you have some

random extension you're using for Chrome like uh something totally unrelated to cryptography which you will not think there is anything which will like steal your data uh but actually there is just one simple function in that injected script which waits for you to like click deposit in tornado and imagine you're like depositing 100 ethereums so that's enough uh like yeah uh so yeah I I don't uh I'm really sorry I was also thinking of like creating the simple demo of how one can create the how one can steal the turn

out the cache node but I didn't have time to do it but I think it should be like pretty clear just like when you have it in HTML uh someone will just uh like do a simple regex and take it from HTML like that that will be the the whole function so uh it should be really easy to do and if you're careless uh yes yeah that's clarifying thanks no worries does anyone else have questions that

they haven't had a chance to ask no okay so like feel free to add any review to this presentation or like what you think about this later and feel free to to Ping Us in CK kids chat uh if you want to integrate chat about this or build some feature on top of this

awesome thanks so much for presenting today um it was really cool to learn thank you more about what you're working on really glad that a lot of people were there so yeah looking forward to other presentations same thanks everyone for joining the call today yeah thank you everyone and um thanks guys thank you