Zerokit RLN-CLI
The Zerokit RLN-CLI provides command-line interface examples on how to use the public API of the Zerokit RLN Module.
Relay Example
The following Relay Example demonstrates how RLN enables spam prevention in anonymous environments for multiple users.
You can run the example using the following command:
cargo run --example relay
You can also change MESSAGE_LIMIT and TREE_DEPTH in the relay.rs file to see how the RLN instance behaves with different parameters.
To customize the TREE_DEPTH constant to differ from the default value of 20,
follow the Custom Circuit Compilation instructions.
Stateless Example
The following Stateless Example demonstrates how RLN can be used for stateless features by creating the Merkle tree outside of the RLN instance.
This example functions similarly to the Relay Example but uses a stateless RLN and separate Merkle tree.
You can run the example using the following command:
cargo run --example stateless --no-default-features --features stateless
Multi Message ID Example
The following Multi Message ID Example demonstrates how RLN supports consuming multiple message_id units in a single proof using the multi-message-id feature.
This example functions similarly to the Relay Example but uses different resource files that support the multi-message-id feature.
You can run the example using the following command:
cargo run --example multi_message_id --features multi-message-id
Partial Proof Example
The following Partial Proof Example demonstrates how RLN supports accelerated proof generation by pre-computing and caching the static witness portion, then quickly finishing proofs for new messages.
This example functions similarly to the Relay Example but demonstrates the partial proof optimization technique for improved proof generation performance.
Cached partial proofs remain usable across tree changes within a small window —
verify against a bounded set of recent roots
(e.g. via verify_with_roots)
instead of regenerating immediately.
Once the root falls outside the allowed window,
reset by generating a new partial proof with the latest Merkle path.
See the Partial Proof Generation section for details.
You can run the example using the following command:
cargo run --example partial