Skip to content

Commit

Permalink
moving to workspaces, splitting tests, other things
Browse files Browse the repository at this point in the history
  • Loading branch information
anupsv committed Jan 27, 2025
1 parent 01b3f0b commit 95d9a0a
Show file tree
Hide file tree
Showing 43 changed files with 752 additions and 681 deletions.
101 changes: 11 additions & 90 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,100 +1,21 @@
[package]
name = "rust-kzg-bn254"
version = "0.2.1"
edition = "2021"
authors = ["Anup Swamy Veena", "Teddy Knox"]
rust-version = "1.81"
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."
readme = "README.md"
repository = "https://github.com/Layr-Labs/rust-kzg-bn254"
license-file = "LICENSE"
exclude = ["tests/*", "benches/*"]
# TODO: is this needed for the image to show up in the rust docs?
include = ["./kzg_commitment_diagram.png"]

[dependencies]
ark-bn254 = "0.5.0"
ark-ec = { version = "0.5.0", features = ["parallel"] }
ark-ff = { version = "0.5.0", features = ["parallel"] }
ark-serialize = "0.5.0"
ark-std = { version = "0.5.0", features = ["parallel"] }
directories = "5.0.1"
hex-literal = "0.4.1"
rand = "0.8.5"
sha2 = "0.10.8"
ureq = "2.12.1"
num-bigint = "0.4"
rayon = "1.10"
num-traits = "0.2"
byteorder = "1.5"
ark-poly = { version = "0.5.0", features = ["parallel"] }
crossbeam-channel = "0.5"
num_cpus = "1.16.0"
sys-info = "0.9"
itertools = "0.13.0"
[workspace]
members = [
"batch",
"kzg", "primitives",
]
resolver = "2"

[workspace.dependencies]
thiserror = "2.0.10"

[dev-dependencies]
criterion = "0.5"
lazy_static = "1.5"
tracing = { version = "0.1.41", features = ["log"] }
tracing-subscriber = "0.3.19"

[[test]]
name = "kzg"
path = "tests/kzg_test.rs"

[[test]]
name = "blob"
path = "tests/blob_test.rs"

[[test]]
name = "polynomial"
path = "tests/polynomial_test.rs"

[[test]]
name = "helpers"
path = "tests/helpers_test.rs"

[[bench]]
name = "bench_g1_ifft"
harness = false
path = "benches/bench_g1_ifft.rs"


[[bench]]
name = "bench_kzg_setup"
harness = false
path = "benches/bench_kzg_setup.rs"

[[bench]]
name = "bench_kzg_commit"
harness = false
path = "benches/bench_kzg_commit.rs"

[[bench]]
name = "bench_kzg_commit_large_blobs"
harness = false
path = "benches/bench_kzg_commit_large_blobs.rs"

[[bench]]
name = "bench_kzg_proof"
harness = false
path = "benches/bench_kzg_proof.rs"

[[bench]]
name = "bench_kzg_verify"
harness = false
path = "benches/bench_kzg_verify.rs"

[profile.bench]
opt-level = 3
debug = false
strip = "none"
debug-assertions = false
overflow-checks = false
lto = false
panic = 'unwind'
panic = 'abort'
incremental = false
codegen-units = 16
rpath = false
Expand All @@ -106,7 +27,7 @@ strip = "none"
debug-assertions = false
overflow-checks = false
lto = false
panic = 'unwind'
panic = 'abort'
incremental = false
codegen-units = 16
rpath = false
rpath = false
20 changes: 20 additions & 0 deletions batch/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
[package]
name = "rust-kzg-bn254-batch-verification"
version = "0.1.0"
edition = "2021"

[dependencies]
rust-kzg-bn254-primitives = { path = "../primitives", version = "0.1.0" }
ark-bn254 = "0.5.0"
ark-ec = { version = "0.5.0", features = ["parallel"] }
ark-ff = { version = "0.5.0", features = ["parallel"] }
ark-serialize = "0.5.0"

[dev-dependencies]
rand = "0.8.5"
criterion = "0.5"
lazy_static = "1.5"
tracing = { version = "0.1.41", features = ["log"] }
tracing-subscriber = "0.3.19"
ark-std = { version = "0.5.0", features = ["parallel"] }
rust-kzg-bn254 = { path = "../kzg", version = "0.1.0" }
9 changes: 9 additions & 0 deletions batch/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# rust-kzg-bn254-batch-verification

[![Crate](https://img.shields.io/crates/v/rust-kzg-bn254.svg)](https://crates.io/crates/rust-kzg-bn254-batch-verification)

This library offers batch verification functions for KZG.

## Warning & Disclaimer

This code is unaudited and under construction. This is experimental software and is provided on an "as is" and "as available" basis and may not work at all. It should not be used in production.
11 changes: 5 additions & 6 deletions src/batch.rs → batch/src/batch.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
use crate::{
use ark_bn254::{Fr, G1Affine, G1Projective, G2Affine, G2Projective};
use ark_ec::{AffineRepr, CurveGroup};
use ark_ff::{BigInteger, PrimeField};
use ark_serialize::CanonicalSerialize;
use rust_kzg_bn254_primitives::{
blob::Blob,
consts::{BYTES_PER_FIELD_ELEMENT, G2_TAU, RANDOM_CHALLENGE_KZG_BATCH_DOMAIN},
errors::KzgError,
helpers::{self, is_on_curve_g1},
};

use ark_bn254::{Fr, G1Affine, G1Projective, G2Affine, G2Projective};
use ark_ec::{AffineRepr, CurveGroup};
use ark_ff::{BigInteger, PrimeField};
use ark_serialize::CanonicalSerialize;

/// Ref: https://github.com/ethereum/consensus-specs/blob/master/specs/deneb/polynomial-commitments.md#verify_blob_kzg_proof_batch
pub fn verify_blob_kzg_proof(
blobs: &[Blob],
Expand Down
1 change: 1 addition & 0 deletions batch/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod batch;
Loading

0 comments on commit 95d9a0a

Please sign in to comment.