NoirHack: Library Workshop - ZK Kit

NoirHack 2025 · April 2025 · 39:12

Vivian Plasencia of Privacy & Scaling Explorations leads a hands-on NoirHack workshop on ZK-Kit. She shows how to integrate the library into projects and works through real code examples that help developers start building with zero-knowledge proofs quickly.

Speakers

Topics

From NoirHack 2025, hosted by Aztec Network.

Transcript

GM GM. Hey everybody, let everybody slowly uh join us. Um we are here for another workshop uh in our workshop series. Um another library workshop. Uh we're joined uh by Vivian from PSSE and she'll be walking us through uh ZKit. Um so she'll introduce ZKit. um she'll show us how to integrate it into our projects and then we'll go into some code examples to help uh really get started super fast. Um so I will hand it over to to Vivian to uh walk us through ZKit.

Hello, my name is Mia Placencia and I'm a software engineer in the privacy and scaling explorations team at the the foundation and today I'm going to talk about CK kit in practice. Let's start. This is the structure of the presentation. I'm going to start with what is CKit. Then I'm going to mention the CK repositories. Then I will talk about the core principles cit I will also talk about the flow of ser knowledge applications. I will talk about how to use ca kit. I will show some code examples and how you can start how you can get involved with c kit

too. Let's start with what is ck kit. Sega kit is a set of libraries such as algorithms, utility functions and data structures that can be reused in different projects and ser knowledge protocols making it easier for developers to access userfriendly tested and well doumented code. There are five repositories so far. There is one for TypeScript, JavaScript, another for Solidity, Circum and Rust. You can find all the repositories in every repository has all the repos. So you can find all of them in DK kit and then the others have links

to the the other repositories too. So it's easy to go from one repository to the other. These are the core principles of CK git. The first one is modular and independent packages. The packages are independent. So you can use a package. You don't need to use others just with one is fine. They are independent. Dry principle. This is don't repeat yourself. If you're writing a code many times you are writing the same code, it's better to abstract it and have a library for that. So that's the idea of ck kit too. Consistent cross language APIs.

This means that if you have stick kit has the same data structure implemented in many different programming languages. So they are consistent in the name of the functions and the parameters. So if you use one data structure, you will probably find the same function in all of them. We always try to be consistent with the different data structures in the same language so that it's easy for people to switch data structures too. Interoperable implementations ac across languages. This means that since the same data structure can be implemented in many programming

languages, every data structure is optimized for its implementation in that ecosystem. For example, if there is one data structure for miracle trees in Typescript, it's optimized for the TypeScript ecosystem. And if this same data structure is implemented in solidity is optimized for solidity for smart contracts in the same form and for all of the others. So that's the idea of this principle also well tested codebase tests are very important. So we always try to make sure that all lines are covered and all branches security through audits. We

recently finished an audit for SEM operation 4 and it covers some cit packages and we want to have more audits so that it's more secure to use these libraries. performance benchmarks. Comparing different data structures is always important so that it's easy for you to decide which one you need and contributions are very welcome. So that's another important thing. Let's talk about citar contains the following packages so far. One for merries. There is an

implementation of a binary micro tree and also sparse mer tree as I mentioned before is they are compatible with the typescript implementation for example. So the idea is try to make them compatible optimized for each ecosystem but still compatible. There's another package called ECDH and another one called binary fruit which I will be talking about during this presentation. This this has been the most popular so far since you have been asking for it lately. So I will cover more about it and I will also explain more about the code and everything and how to use it. You can use

cinor like similar to the other libraries in nor in the nor ecosystem. You for example the binary maker fruit you just add the dependency like you add the GitHub URL the tag and also the directory and that's it. You add this and then you can just import it. You import the library and the function and then you can use it. I will explain more this library and also show an example how how you can use it.

But here you can see that you send the hash function. You send the leave and also the depth and the indices and the siblings like membership proof and then you can calculate the root because the idea of this library is to calculate the root of a binary miracle tree. This is the flow of a general serowledge application. The user will interact with the front end, the user interface and then the user interface will interact with the back end, a web to back end or a smart

contracts. Something important here is that to generate the proof is the proof generation is always in the front end because it will probably use private data. So it should be in the browser or the phone and the proof should be verified in the back end in smart contrast or web two back end so that we can know that is correct or not. That's important to know that the proof generation is always option in the browser or the user interface and the proof verification is always in the back end.

This is a diagram to show how you can use sticker kit in the nor system. You will have your N circuits. Then you will have your logic for your circuits using the binary maker as an example. You imagine that you want to calculate the maker. Then you will have your logic and then you will use this library and and have your circuits. And then for the front end you since the libraries are compatible across ecos different ecosystem and programming languages you can use any binary maker tree from cit in this case I'm going to talk about the

lin incremental tree which is an optimized version of the incremental tree in c kit. There there is also a data structure called incremental tree but we've recently created this Linux incremental tree to for version 4 which is an tree. So I will suggest you to use this one if you need an incremental look tree. And in this case the in the front end to generate the proof you will use the JavaScript implementation of this data structure. And then to verify it if you have a web to back end with TypeScript in JavaScript you can use the same implementation in JavaScript and and if you use solidity to verify the

proof and for the logic of your program you you will use the solid implementation. These are the same data structure but each implementation is optimized for each environment. So the implementations are not the same but they generate the same results because one implementation is optimized for JavaScript and then the SL8 implementation is optimized for smart contracts like gas cost and things like that. So let's show some code examples.

Here is the cinar repository. You can if you go to the freely file you will find the other repositories and the documentation for each package is always in the free file. So you can find the code examples there and the frame file the main frame file will always have the repositories the packages and the ways to contribute how to install it how to use it and test it. So in this repository I'm going to talk about the binary maker root for example. This can be imported like this and this can be added to the

dependency. Just copy this. And for example, you have been asking about this circuit lately and I'm going to talk a bit about it. And this is a circuit to calculate the fruit of a binary micro tree. It's compatible with the incremental mer tree from seek kit also with with the l incremental merch tree with any binary mer tree and the circuit is designed to as a dynamic is designed to calculate the mer for smaller tree depths. That's why

there is a max depth parameter here. The idea of this max depth is that if you is mainly for the artifacts. If you generate this cir if you use this circuit and your your circuit uses max depth 32 for example then you can use with the same artifacts you can use three depths up to 32. And the idea is to to allow this because if you don't if we don't do that then we will need to create artifacts for all of the three depths and this is better it's better to use the artifacts of every three depths

because this way you can the file the CP artifacts are smaller but in case your application needs just artifacts for one tree dep is better to use the biggest one so that you can support all of the three depths less than or equal to that one that max depth you decided. And this circuit will go to until max depth and then we'll be calculating until the depth the the root using the membership proof like if it's a if it's the index is zero it will the node will be in the left and then if it's one it will be in the right and they will use

the hasher like the hash function you send to hash it and then you will get the root. So that's the idea of this circuit. Then I want to show the the TypeScript equivalent. So that one is to calculate the mer foods. But you can use this library in Typescript in the front end or in the back end is in JavaScript to at the same time with these other binary miracle fruit circuits. So that's the idea to use different packages in different

ecosystem but they are all compatible and here is implementation. This is the way you can install it and use it and and this here you can find the functions. I'm going to talk about the example of circuits using these libraries. I'm going to talk about the semifur version 4 implementation in N. This is an ongoing implementation and research implementation by the hash glow team.

They they have been doing a great work with that. And here you can see how this library can be used. For example, in here the max step will be up to 10. For example, we will need to have 32. But this is an example. And this is related to semur like identity. But here you can see how this circuit can be used. How this library can be used. This is the hash function for two elements. Then this is the leaf and this is the the depth and then the indices and

the ceilings. So the way to use it is the same. You just try to use it according to your application and what you need. Because for example for RLN which is another implementation a new implementation of the RLN protocol using the latest features of SEM for version 4 like the identity schema with EDSA and the LIN incremental tree. This protocol also uses this library because it needs to calculate the merger fruit and then it's the same like it's poss but it's still the leaf of the a

leaf of of the tree and then the depth and the insistency. So it's the same. And then if you check here is the dependency. So how you can get involved?

So if you if if you have an idea for a new package or a new algorithm, something that can be helpful for the program of the cryptography space for apply cryptography for C knowledge applications, that would be great if you if you create an issue or ask to add it because the idea of CK nor is to provide this kind of functions and libraries for people creating ser knowledge applications and apply cryptography. So that's the idea of CKit in general. So you can work on open issues, you can

also suggest new libraries, you can share ideas for new features and also report any bugs you find in the code. And for that you can go to GitHub or you can also go to the PSC discord. Here is the QR code and there is a channel for CK kid. You can also ask question there, join discussions or create discussions and yeah you can contact me on Telegram, GitHub, Discord, but feel free to tag me on the Discord or PSC. Yeah, I will answer there too. So

yeah, thank you very much. Feel free to ask any questions or if you want me to answer something specifically or show some code. We have a couple questions in the Q&A from Monza. You want me to read them to you? I know while you're sharing I'm going there. Okay. Yeah, feel free to read them. Sure.

Yeah. So the first one is um what's the current implementation status of semaphore and are there any plans to implement Macy? We're planning to use both in our project. That's cool. So semaphore there the circuit is ready and there are some benchmarks. So we will have more benchmarks and there is also an ongoing research development for proof recursion and yeah so you can I can share the link to their work they the repo I will share

the link to the repo in the chat. Okay. Okay. Awesome. I think the same uh the follow-up question to that was just around the initial implementation for semaphore and if you could share that. So if you can share that in the chat I think that'll be good for Monza. Um and then Octavio asked um have you documented the format requirements for an algorithm to be a part of the kit? I like the formatting idea. It might be good to have parallel sets of functions in this fashion but perhaps some of them are not general enough to be worse on the main repo. So he's just asking about like if there's a format for if I guess he wants to maybe submit some stuff for the algorithm part.

Yeah, the in the issues you can find the information when you willing to create a new issue, suggest an idea. So feel free to create the issue as you prefer, create the idea and then we can discuss it there and and then if you are interested you can also create the PR to add this new package and algorithm. Cool. Awesome. Um any other questions from anyone? I see Savio is in the chat. Oh, Octavio asks um are there any strong cryptographical warrants that all

implementations do the same like uh I don't understand like the question a different way to say the same thing. Well, you want to add a little bit more context to what you're asking? So uh he's asked you're able to see the Q&A now. Yeah. Is there a set of tests ensuring all of them deliver the same results for the same input environments?

Yeah. Yeah. Yeah. There are tests for every package and for every for everything. So you can check that they are all compatible and they are actually in SEMA 4 and Macy and some protocols they are using we are all using these packages and yeah so so yes there are tests and also there are real world protocols using them awesome I have some some questions for you maybe you could share um if there's any um use cases or example applications that you could think of that um would benefit from using ZKit. So um in the Noir hack um program, people are trying

to build a cool applications that really, you know, actually are useful and uh on the application layer um really for the first time. Part of the whole message of Noir Hack is that now is the time to build real apps. Um are there any real apps that you envision people building that they could use ZKit to make um way easier to build? Yeah. Yes. So the idea of someone mentioned Macy, it will be really cool. I don't know of any anyone or anything working on that. So it will be super cool. And for SE for there is already an ongoing research development process.

But for example for RLN which is similar. I created the circuit and you the circuit is the one I showed before. But it will be nice if someone take this circuit and improve it or maybe optimize it. If if there is a way to optimize it, they optimize it and make it production ready so that RLN can be used in real life but created with more. That's an interesting protocol too. So yeah, Macy RLN these kind of things are really interesting because these are protocols that are used in real life. RL is used by Waku for example. they have their own own implementation that is useful and Mac is used by many projects too. So

yeah, for semaphore there isn't already but for these other two protocols it will be super nice to have this and also if someone is using the same circuit or if someone creates a circuit that can be reused by other people, it will be nice if they just add it to Cit so that many people can use it and also at some point the circuit will be audited and and yeah so if someone wants to add any circuit that will be cool too or create issues these kind of things. Yeah.

Awesome. Maybe you could also share a bit more on for those people who are joining either via the recording or now who are maybe a bit more new um or you know beginners or intermediate to noir. Um you could talk a little bit about how uh using ZKK compares to manually implementing some of these primitives and how much easier it could make. Maybe you could talk about like some of the trade-offs and why it's like so useful to to be able to use this instead of just rewriting all of these primitives. Yeah. Yeah. I think the circuit I mentioned before, the binary maker route is a great example because if you create this circuit from scratch, you will probably have the functionality, but it

won't be optimized. So the hash code team work on that and then it was optimized in a way that if you just integrate it you you just need to know that it's optimized. it was optimized for some people and you can optimize it too but it was already optimized which is great so that you don't need to to create the same thing and and you can just know that is it was test well tested it was optimized and that's cool and so I think that's the main advantage of using it's like the advantage of using a package that was tested by many people other projects that is being used in some projects so That's the idea that

yeah they can use it directly to get the functionality and the security and and everything. Yeah. And how do you guys envision u zkit kind of evolving in the longer term? Um what what are some so you mentioned a little bit about like Macy and other uh examples but like maybe in the longer term what excites you uh for a ZK kit like what do you think you will be able to do and solve? Yeah, I would like to see many people contributing in a way that we all add code there. The seralist ecosystem, the apply cryptography ecosystem at libraries and circuits there so that

everyone can use it and we all know that it is correct and it was edited it was tested by many people and projects. So I would like to see that many people using an addin circuit and libraries there so that so that we know that that's correct. I think that's the idea to to have a package that many people can use and these people that are using it will optimize the package and then the package will be better and then other people will use it and then we optimize it and we will be better and in the long term it's going to be audited will test it and working well. So I I would like to see this project as a community project

like many people involved and helping not just a few projects but many people. Yeah. Right now there are quite a few projects using it and contributing but I would like to see even more people and projects and teams doing that. Yeah. In all the programming languages. So you mentioned also uh auditing. Could you share more about the the timeline on that? And then you also mentioned that there are some teams that are building with it. Maybe you could share like what what cool stuff people are already using with ZKit or people are already using ZKit for.

Yeah, for there was an update for SEMA for version 4 for the latest version and there were some packages from Cit. So some package like the L from tree were were audited and the idea is to plan and audit for other packages too and some other projects using CKit. I would say Macy. Macy is also using CK Git and I have seen other projects also supas the supas team and usually people use it for merries for for the incremental m tree the

incremental merch tree since it's more recent than incremental merch tree people started to use that one too. So I would say mainly for membership proof and mercuries. Yeah. People have been using that. Yeah. Uh what for you? So um maybe you could share about any um pitfalls, challenges, resources for you like in learning noir if you have been um working on more noir projects, working on this noir part of uh Zika kit. um like you could maybe share some some resources that were helpful for you. Um and then also like

any things that you found like challenging, interesting in like learning and getting more familiar with noir. Mhm. Yeah, I think the documentation is really good and the code that people create this is useful also. That's one of the interesting part of sik kit that people can use the code to learn about this language not just the data structure but also the language so some resources I follow the documentation is great the documentation is great yeah so it's been very helpful and code I found from the from discord

the discore and yeah the on GitHub too. Were there any like things that were like gotchas where you felt like something should have been a certain way and then you got like stumped and then you realized like oh actually this is um in this way like something that maybe developers could be more aware of. is something we have been discussing in the square is the dummy square that the for example the semer circuit has a dummy square because the input won't be constrained if you don't create this dummy square and it looks

like in R that's not necessary which is cool because all the input are constrained so that's interesting to me because yeah it makes sense And it's really nice that we don't need to create this dummy constraint. And I really like that. And I also like that this circuit, the binary maker fruit has the hasher as a parameter. So you can use the hash function you want because by default in circum you will need to use a specific hash function. And here is more general. You can use the ones you prefer, which is great because it's more

abstract. I really like that too. Yeah, I really like that about norm. What other nice stuff can you say about Noir? Yes. So, no pressure. I think it's a good developer experience. No, but it's like the developer experience to get started. The community, I like the community and people around it. Yeah, very helpful.

You ask questions and there's always someone answering which is great and that's super important. I really like that. With ZK Kit, are there any uh gotchas or things for people to keep in mind as they integrate it? Um, so either as they maybe make contributions or if they start using any of the um primitives, is there anything that you think is especially important for people to to keep in mind? Probably a lot of it you've maybe already covered, but anything that um just know that if you're using a data structure, it's probably implemented in another language. Like if you are using

it in Typescript, it's probably implemented in another language. And if it's not implemented, you can create an issue in a PR to implement it. And that's something important to keep in mind because they will be compatible. So if you use one in one ecosystem is better if you use the same the same one from kit but in the other ecosystem you need that. So that's important to keep in mind. And yeah, and if people need something or have questions, they can always ask on GitHub or in the BSC CK channel on Discord. So, so yeah, and we would

always answer. Awesome. I think so far there's not been any integrations with like front-end tools like with NoJS. I think that would be something I would want to see someone build potentially. Um, has there been anything like that so far? I know it's quite new like the noir part. Yeah, this the sema for no implementation they are integrating the the JavaScript part. So they already did that and they already created benchmarks. So So yeah, this is the first approach to to test this. So no there are not others packages. No for circum there is a package for example

to to to convert the for example the grocery the grocery proof compatible with both the contracts and and the back end with Typescript. And something interesting will be to explore if this is necessary for nor for the JavaScript part. I haven't taken time for that but that's something I have in mind because there is a library to to work with that with sircom because of uh the way everything is done injs. So if there is if this is necessary for no it will be nice to create a library or a function for that

so that people can create protocols in a way that when they generate the proof the same proof can be used onchain and offchain because with snarjs if you generate the proof this can be used directly with snarjs in the back end but you need to create convert it to use it in smart contracts. So the way we we are doing it in semaphore and we did with CK kit in the library was to just convert it to to be compatible with smart contracts so that we save gas and then we convert it in JavaScript when we want to verify it.

So if in order this needs to be done it will be nice to add the function to cit JavaScript repo so that this functionality can be there too but maybe that's not necessary because but I haven't checked but maybe the same proof can be used both places directly but yeah I haven't checked but if this is necessary it would be nice to add these functions. Yeah, if whoever is listening and wants to contribute, this would be a good thing to potentially build or at least to check to see if you can use it in the front end, I think for any project that's going to use this, they'll probably likely need to support that.

So, if someone is interested uh in building that, we would love to see that. In general, maybe you could share a bit about uh contributors. So, um you guys are looking for people to help contribute to add uh resources to share primitives. Um, and I think maybe there's going to be some potential incentives as well for PSSE from PSSE for this. So maybe you could share like how you're thinking about contributors as I I'm sure that there are people listening either live now or in the recording that uh could be interested. Yeah, we are still organizing this part now but the general idea is that people can just go there and propose ideas.

There is not like an official way to do it like you need to to do this step and then this other. It's it's just you go there and you create an issue and you share your idea. Feel free to always share your idea and yeah it's not that it's not not not difficult. Just go share your idea and that's it. we will discuss it there and then yeah if you need a primitive that can be interesting for kit just drop idea there too so that we can work on that and or someone can work on that it would be better if someone from the hackathon work on that so so yeah

we have one question right now from nerf she's asking where they share the ideas I think you mean just like GitHub issues like in the repo or if you have issues or yeah I in the presentation there is uh the PSC Discord you can go to that place too if but both are fine wherever you prefer GitHub issues uh with any repo if it's you go to the kit no repo go to the issues and create an issue and if it's if you want to just discuss in a shot you can go to PSC kit channel and yeah that's fine Cool. Awesome. Yeah, I will share some

of these resources uh afterwards in our notion. We have a notion which is our start page. So, um I'll share like the PSC Discord, the slides that Vivian went over, um the actual uh links to Zika kit for u JavaScript, TypeScript, Noir, uh even the Saraban as well. Um but cool. Yeah. Uh does anyone else have any any more questions for for me or for Vivian? before we maybe close. You miss early. Just thank yous. Cool. Yeah, thank you.

Awesome. Well, um unless Vivian there's anything you want to add, um we can maybe close uh here. Thank you for excellent presentation. Thank you. Thank you very much for inviting me and yeah, super happy to be here. Thank you. Awesome. Yeah, super excited to see what uh what people build and hopefully what they contribute to uh to uh ZK Kit. Yeah, cool. All right, thanks everyone. Have a good one. See you at the next workshop. Hi