Files
zerokit/README.md
Vinh Trịnh 77a8d28965 feat: unify RLN types, refactor public APIs, add full (de)serialization, align FFI/WASM/APIs, simplify errors, update docs/examples, and clean up zerokit (#355)
# Changes

- Unified the `RLN` struct and core protocol types across public, FFI,
and WASM so everything works consistently.
- Fully refactored `protocol.rs` and `public.rs` to clean up the API
surface and make the flow easier to work with.
- Added (de)serialization for `RLN_Proof` and `RLN_ProofValues`, and
matched all C, Nim, WASM, and Node.js examples.
- Aligned FFI and WASM behavior, added missing APIs, and standardized
how witness are created and passed around.
- Reworked the error types, added clearer verification messages, and
simplified the overall error structure.
- Updated variable names, README, Rust docs, and examples across the
repo, updated outdated RLN RFC link.
- Refactored `rln-cli` to use the new public API, removed
serialize-based cli example, and dropped the `eyre` crate.
- Bumped dependencies, fixed CI, fixed `+atomic` flags for latest
nightly Rust and added `Clippy.toml` for better fmt.
- Added a `prelude.rs` file for easier use, cleaned up public access for
types and types import across zerokit modules.
- Separated keygen, proof handling, slashing logic, and witness into
protocol folder.
2025-12-09 19:03:04 +07:00

3.1 KiB

Zerokit

Crates.io GitHub Workflow Status License: MIT License: Apache 2.0

A collection of Zero Knowledge modules written in Rust and designed to be used in other system programming environments.

Overview

Zerokit provides zero-knowledge cryptographic primitives with a focus on performance, security, and usability. The current focus is on Rate-Limiting Nullifier RLN implementation.

Current implementation is based on the following specification and focused on RLNv2 which allows to set a rate limit for the number of messages that can be sent by a user.

Features

  • RLN Implementation: Efficient Rate-Limiting Nullifier using zkSNARK
  • Circom Compatibility: Uses Circom-based circuits for RLN
  • Cross-Platform: Support for multiple architectures with cross-compilation
  • FFI-Friendly: Easy to integrate with other languages
  • WASM Support: Can be compiled to WebAssembly for web applications

Architecture

Zerokit currently focuses on RLN (Rate-Limiting Nullifier) implementation using Circom circuits through ark-circom, providing an alternative to existing native Rust implementations.

Build and Test

Install Dependencies

make installdeps

Use Nix to install dependencies

nix develop

Build and Test All Crates

make build
make test

Release Assets

We use cross-rs to cross-compile and generate release assets:

# Example: Build for specific target
cross build --target x86_64-unknown-linux-gnu --release -p rln

Used By

Zerokit powers zero-knowledge functionality in:

  • nwaku - Nim implementation of the Waku v2 protocol
  • js-rln - JavaScript bindings for RLN

Acknowledgements

  • Inspired by Applied ZKP group work, including zk-kit
  • Uses ark-circom for zkey and Groth16 proof generation
  • Witness calculation based on circom-witnesscalc by iden3. The execution graph file used by this code has been generated by means of the same iden3 software.

Important

The circom-witnesscalc code fragments have been borrowed instead of depending on this crate, because its types of input and output data were incompatible with the corresponding zerokit code fragments, and circom-witnesscalc has some dependencies, which are redundant for our purpose.

Documentation

For detailed documentation on each module:

cargo doc --open