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

Overview

Zerokit

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

Initial scope

Focus on RLN and being able to use Circom based version through ark-circom, as opposed to the native one that currently exists in Rust.

Acknowledgements

Comments
  • feat: wasm

    feat: wasm

    How to compile zerokit for wasm and see example code:

    1. Make sure you have nodejs installed and the build-essential package if using ubuntu.
    2. Install wasm-pack
    curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh
    
    1. Compile zerokit for wasm32-unknown-unknown:
    cd rln
    wasm-pack build --release
    
    1. Launch example app
    cd www
    npm install
    npm start
    
    1. Browse http://localhost:8080 and open the developer tools to see console logs
    track:zerokit 
    opened by richard-ramos 12
  • RLN: use space-efficient Merkle Tree implementation

    RLN: use space-efficient Merkle Tree implementation

    Problem

    Currently, zerokit RLN supports naive Merkle Tree implementation: when a RLN object is created, a tree of height N+1 is initialized (including the leaves level) with a total of 2^(N+1)-1 allocated nodes that remain allocated for the whole life of the RLN object, even in case the tree is empty or accumulates less than 2^N leaves.

    For space-efficiency reasons we would like to add support to a Merkle trees implementations that progressively allocates only those nodes which are necessary to prove membership of currently non-empty leaves.

    Acceptance criteria

    • [x] Implement Incremental Merkle Tree with APIs compatible with current Merkle Tree implementation (aligned to https://github.com/vacp2p/zerokit/issues/28)
    • [ ] ~~No regression in performances with respect to current implementation.~~
    • [ ] ~~If regression in performance, evaluate space/time tradeoffs and followup with a better solution.~~
    track:zerokit track:rln 
    opened by s1fr0 9
  • refactor(rln): update APIs after circuit update

    refactor(rln): update APIs after circuit update

    This PR updates some zerokit RLN APIs in light of the security design changes discussed in https://github.com/vacp2p/research/issues/152, https://github.com/Rate-Limiting-Nullifier/rln_circuits/issues/1 and implemented in https://github.com/Rate-Limiting-Nullifier/rln_circuits/pull/2.

    In particular external_nullifier is now computed as the Poseidon hash of epoch and RLN identifier, while in generating shares the nullifier is computed only by hashing the a1 coefficient (see above issues for more details).

    Note that all circuit resources had to be re-generated and that new circuits are not compatible with previous ones.

    @richard-ramos @fryorcraken could you please ensure that these changes doesn't break anything in rln-wasm and js-rln ? (should not, but better we double check)

    FYI: @curryrasul @AtHeartEngineer

    track:zerokit track:rln 
    opened by s1fr0 8
  • RLN: Update Rust and C API

    RLN: Update Rust and C API

    This PR addresses https://github.com/vacp2p/zerokit/issues/19.

    Progress

    • [x] Implement byte serialization/deserialization of custom data structure (RLN Witness and Proof values);
    • [x] Extend/update RLN Rust public API to support all required features;
    • [x] Extend/update RLN C public API to support all required features.
    track:zerokit track:rln 
    opened by s1fr0 8
  • feat(rln): integrate pmtree for MT persistance

    feat(rln): integrate pmtree for MT persistance

    This PR is a first step towards a fully working implementation of persisted Merkle trees in zerokit.

    The PR integrates the pmtree module developed by PSE, as described in https://github.com/vacp2p/zerokit/issues/65, and checks correctness of implementations using SledDB for on-disk persistence and HashMap for in-memory storage.

    A new feature pmtree is added in order to swap from the current default OptimalMerkleTree implementation to pmtree. However, at the moment this feature is disabled (will fallback to OptimalMerkleTree), since some pmtree's APIs still need to be aligned with zerokit module and other MT implementations.

    Follow-up PRs will ensure that all 3 FullMerkleTree, OptimalMerkleTree and pmtree implementations are aligned and interchangeable by enabling the corresponding feature flag.

    @curryrasul @AtHeartEngineer

    track:zerokit 
    opened by s1fr0 6
  • RLN: Update identity_secret generation

    RLN: Update identity_secret generation

    To make the credentials generated by RLN more compatible with Semaphore, we need to update the secret generation to include generation of the identity_trapdoor and identity_nullifier as mentioned in Semaphore's docs - https://semaphore.appliedzkp.org/docs/technical-reference/circuits

    This will allow re-using the same credentials for Semaphore groups and RLN

    cc: @s1fr0 @oskarth

    track:zerokit track:rln 
    opened by rymnc 6
  • feat(rln): add example usage tutorial and expand documentation for RLN

    feat(rln): add example usage tutorial and expand documentation for RLN

    This PR partially addresses https://github.com/vacp2p/zerokit/issues/69.

    Items completed

    • [x] Basic documentation for how to use RLN in Zerokit.
    • [x] Document public crate APIs documentation so that meaningful info appears when running cargo doc

    In order to minimize the cognitive overhead given by following the tutorial proposed in first item, further APIs might be added in parallel PRs with the goal to minimize the amount of code required (e.g. simplify serialization, etc). Such effort will ease the understanding and design of a CLI interface as requested by https://github.com/vacp2p/zerokit/issues/70.

    At the moment, such parallel PRs consist of:

    • https://github.com/vacp2p/zerokit/pull/75

    Merging/closing them PRs is a prerequisite for this one to be merged.

    opened by s1fr0 6
  • feat(rln): ability to set leaves from a given index

    feat(rln): ability to set leaves from a given index

    This PR allows the following feature - https://github.com/status-im/nwaku/issues/1266.

    Changes the C FFI of set_leaves to init_tree_with_leaves, and adds a new function called set_leaves_from, which init_tree_with_leaves uses internally, with starting index 0.

    track:rln 
    opened by rymnc 5
  • RLN: fix proof generation/verification and E2E tests

    RLN: fix proof generation/verification and E2E tests

    This WIP PR addresses https://github.com/vacp2p/zerokit/issues/16 solving previous issues with proving and verifying keys import, proof generation/verification, RLN witness fields, etc. It further removes some unnecessary crates.

    track:zerokit track:rln 
    opened by s1fr0 5
  • feat(rln): add few serialization APIs to ease user interaction

    feat(rln): add few serialization APIs to ease user interaction

    This PR partially addresses https://github.com/vacp2p/zerokit/issues/69, by adding new APIs to ease user interaction while using public APIs.

    The main goal is to reduce the cognitive overhead required to interface with public APIs, by providing helper function which automate non-RLN specific tasks (mainly I/O serialization/deserialization).

    Merging this PR is a requirement for merging the documentation PR https://github.com/vacp2p/zerokit/pull/74, which was already updated to refer to such new APIs.

    track:zerokit 
    opened by s1fr0 4
  • Milestone: zerokit release v0.1

    Milestone: zerokit release v0.1

    Problem

    UPDATE: This is becoming a waterfall release which keeps getting delayed, which was never the intention. We want to take existing code and cut it into an initial 0.1 release.

    We want to publish a release v0.1 for Zerokit with a first ~~mature~~ version of the RLN module.

    Before that, it is desirable to clean-up the RLN module library code and implement different optimizations which are already standard in other libraries.

    These allow to: make the RLN module more efficient and easily integrable in projects employing the RLN primitive; bring a cleaner code and optimized cross-module primitives (e.g., Merkle trees) to new zerokit modules.

    Scope

    Release zerokit v0.1 with a RLN module that can replace and improve Kilic's RLN module currently employed by nwaku.

    Must have:

    • [x] Sanity check main features included / bug fixes included -- Err on side of not accepting more scope
    • [x] Release branch with release note and tag
    • [ ] Announce release on Discord and Twitter

    Initial list of issues, many nice to haves that can be dealt with separately:

    • [x] https://github.com/vacp2p/zerokit/issues/29
    • [ ] Maximize usage of only arkworks dependencies (e.g., replace Semaphore's Field with arkworks Fr, etc.) and remove unnecessary ones (might require adapting/integrating used primitives e.g. Poseidon hash)
      • [x] https://github.com/vacp2p/zerokit/issues/35
      • [ ] https://github.com/vacp2p/zerokit/pull/44
    • [ ] Eventually add/update APIs to address new needs resulting from completions of milestones in the RLN-RELAY track https://github.com/status-im/nwaku/issues/1062 or other tracks:
      • [ ] https://github.com/vacp2p/zerokit/pull/45 (contains https://github.com/vacp2p/zerokit/pull/36)
    • [ ] Reduce size of compiled libraries (might require partial refactoring of dependencies) https://github.com/vacp2p/zerokit/issues/37

    Acceptance criteria

    Issues defined in scope addressed.

    Risks and uncertainty

    Removing some dependencies (e.g. semaphore-rs) might result not trivial, since there might some implementation used across the code base that should be ported to the replacing dependencies.

    Out of scope

    This milestone's scope requires a RLN module which can replace (in terms of APIs and efficiency) Kilic's RLN module. However, integration of zerokit v0.1 in nwaku is out-of-scope and is tracked in https://github.com/status-im/nwaku/issues/1061.

    Notes and links

    This first issue partially overlaps with https://github.com/vacp2p/research/issues/127, where a thorough performance analysis of employing Incremental Merkle trees is performed. This milestone will clearly benefit from completion of https://github.com/vacp2p/research/issues/127, and new items will be added to the above issues list to implement any eventual optimization found.

    track:zerokit milestone 
    opened by s1fr0 4
  • Benchmarking using the inbuilt lib

    Benchmarking using the inbuilt lib

    As per the discussion here - https://github.com/vacp2p/zerokit/pull/86#discussion_r1044331978. When the benchmarking needs become more significant, we will use the inbuilt library or an alternative to benchmark to understand where the code can be optimized.

    opened by rymnc 0
  • Semaphore: module refactoring

    Semaphore: module refactoring

    Problem

    Currently, zerokit semaphore module implements wrappers around API exposed by semaphore-rs, a submodule of the semaphore crate.

    This doesn't allow the same flexibility and easy features extension currently allowed e.g., by the zerokit RLN module.

    Furthermore, using submodules makes hard to deal with any eventually breaking change introduced by submodule's dependencies, as happened in https://github.com/vacp2p/zerokit/pull/79. This results in a failing zerokit compilation and leaves few possibilities to solve such issue quickly without relying on forks and/or dependencies' developers response.

    Acceptance criteria

    • [ ] Refactor semaphore module similarly as the RLN module (public API, FFI, zk resources, MT implementation, etc.)
    track:zerokit 
    opened by s1fr0 0
  • Zerokit generalize API to allow for any Circom based proof

    Zerokit generalize API to allow for any Circom based proof

    Problem

    Currently we are doing special-purpose APIs for e.g. RLN. It'd be useful to factor out the general parts and allow and Circom-based circuits to be used through Zerokit.

    Context

    Obviously not doable for all APIs, but e.g. prove and verify + general format for inputs seems doable? Especially if it is using JSON or whatever for passing data.

    (This doesn't mean we shouldn't also have special purpose APIs that are useful for specific circuits).

    Acceptance criteria

    Some way of dealing with with generic Circom circuits (e.g. ones that the library doesn't know about!) to do basic prove and verify operations.

    track:zerokit 
    opened by oskarth 5
  • Zerokit/RLN Command Line API

    Zerokit/RLN Command Line API

    Problem

    As a dapp developer I'm required to know and deal with a lot of different runtimes/domains (JS/Circom/Solidity/Rust/ZK etc). Minimizing cognitive overhead would be useful.

    Context

    Also see https://github.com/vacp2p/zerokit/issues/69

    As well as https://book.getfoundry.sh/forge/tests for Foundry forge tool. Might make sense to "bundle" foundry or similar based scripts for interacting with smart contracts.

    Acceptance criteria

    • [ ] Proposal of MVP CLI API that allows for interacting with RLN - e.g. create groups, adding members, etc. -- separate out must have for MVP and nice to have future work
    track:zerokit track:rln 
    opened by oskarth 6
  • Standalone RLN docs and tutorial

    Standalone RLN docs and tutorial

    Problem

    As a developer, it isn't clear how to get started with RLN in Zerokit.

    Context

    Zerokit has multiple crates, where RLN is the most important one right now. Currently, usage of this is mostly aimed towards Waku usage, e.g. RLN Relay. There are many other uses for RLN too.

    E.g. see for example https://github.com/Rate-Limiting-Nullifier/rlnjs#usage

    Acceptance criteria

    • [ ] Basic documentation for how to use RLN in Zerokit.
    • [ ] To extent that API currently doesn't allow standalone usage, issues should be cut out and addressed
    track:zerokit track:rln 
    opened by oskarth 4
  • chore(utils): assert if root generated by Merkle tree implementations are the same

    chore(utils): assert if root generated by Merkle tree implementations are the same

    Background

    Tracking this issue based on https://github.com/vacp2p/zerokit/pull/67#discussion_r1019377045.

    Problem

    The roots generated by FullMerkleTree and OptimalMerkleTree should be the same.

    Acceptance Criteria

    • [ ] The test at https://github.com/vacp2p/zerokit/blob/master/rln/src/poseidon_tree.rs#L87 is updated with this assertion
    track:zerokit 
    opened by rymnc 0
Releases(nightly)
  • nightly(Dec 29, 2022)

    What's Changed

    • docs: Add CHANGELOG for v0.1 release by @oskarth in https://github.com/vacp2p/zerokit/pull/46
    • feat: wasm by @richard-ramos in https://github.com/vacp2p/zerokit/pull/38
    • chore: use cargo-make for building and publishing rln-wasm by @richard-ramos in https://github.com/vacp2p/zerokit/pull/48
    • ci: include wasm by @fryorcraken in https://github.com/vacp2p/zerokit/pull/54
    • Add GrainLFRS and PrimeField trait to Poseidon by @s1fr0 in https://github.com/vacp2p/zerokit/pull/51
    • Add utils module by @s1fr0 in https://github.com/vacp2p/zerokit/pull/53
    • feat(rln): add seeded keygen by @s1fr0 in https://github.com/vacp2p/zerokit/pull/56
    • fix(rln-wasm): expose verify_rln_proof instead of verify by @richard-ramos in https://github.com/vacp2p/zerokit/pull/58
    • fix(rln): fix order of inputs in comments by @s1fr0 in https://github.com/vacp2p/zerokit/pull/59
    • Initializes the private settlement package by @staheri14 in https://github.com/vacp2p/zerokit/pull/60
    • feat(RLN): Proof verification using provided roots by @s1fr0 in https://github.com/vacp2p/zerokit/pull/61
    • feat(rln-wasm): expose get_root and verify_with_roots by @richard-ramos in https://github.com/vacp2p/zerokit/pull/62
    • feat(rln): ability to set leaves from a given index by @rymnc in https://github.com/vacp2p/zerokit/pull/63
    • fix(rln): throw if attempting to insert out of bounds by @rymnc in https://github.com/vacp2p/zerokit/pull/67
    • feat(rln): publish rln artifacts nightly by @rymnc in https://github.com/vacp2p/zerokit/pull/72
    • fix(ci): exclude rln-wasm since it has its own step now by @rymnc in https://github.com/vacp2p/zerokit/pull/73
    • fix(rln-wasm): make cargo make build work on macOS and linux by @s1fr0 in https://github.com/vacp2p/zerokit/pull/77
    • feat(rln): add few serialization APIs to ease user interaction by @s1fr0 in https://github.com/vacp2p/zerokit/pull/75
    • refactor(zerokit): split test workflows per module by @s1fr0 in https://github.com/vacp2p/zerokit/pull/76
    • fix(semaphore): temporarily use fixed semaphore-rs fork by @s1fr0 in https://github.com/vacp2p/zerokit/pull/79
    • feat(rln): add example usage tutorial and expand documentation for RLN by @s1fr0 in https://github.com/vacp2p/zerokit/pull/74
    • feat(rln): add recover identity secret API by @s1fr0 in https://github.com/vacp2p/zerokit/pull/80
    • feat(wasm): expose seeded_key_gen by @richard-ramos in https://github.com/vacp2p/zerokit/pull/83
    • refactor(rln): update APIs after circuit update by @s1fr0 in https://github.com/vacp2p/zerokit/pull/84
    • feat(rln): add extended keygen APIs for Semaphore-compatible credentials by @s1fr0 in https://github.com/vacp2p/zerokit/pull/85
    • feat(rln): integrate pmtree for MT persistance by @s1fr0 in https://github.com/vacp2p/zerokit/pull/86
    • feat(wasm): add extended_key_gen, seeded_extended_key_gen and recover_id_secret by @richard-ramos in https://github.com/vacp2p/zerokit/pull/90

    New Contributors

    • @fryorcraken made their first contribution in https://github.com/vacp2p/zerokit/pull/54
    • @staheri14 made their first contribution in https://github.com/vacp2p/zerokit/pull/60
    • @rymnc made their first contribution in https://github.com/vacp2p/zerokit/pull/63

    Full Changelog: https://github.com/vacp2p/zerokit/compare/v0.1...nightly

    Source code(tar.gz)
    Source code(zip)
    browser-rln-wasm.tar.gz(231.64 KB)
    linux-rln.tar.gz(20.94 MB)
    macos-rln.tar.gz(18.21 MB)
  • v0.1(Sep 19, 2022)

    Initial beta release.

    This release contain:

    • RLN Module with API to manage, compute and verify RLN zkSNARK proofs and RLN primitives.
    • This can be consumed either as a Rust API or as a C FFI. The latter means it can be easily consumed through other environments, such as Go or Nim.

    It also contains the following examples and experiments:

    Feedback welcome! You can either open an issue or come talk to us in our Vac Discord #zerokit channel.

    Source code(tar.gz)
    Source code(zip)
Owner
vac
Modular p2p messaging stack, with a focus on secure messaging.
vac
A repository for showcasing my knowledge of the Rust programming language, and continuing to learn the language.

Learning Rust I started learning the Rust programming language before using GitHub, but increased its usage afterwards. I have found it to be a fast a

Sean P. Myrick V19.1.7.2 2 Nov 8, 2022
Operating system based off of blog_os, with the goal of running wasm modules as executables

yavkOS - A OS that attempts at running WASM modules as userspace programs Recommended Development Environment You need nix with the flakes, and nix-co

Yavor Kolev 12 Apr 1, 2023
A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace.

Zero-Width A turing-complete programming language using only zero-width unicode characters, inspired by brainfuck and whitespace. Currently a (possibl

Gavin M 2 Jan 14, 2022
In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang.

Learn Rust What is this? In this repository you can find modules with code and comments that explain rust syntax and all about Rust lang. This is usef

Domagoj Ratko 5 Nov 5, 2022
Mote is a systems-programming language designed to be practical, performant, and simple.

Mote NOTE: this following lists the goals for what Mote is supposed to be. It does not promise that any of the features here will be accomplished or a

The Mote Programming Language 14 Jul 28, 2021
Unify your game sources in one place and aquire more of them, using modules made by the community.

Project Black Pearl Unify your game sources in one place by using modules made by the community. What is Project Black Pearl? Project Black Pearl (or

Project Black Pearl 8 Jan 15, 2023
Crabzilla provides a simple interface for running JavaScript modules alongside Rust code.

Crabzilla Crabzilla provides a simple interface for running JavaScript modules alongside Rust code. Example use crabzilla::*; use std::io::stdin; #[i

Andy 14 Feb 19, 2022
A cargo plugin for showing a tree-like overview of a crate's modules.

cargo-modules Synopsis A cargo plugin for showing an overview of a crate's modules. Motivation With time, as your Rust projects grow bigger and bigger

Vincent Esche 445 Jan 3, 2023
OP-Up is a hive tool for testing OP-Stack-compatible software modules

op-up Warning This is a work in progress. OP-Up is a hive tool for testing OP-Stack-compatible software modules. This project was born out of the need

nicolas 20 Jun 13, 2023
A relatively simple puzzle generator application written in Rust and used via Javascript

Puzzlip Basic Overview This is a relatively simple puzzle generator application written in Rust and used via Javascript in https://puzzlip.com. If you

Nenad 5 Dec 7, 2022
Rust library for compiling and running other programs.

Exers ?? Exers is a rust library for compiling and running code in different languages and runtimes. Usage example fn main() { // Imports...

olix3001 5 Jun 10, 2023
Elton is a benchmark utility written in rust aimed to be used to benchmark HTTP calls.

Elton Elton is an HTTP Benchmark utility with options to be used within an HTTP interface. Installation Elton is currently available via Docker or by

Emil Priver 5 Sep 22, 2023
Compile-time stuff and other goodies for rustaceans 🦀

?? bagel: Always baked, never fried bagel is a collection of macros and other things that we frequently use at Skytable, primarily to get work done at

Skytable 3 Jul 4, 2022
Algebraic structures, higher-kinded types and other category theory bad ideas

Algar Algebric structures, higher-kinded types and other category theory bad ideas. Yes, you'll have generalized functors, applicatives, monads, trave

Stefano Candori 3 Jan 31, 2023
A mobile application platform for tertiary students to communicate, collaborate and share ideas with each other

Qreeket (pronounced "cricket") A mobile application platform for tertiary students to communicate, collaborate and share ideas with each other. As the

Quabynah Bilson Jr. 3 May 15, 2023
Elemental System Designs is an open source project to document system architecture design of popular apps and open source projects that we want to study

Elemental System Designs is an open source project to document system architecture design of popular apps and open source projects that we want to study

Jason Shin 9 Apr 10, 2022
Rust crates with map and set with interval keys (ranges x..y).

This crates implements map and set with interval keys (ranges x..y). IntervalMap is implemented using red-black binary tree, where each node contains

Timofey Prodanov 8 Aug 23, 2022
The Devils' Programming Language (Quantum Programming Language)

devilslang has roots in Scheme and ML-flavored languages: it's the culmination of everything I expect from a programming language, including the desire to keep everything as minimalistic and concise as possible. At its core, devilslang is lambda-calculus with pattern-matching, structural types, fiber-based concurrency, and syntactic extension.

Devils' Language 2 Aug 26, 2022