Skip to content

Commit

Permalink
moving to prover and verifier crates
Browse files Browse the repository at this point in the history
  • Loading branch information
anupsv committed Jan 28, 2025
1 parent e8f1128 commit c219091
Show file tree
Hide file tree
Showing 29 changed files with 300 additions and 286 deletions.
18 changes: 16 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
[workspace]
members = [
"batch",
"kzg", "primitives",
"verifier",
"prover",
"primitives",
]
resolver = "2"

Expand Down Expand Up @@ -39,3 +40,16 @@ 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


1 change: 0 additions & 1 deletion batch/src/lib.rs

This file was deleted.

182 changes: 0 additions & 182 deletions kzg/tests/kzg_test.rs

This file was deleted.

7 changes: 1 addition & 6 deletions kzg/Cargo.toml → prover/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "rust-kzg-bn254"
name = "rust-kzg-bn254-prover"
version = "0.1.0"
edition.workspace = true
rust-version.workspace = true
Expand Down Expand Up @@ -59,8 +59,3 @@ path = "benches/bench_kzg_commit_large_blobs.rs"
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"
File renamed without changes.
20 changes: 10 additions & 10 deletions kzg/benches/bench_g1_ifft.rs → prover/benches/bench_g1_ifft.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use rust_kzg_bn254::{kzg::KZG, srs::SRS};
use rust_kzg_bn254_prover::{kzg::KZG, srs::SRS};
use std::time::Duration;

fn generate_powers_of_2(limit: u64) -> Vec<usize> {
Expand All @@ -16,17 +16,17 @@ fn generate_powers_of_2(limit: u64) -> Vec<usize> {

fn bench_g1_ifft(c: &mut Criterion) {
c.bench_function("bench_g1_ifft", |b| {
let kzg = KZG::new(
SRS::new(
"tests/test-files/mainnet-data/g1.131072.point",
268435456,
131072,
)
.unwrap(),
);
let kzg = KZG::new();
let srs = SRS::new(
"tests/test-files/mainnet-data/g1.131072.point",
268435456,
131072,
)
.unwrap();

b.iter(|| {
for power in &generate_powers_of_2(3000) {
kzg.g1_ifft(black_box(*power)).unwrap();
kzg.g1_ifft(black_box(*power), &srs).unwrap();
}
});
});
Expand Down
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
use criterion::{criterion_group, criterion_main, Criterion};
use rand::Rng;
use rust_kzg_bn254::{blob::Blob, kzg::KZG, srs::SRS};
use rust_kzg_bn254_primitives::blob::Blob;
use rust_kzg_bn254_prover::{kzg::KZG, srs::SRS};
use std::time::Duration;

fn bench_kzg_commit(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let mut kzg = KZG::new(
SRS::new(
"tests/test-files/mainnet-data/g1.131072.point",
268435456,
131072,
)
.unwrap(),
);
let mut kzg = KZG::new();
let srs = SRS::new(
"tests/test-files/mainnet-data/g1.32mb.point",
268435456,
524288,
)
.unwrap();

c.bench_function("bench_kzg_commit_10000", |b| {
let random_blob: Vec<u8> = (0..10000).map(|_| rng.gen_range(32..=126) as u8).collect();
let input = Blob::from_raw_data(&random_blob);
let input_poly = input.to_polynomial_coeff_form();
kzg.calculate_and_store_roots_of_unity(input.len().try_into().unwrap())
.unwrap();
b.iter(|| kzg.commit_coeff_form(&input_poly).unwrap());
b.iter(|| kzg.commit_coeff_form(&input_poly, &srs).unwrap());
});

c.bench_function("bench_kzg_commit_30000", |b| {
Expand All @@ -29,7 +29,7 @@ fn bench_kzg_commit(c: &mut Criterion) {
let input_poly = input.to_polynomial_coeff_form();
kzg.calculate_and_store_roots_of_unity(input.len().try_into().unwrap())
.unwrap();
b.iter(|| kzg.commit_coeff_form(&input_poly).unwrap());
b.iter(|| kzg.commit_coeff_form(&input_poly, &srs).unwrap());
});

c.bench_function("bench_kzg_commit_50000", |b| {
Expand All @@ -38,7 +38,7 @@ fn bench_kzg_commit(c: &mut Criterion) {
let input_poly = input.to_polynomial_coeff_form();
kzg.calculate_and_store_roots_of_unity(input.len().try_into().unwrap())
.unwrap();
b.iter(|| kzg.commit_coeff_form(&input_poly).unwrap());
b.iter(|| kzg.commit_coeff_form(&input_poly, &srs).unwrap());
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
use criterion::{criterion_group, criterion_main, Criterion};
use rand::Rng;
use rust_kzg_bn254::{blob::Blob, kzg::KZG, srs::SRS};
use rust_kzg_bn254_primitives::blob::Blob;
use rust_kzg_bn254_prover::{kzg::KZG, srs::SRS};
use std::time::Duration;

fn bench_kzg_commit(c: &mut Criterion) {
let mut rng = rand::thread_rng();
let mut kzg = KZG::new(
SRS::new(
"tests/test-files/mainnet-data/g1.32mb.point",
268435456,
524288,
)
.unwrap(),
);
let mut kzg = KZG::new();
let srs = SRS::new(
"tests/test-files/mainnet-data/g1.32mb.point",
268435456,
524288,
)
.unwrap();

c.bench_function("bench_kzg_commit_8mb", |b| {
let random_blob: Vec<u8> = (0..8000000)
Expand All @@ -22,7 +22,7 @@ fn bench_kzg_commit(c: &mut Criterion) {
let input_poly = input.to_polynomial_coeff_form();
kzg.calculate_and_store_roots_of_unity(input.len().try_into().unwrap())
.unwrap();
b.iter(|| kzg.commit_coeff_form(&input_poly).unwrap());
b.iter(|| kzg.commit_coeff_form(&input_poly, &srs).unwrap());
});

c.bench_function("bench_kzg_commit_16mb", |b| {
Expand All @@ -33,7 +33,7 @@ fn bench_kzg_commit(c: &mut Criterion) {
let input_poly = input.to_polynomial_coeff_form();
kzg.calculate_and_store_roots_of_unity(input.len().try_into().unwrap())
.unwrap();
b.iter(|| kzg.commit_coeff_form(&input_poly).unwrap());
b.iter(|| kzg.commit_coeff_form(&input_poly, &srs).unwrap());
});
}

Expand Down
Loading

0 comments on commit c219091

Please sign in to comment.