MCPcopy Index your code
hub / github.com/EspressoSystems/jellyfish

github.com/EspressoSystems/jellyfish @jf-poseidon2-v0.2.0

Chat with this repo
repository ↗ · DeepWiki ↗ · release jf-poseidon2-v0.2.0 ↗ · + Follow
1,674 symbols 5,591 edges 144 files 638 documented · 38% updated 2d ago0.1.2 · 2022-06-22★ 51679 open issues
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

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.

Crates

Helper

Primitives

  • jf-prf: trait definitions for pseudorandom function (PRF).
  • jf-crhf: trait definitions for collision-resistant hash function (CRHF).
  • jf-commitment: trait definitions for cryptographic commitment scheme.
  • jf-rescue: Rescue hash function, and its subsequent PRF, CRHF, commitment scheme implementations.
  • jf-elgamal: a Rescue-based ElGamal encryption scheme implementation.
  • jf-signature: signature scheme trait definition, and BLS/Schnorr signature scheme implementations.
  • jf-vrf: verifiable random function trait definition and BLS-based implementation.
  • jf-aead: authenticated encryption with associated data (AEAD) implementation.
  • jf-merkle-tree: various (vanilla, sparse, namespaced) Merkle tree trait definitions and implementations.
  • jf-pcs: polynomial commitment scheme (PCS) trait definitions and univariate/multilinear KZG-PCS implementations.
  • jf-vid: verifiable information dispersal (VID) trait definition and implementation.
  • jf-poseidon2: Poseidon2 permutation, and Sponge, CRHF, derived from this permutation.

Plonk

  • jf-relation: Jellyfish constraint system for PLONK.
  • jf-plonk: KZG-PCS based TurboPlonk and UltraPlonk implementations.

Development environment setup

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, run tests and examples

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.

WASM target

Jellyfish is no_std compliant and compilable to WASM target environment, just run:

./scripts/build_wasm.sh

Backends

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"'

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.

Git Hooks

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

pre-commit run --all-files

Extension points exported contracts — how you extend this code

Gate (Interface)
Describes a gate with getter for all selectors configuration [25 implementers]
relation/src/gates/mod.rs
RescueParameter (Interface)
This trait defines constants that are used for rescue hash functions. [7 implementers]
rescue/src/lib.rs
CRHF (Interface)
A trait for CRHF (based on ark-primitives' definition, but self-declared for minimal dependency and easier future upgrad [4 …
crhf/src/lib.rs
DigestAlgorithm (Interface)
Merkle tree hash function WARN: it's important to domain separate the two digest functions. Otherwise, you may suffer fr [4 …
merkle_tree/src/lib.rs
StructuredReferenceString (Interface)
API definitions for structured reference string [3 implementers]
pcs/src/lib.rs
PlonkTranscript (Interface)
Defines transcript APIs. It has an associated type `F` which defines the native field for the snark circuit. The trans [3 …
plonk/src/transcript/mod.rs
SignatureScheme (Interface)
Trait definition for a signature scheme. A signature scheme is associated with a hash function H that is to be used for [3 …
signature/src/lib.rs
MaybeGPU (Interface)
A helper trait that cover API that maybe instantiated using GPU code in specialized implementation for concrete types [2 …
vid/src/advz.rs

Core symbols most depended-on inside this repo

push
called by 271
plonk/src/proof_system/structs.rs
create_variable
called by 250
relation/src/constraint_system.rs
clone
called by 136
relation/src/gates/mod.rs
len
called by 136
rescue/src/lib.rs
len
called by 133
plonk/src/proof_system/structs.rs
witness_mut
called by 132
relation/src/constraint_system.rs
witness
called by 125
relation/src/gadgets/ultraplonk/mod_arith.rs
as_ref
called by 101
pcs/src/structs.rs

Shape

Method 815
Function 622
Class 167
Interface 54
Enum 16

Languages

Rust100%

Modules by API surface

relation/src/constraint_system.rs137 symbols
relation/src/gadgets/ecc/mod.rs59 symbols
rescue/src/gadgets/native.rs53 symbols
relation/src/gadgets/ultraplonk/mod_arith.rs50 symbols
pcs/src/univariate_kzg/mod.rs48 symbols
rescue/src/lib.rs46 symbols
rescue/src/gadgets/non_native.rs45 symbols
signature/src/bls_over_bn254.rs38 symbols
relation/src/gadgets/emulated.rs37 symbols
plonk/src/proof_system/structs.rs37 symbols
relation/src/gadgets/arithmetic.rs35 symbols
signature/src/schnorr.rs33 symbols

For agents

$ claude mcp add jellyfish \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact

Ask about this repo answers extend the page