Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Splitting to Multiple files and Optimizing #43

Merged
merged 18 commits into from
Jan 30, 2025
Merged
Show file tree
Hide file tree
Changes from 14 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,14 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just moving to hash here to make it more safer.

- name: Build
run: cargo build --verbose
- name: Fmt check
run: cargo fmt --all -- --check
- name: Clippy Format test
run: cargo clippy --all --manifest-path Cargo.toml -- -D warnings
- name: Run tests
run: cargo test --verbose
- name: Run tests with mainnet data
run: KZG_ENV=mainnet-data cargo test --verbose
- name: Fmt check
run: cargo fmt --all -- --check


113 changes: 28 additions & 85 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,91 +1,20 @@
[package]
name = "rust-kzg-bn254"
version = "0.2.1"
[workspace]
members = [
"verifier",
"prover",
"primitives",
]
resolver = "2"

[workspace.dependencies]
thiserror = "2.0.11"

[workspace.package]
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"
homepage = ""
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"
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
Expand All @@ -94,7 +23,7 @@ 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 +35,21 @@ strip = "none"
debug-assertions = false
overflow-checks = false
lto = false
panic = 'abort'
incremental = false
codegen-units = 16
rpath = false

[profile.release]
opt-level = 3
debug = false
strip = "none"
debug-assertions = false
overflow-checks = false
lto = true
panic = 'unwind'
incremental = false
codegen-units = 16
rpath = false


33 changes: 33 additions & 0 deletions primitives/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
[package]
name = "rust-kzg-bn254-primitives"
version = "0.1.0"
edition.workspace = true
repository.workspace = true
license-file.workspace = true

[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"] }
ark-poly = { version = "0.5.0", features = ["parallel"] }
sha2 = "0.10.8"
crossbeam-channel = "0.5"
num-traits = "0.2"
thiserror = "2.0.11"

[dev-dependencies]
rand = "0.8.5"

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

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

[[test]]
name = "helpers"
path = "tests/helpers_test.rs"
9 changes: 9 additions & 0 deletions primitives/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# rust-kzg-bn254-primitives

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

This library offers primitive set of structures and functions for generating and interacting with bn254 KZG commitments and proofs in rust.

## 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.
File renamed without changes.
File renamed without changes.
15 changes: 2 additions & 13 deletions src/consts.rs → primitives/src/consts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,18 +51,7 @@ pub const PRIMITIVE_ROOTS_OF_UNITY: [Fr; 29] = [
MontFp!("19103219067921713944291392827692070036145651957329286315305642004821462161904"),
];

pub const G2_TAU_FOR_TEST_SRS_3000: G2Affine = G2Affine::new_unchecked(
Fq2::new(
MontFp!("7912312892787135728292535536655271843828059318189722219035249994421084560563"),
MontFp!("21039730876973405969844107393779063362038454413254731404052240341412356318284"),
),
Fq2::new(
MontFp!("18697407556011630376420900106252341752488547575648825575049647403852275261247"),
MontFp!("7586489485579523767759120334904353546627445333297951253230866312564920951171"),
),
);

pub const G2_TAU_FOR_MAINNET_SRS: G2Affine = G2Affine::new_unchecked(
pub const G2_TAU: G2Affine = G2Affine::new_unchecked(
Fq2::new(
MontFp!("19394299006376106554626551996044114846855237028623244664226757033024550999552"),
MontFp!("10478571113809844268398751534081669357808742555529167819607714577862447855483"),
Expand All @@ -73,5 +62,5 @@ pub const G2_TAU_FOR_MAINNET_SRS: G2Affine = G2Affine::new_unchecked(
),
);

// This is the G2 Tau for the MAINNET SRS points.
// This is the G2 Tau for the EigenDA MAINNET SRS points.
pub const MAINNET_SRS_G1_SIZE: usize = 131072;
File renamed without changes.
Loading