Skip to content

Commit

Permalink
Refactor DAS implementation to support various trusted setup sizes / …
Browse files Browse the repository at this point in the history
…cell sizes
  • Loading branch information
ArtiomTr committed Nov 28, 2024
1 parent 7018ff3 commit c588164
Show file tree
Hide file tree
Showing 28 changed files with 2,033 additions and 2,354 deletions.
25 changes: 3 additions & 22 deletions blst/benches/eip_7594.rs
Original file line number Diff line number Diff line change
@@ -1,33 +1,14 @@
use criterion::{criterion_group, criterion_main, Criterion};
use kzg::{
eip_4844::{blob_to_kzg_commitment_rust, bytes_to_blob},
eip_7594::{
compute_cells_and_kzg_proofs, recover_cells_and_kzg_proofs, verify_cell_kzg_proof_batch,
},
};
use kzg::eip_4844::{blob_to_kzg_commitment_rust, bytes_to_blob};
use kzg_bench::benches::eip_7594::bench_eip_7594;
use rust_kzg_blst::{
eip_4844::load_trusted_setup_filename_rust,
types::{
fft_settings::FsFFTSettings,
fp::FsFp,
fr::FsFr,
g1::{FsG1, FsG1Affine},
g2::FsG2,
kzg_settings::FsKZGSettings,
poly::FsPoly,
},
};
use rust_kzg_blst::{eip_4844::load_trusted_setup_filename_rust, eip_7594::BlstBackend};

fn bench_eip_7594_(c: &mut Criterion) {
bench_eip_7594::<FsFr, FsG1, FsG2, FsPoly, FsFFTSettings, FsKZGSettings, FsFp, FsG1Affine>(
bench_eip_7594::<BlstBackend>(
c,
&load_trusted_setup_filename_rust,
&bytes_to_blob,
&blob_to_kzg_commitment_rust,
&compute_cells_and_kzg_proofs,
&recover_cells_and_kzg_proofs,
&verify_cell_kzg_proof_batch,
);
}

Expand Down
32 changes: 3 additions & 29 deletions blst/benches/fk_20.rs
Original file line number Diff line number Diff line change
@@ -1,43 +1,17 @@
use criterion::{criterion_group, criterion_main, Criterion};
use kzg_bench::benches::fk20::{bench_fk_multi_da, bench_fk_single_da};

use rust_kzg_blst::types::fft_settings::FsFFTSettings;
use rust_kzg_blst::eip_7594::BlstBackend;
use rust_kzg_blst::types::fk20_multi_settings::FsFK20MultiSettings;
use rust_kzg_blst::types::fk20_single_settings::FsFK20SingleSettings;
use rust_kzg_blst::types::fp::FsFp;
use rust_kzg_blst::types::fr::FsFr;
use rust_kzg_blst::types::g1::{FsG1, FsG1Affine};
use rust_kzg_blst::types::g2::FsG2;
use rust_kzg_blst::types::kzg_settings::FsKZGSettings;
use rust_kzg_blst::types::poly::FsPoly;
use rust_kzg_blst::utils::generate_trusted_setup;

fn bench_fk_single_da_(c: &mut Criterion) {
bench_fk_single_da::<
FsFr,
FsG1,
FsG2,
FsPoly,
FsFFTSettings,
FsKZGSettings,
FsFK20SingleSettings,
FsFp,
FsG1Affine,
>(c, &generate_trusted_setup)
bench_fk_single_da::<BlstBackend, FsFK20SingleSettings>(c, &generate_trusted_setup)
}

fn bench_fk_multi_da_(c: &mut Criterion) {
bench_fk_multi_da::<
FsFr,
FsG1,
FsG2,
FsPoly,
FsFFTSettings,
FsKZGSettings,
FsFK20MultiSettings,
FsFp,
FsG1Affine,
>(c, &generate_trusted_setup)
bench_fk_multi_da::<BlstBackend, FsFK20MultiSettings>(c, &generate_trusted_setup)
}

criterion_group! {
Expand Down
24 changes: 3 additions & 21 deletions blst/benches/kzg.rs
Original file line number Diff line number Diff line change
@@ -1,32 +1,14 @@
use criterion::{criterion_group, criterion_main, Criterion};
use kzg_bench::benches::kzg::{bench_commit_to_poly, bench_compute_proof_single};
use rust_kzg_blst::types::fft_settings::FsFFTSettings;
use rust_kzg_blst::types::fp::FsFp;
use rust_kzg_blst::types::fr::FsFr;
use rust_kzg_blst::types::g1::{FsG1, FsG1Affine};
use rust_kzg_blst::types::g2::FsG2;
use rust_kzg_blst::types::kzg_settings::FsKZGSettings;
use rust_kzg_blst::types::poly::FsPoly;
use rust_kzg_blst::eip_7594::BlstBackend;
use rust_kzg_blst::utils::generate_trusted_setup;

fn bench_commit_to_poly_(c: &mut Criterion) {
bench_commit_to_poly::<FsFr, FsG1, FsG2, FsPoly, FsFFTSettings, FsKZGSettings, FsFp, FsG1Affine>(
c,
&generate_trusted_setup,
)
bench_commit_to_poly::<BlstBackend>(c, &generate_trusted_setup)
}

fn bench_compute_proof_single_(c: &mut Criterion) {
bench_compute_proof_single::<
FsFr,
FsG1,
FsG2,
FsPoly,
FsFFTSettings,
FsKZGSettings,
FsFp,
FsG1Affine,
>(c, &generate_trusted_setup)
bench_compute_proof_single::<BlstBackend>(c, &generate_trusted_setup)
}

criterion_group! {
Expand Down
4 changes: 2 additions & 2 deletions blst/src/data_availability_sampling.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use alloc::string::String;
use alloc::vec::Vec;
use core::cmp::Ordering;

use kzg::{Fr, DAS};
use kzg::{DASExtension, Fr};

use crate::types::fft_settings::FsFFTSettings;
use crate::types::fr::FsFr;
Expand Down Expand Up @@ -71,7 +71,7 @@ impl FsFFTSettings {
}
}

impl DAS<FsFr> for FsFFTSettings {
impl DASExtension<FsFr> for FsFFTSettings {
/// Polynomial extension for data availability sampling. Given values of even indices, produce values of odd indices.
/// FFTSettings must hold at least 2 times the roots of provided evens.
/// The resulting odd indices make the right half of the coefficients of the inverse FFT of the combined indices zero.
Expand Down
Loading

0 comments on commit c588164

Please sign in to comment.