zerokit/rln
G 824296e695
refactor(rln): use space-efficient Merkle tree implementation (#32)
* refactor(rln): replace merkle tree implementation

refactor(rln): before switch

refactor(rln): replace merkle tree implementation

fix(rln): cargo fmt, cargo clippy

cargo fmt

* chore(rln): add comments

* chore(rln): cargo fmt; cargo clippy

* refactor(rln): improve Merkle tree crate

- Integrate previous Full storage MT with Optimal (storage) MT implementation
- Align the two implementation to same API/traits implementations
- Align implementations as much as possible to same language and variable names/meaning
- Comment code
- Add descriptions to each module's crate
- address reviewer's comments

* refactor(rln): fmt, clippy, remove pub from next index, update output type for some proc
2022-08-17 11:08:14 +02:00
..
resources refactor(rln): Update Merkle tree initialization method (#30) 2022-08-05 12:36:06 +02:00
src refactor(rln): use space-efficient Merkle tree implementation (#32) 2022-08-17 11:08:14 +02:00
vendor chore(rln): Add git submodule 2022-05-24 12:08:42 +01:00
Cargo.toml refactor(rln): improve circuit loading performances and tests fix (#26) 2022-07-29 13:40:16 +08:00
README.md RLN: update README (#27) 2022-08-07 16:51:03 +02:00

README.md

Zerokit RLN Module

This module provides APIs to manage, compute and verify RLN zkSNARK proofs and RLN primitives.

Currently, this module comes with three pre-compiled RLN circuits having Merkle tree of height 15, 19 and 20, respectively.

Implemented tests can be executed by running within the module folder

cargo test --release

Compiling circuits

rln (https://github.com/privacy-scaling-explorations/rln) repo with Circuits is contained as a submodule.

# Update submodules
git submodule update --init --recursive

# Install rln dependencies
cd vendor/rln/ && npm install

# Build circuits
./scripts/build-circuits.sh rln

# Copy over assets
cp build/zkeyFiles/rln-final.zkey ../../resources/tree_height_15
cp build/zkeyFiles/rln.wasm ../../resources/tree_height_15

Note that the above code snippet will compile a RLN circuit with a Merkle tree of height equal 15 based on the default value set in rln/circuit/rln.circom.

To compile a RLN circuit with Merkle tree height N, it suffices to change rln/circuit/rln.circom to

pragma circom 2.0.0;

include "./rln-base.circom";

component main {public [x, epoch, rln_identifier ]} = RLN(N);

However, if N is too big, this might require a bigger Powers of Tau ceremony than the one hardcoded in ./scripts/build-circuits.sh, which is 2^14. In such case we refer to the official Circom documentation for instructions on how to run an appropriate Powers of Tau ceremony and Phase 2 in order to compile the desired circuit.