Skip to content

Layr-Labs/rust-kzg-bn254

Repository files navigation

rust-kzg-bn254

Description

This library offers a set of functions for generating and interacting with bn254 KZG commitments and proofs in rust, with the motivation of supporting fraud and validity proof logic in EigenDA rollup integrations.

Crates

This repository is organized as a Rust workspace with three main crates:

Docs Crate

Provides the fundamental data structures and operations:

  • Blob: Data representation with conversion methods
  • Polynomial: Support for both evaluation and coefficient forms
  • Various arithmetic and helper functions

Docs Crate

Implements KZG commitment and proof generation:

  • KZG: Main struct for creating commitments and generating proofs
  • SRS: Structured Reference String handling
  • Optimized parallel FFT implementations

Docs Crate

Provides verification functions:

  • Single proof verification
  • Batch verification for improved efficiency

Getting Started

For a complete end-to-end example, see the test_compute_kzg_proof function in prover/tests/kzg_test.rs.

Building and Benchmark

# Build all crates
cargo build

# Run benchmarks
cargo bench

Compatibility

  1. The project is compatible with Rust 1.75 or later

Downstream Dependencies

  1. Arbitrum Nitro uses rust 1.78
  2. RiscZero ZKVM uses 1.85
  3. SP1 ZKVM uses 1.79

Notes on testing

If you encounter issue running tests and it fails with the following error:

error: package `half v2.5.0` cannot be built because it requires rustc 1.81 or newer, while the currently active rustc version is 1.75.0

then run cargo update half --precise 2.4.1 to downgrade this transitive dependency to a lower version that works with our MSRV. This issue can be permanently solved when this rust RFC is implemented.

Crates Releases

Releasing a crate is done by creating a PR (see this example) that bumps the version in Cargo.toml and then manually dispatching the crates-release-prod.yml workflow. This will publish the new version to crates.io.

Warning & Disclaimer

This code is unaudited and under construction. This is experimental software and is provided on an "as is" and "as available" basis. It may not work as expected and should not be used in production environments.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 9

Languages