DISCLAIMER: This software is provided "as is" and its security has not been externally audited. Use at your own risk.
For general discussions on Jellyfish PLONK, please join our Discord channel.
We recommend the following tools:
Run direnv allow
at the repo root. You should see dependencies (including Rust) being installed.
Alternatively, enter the nix-shell manually via nix develop
.
You can check you are in the correct development environment by running which cargo
, which should print
something like /nix/store/2gb31jhahrm59n3lhpv1lw0wfax9cf9v-rust-minimal-1.69.0/bin/cargo
;
and running echo $CARGO_HOME
should print ~/.cargo-nix
.
Build:
cargo build
Run an example:
cargo run --release --example proof-of-exp --features test-srs
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.
Jellyfish is no_std
compliant and compilable to WASM target environment, just run:
./scripts/build_wasm.sh
To choose different backends for arithmetics of curve25519-dalek
, which is currently
used by jf-primitives/aead
, set the environment variable:
RUSTFLAGS='--cfg curve25519_dalek_backend="BACKEND"'
See the full list of backend options here.
You could further configure the word size for the backend by setting (see here):
RUSTFLAGS='--cfg curve25519_dalek_bits="SIZE"'
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
We use grcov for test coverage
./scripts/test_coverage.sh
cargo doc --open
To format your code run
cargo fmt
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
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
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
.
The pre-commit hooks are installed via the nix shell. To run them on all files use
pre-commit run --all-files