zhenfeizhang / jellyfish

A Rust Implementation of the PLONK ZKP System and Extensions

Home Page:https://jellyfish.docs.espressosys.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Jellyfish cryptographic library

example workflow Crates.io (version) GitHub

Disclaimer

DISCLAIMER: This software is provided "as is" and its security has not been externally audited. Use at your own risk.

Chatroom

For general discussions on Jellyfish PLONK, please join our Discord channel.

Development environment setup

Install RUST

We recommend to use nix for installing the correct version of rust and additional libraries:

> curl -L https://nixos.org/nix/install | sh
> . ~/.nix-profile/etc/profile.d/nix.sh

Compiling the project for the first time

> nix-shell
> cargo build

Direnv

To avoid manually activating the nix shell each time the direnv shell extension can be used to activate the environment when entering the local directory with the checkout of this repo. Note that direnv needs to be installed first, and to be hooked into the shell to function.

To allow direnv for this repo run

direnv allow

from within the local checkout of this repo.

Git Hooks

The pre-commit hooks are installed via the nix shell. To run them on all files use

> pre-commit run --all-files

Get start

> cargo run --release --example proof_of_exp

This is a simple example to prove and verify knowledge of exponent. It shows how one may compose a circuit, and then build a proof for the circuit.

Tests

> cargo test --release

Note that by default the release mode does not check integers overflow. In order to enforce this check run:

> ./scripts/run_tests.sh

Test coverage

We use grcov for test coverage

> ./scripts/test_coverage.sh

Generate and read the documentation

Standard

> cargo doc --open

Code formatting

To format your code run

> cargo fmt

Updating non-cargo dependencies

Run nix flake update if you would like to pin other version edit flake.nix beforehand. Commit the lock file when happy.

To update only a single input specify it as argument, for example

nix flake update github:oxalica/rust-overlay

Benchmarks

Primitives

Currently, a benchmark for verifying Merkle paths is implemented. The additional flags allow using assembly implementation of square_in_place and mul_assign within arkworks:

> RUSTFLAGS='-Ctarget-cpu=native -Ctarget-feature=+bmi2,+adx' cargo bench --bench=merkle_path

PLONK proof generation/verification

For benchmark, run:

RAYON_NUM_THREADS=N cargo bench

where N is the number of threads you want to use (N = 1 for single-thread).

A sample benchmark result is available under bench.md.

About

A Rust Implementation of the PLONK ZKP System and Extensions

https://jellyfish.docs.espressosys.com

License:MIT License


Languages

Language:Rust 99.4%Language:Shell 0.3%Language:Nix 0.3%