Ekaterina Broslavskaya ba467d370c chore(rln): update dependencies and refactor code for compatibility (#291)
While publishing the release on crate io it turned out that we can't use
libraries without a version as it was for arc-circom.

During the upgrade to the new version it was also discovered that it is
possible to speed up input preparation for witness calculator by 4 times
by switching from bigint to Fr:


![image](https://github.com/user-attachments/assets/53962387-308b-4aae-8af2-dbd0d3f62369)

it was also checked that it is also possible to use iden3 as a
sub-module instead of copying code, but benchmarks showed that the new
iden3 version with u256 calculations and subsequent conversion of the
result to Fr is slower than the current implementation:


![image](https://github.com/user-attachments/assets/f950f089-b66a-4a13-a86f-f391caf32b4f)

----

- Updated dependencies to their latest versions, including ark-ff,
ark-bn254, ark-std, and others to 0.5.0.
- Refactored circuit and iden3calc modules to use Fr instead of BigInt
for better type consistency.
- Improved utility functions for type conversions between Fr and U256.
- Adjusted Cargo.toml files for rln and utils to reflect new dependency
versions and features.
- Enhanced documentation and comments for clarity on changes made.

This update ensures compatibility with the latest versions of the Ark
framework and improves overall code quality.
2025-03-14 20:56:00 +07:00
2023-02-28 16:25:18 +05:30

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 zkSNARKs
  • Circom Compatibility: Uses Circom-based circuits for RLN
  • Cross-Platform: Support for multiple architectures (see compatibility note below)
  • FFI-Friendly: Easy to integrate with other languages

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

Important

For WASM support or x32 architecture builds, use version 0.6.1. The current version has dependency issues for these platforms. WASM support will return in a future release.

Install Dependencies

make installdeps

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
Description
No description provided
Readme 52 MiB
Latest
2025-06-05 05:23:06 -04:00
Languages
Rust 89.8%
Nim 4.1%
C 2.7%
JavaScript 2.7%
Nix 0.5%
Other 0.2%