Fix kzg bench (#336)

This commit is contained in:
Daniel Sanchez 2023-08-29 13:27:52 +02:00 committed by GitHub
parent 115d45d0f0
commit 466cef7623
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 11 deletions

View File

@ -1,24 +1,23 @@
use criterion::{black_box, criterion_group, criterion_main, Criterion};
use kzg::{types::kzg_settings::FsKZGSettings, utils::generate_trusted_setup};
use kzg_traits::{FFTSettings, KZGSettings};
use nomos_kzg::Blob;
use nomos_kzg::{Blob, KzgSettings};
fn nomos_dynamic_vs_external(c: &mut Criterion) {
let (g1s, g2s) = generate_trusted_setup(4096, [0; 32]);
let fft_settings = kzg::types::fft_settings::FsFFTSettings::new(8).unwrap();
let settings = FsKZGSettings::new(&g1s, &g2s, 4096, &fft_settings).unwrap();
let blob = Blob::from_bytes(&[5; 4096 * 32]).unwrap();
let kzg_settings = KzgSettings {
settings: settings.clone(),
bytes_per_field_element: 32,
};
let data = [5; 4096 * 32];
let blob = Blob::from_bytes(&data, &kzg_settings).unwrap();
let mut group = c.benchmark_group("KZG Commitment Benchmarks");
group.bench_function("nomos blob commitment", |b| {
b.iter(|| {
nomos_kzg::blob_to_kzg_commitment(
black_box(&blob),
black_box(&settings),
black_box(4096),
)
})
b.iter(|| nomos_kzg::compute_commitment(black_box(&data), black_box(&kzg_settings)))
});
group.bench_function("external blob commitment", |b| {

View File

@ -1,8 +1,7 @@
mod dynamic_kzg;
mod types;
use crate::types::KzgSettings;
pub use crate::types::{Blob, Commitment, Proof};
pub use crate::types::{Blob, Commitment, KzgSettings, Proof};
pub use dynamic_kzg::{blob_to_kzg_commitment, compute_blob_kzg_proof, verify_blob_kzg_proof};
use std::error::Error;