Skip to content

Commit

Permalink
ran cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
MatasSvarlys committed Nov 21, 2024
1 parent 04cd0e1 commit d14d5b3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 30 deletions.
4 changes: 3 additions & 1 deletion arkworks3/benches/fk_20.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use criterion::{criterion_group, criterion_main, Criterion};
use kzg_bench::benches::fk20::{bench_fk_multi_da, bench_fk_single_da};
use rust_kzg_arkworks3::fk20_proofs::{KzgFK20MultiSettings, KzgFK20SingleSettings};
use rust_kzg_arkworks3::kzg_proofs::{generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings};
use rust_kzg_arkworks3::kzg_proofs::{
generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings,
};
use rust_kzg_arkworks3::kzg_types::{ArkFp, ArkFr, ArkG1, ArkG1Affine, ArkG2};
use rust_kzg_arkworks3::utils::PolyData;

Expand Down
4 changes: 3 additions & 1 deletion arkworks3/benches/kzg.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
use criterion::{criterion_group, criterion_main, Criterion};
use kzg_bench::benches::kzg::{bench_commit_to_poly, bench_compute_proof_single};

use rust_kzg_arkworks3::kzg_proofs::{generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings};
use rust_kzg_arkworks3::kzg_proofs::{
generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings,
};
use rust_kzg_arkworks3::kzg_types::{ArkFp, ArkFr, ArkG1, ArkG1Affine, ArkG2};
use rust_kzg_arkworks3::utils::PolyData;

Expand Down
19 changes: 13 additions & 6 deletions arkworks3/src/fft_g1.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::kzg_proofs::LFFTSettings;
use crate::kzg_types::{ArkFr, ArkG1};
use crate::kzg_types::{ArkFp, ArkG1Affine};
use crate::kzg_types::ArkG1ProjAddAffine;
use crate::kzg_types::{ArkFp, ArkG1Affine};
use crate::kzg_types::{ArkFr, ArkG1};

use kzg::msm::msm_impls::msm;

Expand Down Expand Up @@ -55,7 +55,7 @@ pub fn g1_linear_combination(
points,
scalars,
len,
precomputation
precomputation,
);
}
}
Expand Down Expand Up @@ -146,14 +146,21 @@ pub fn fft_g1_fast(

#[cfg(not(feature = "parallel"))]
{
fft_g1_fast(&mut ret[..half], data, stride * 2, roots, roots_stride * 2, 1);
fft_g1_fast(
&mut ret[..half],
data,
stride * 2,
roots,
roots_stride * 2,
1,
);
fft_g1_fast(
&mut ret[half..],
&data[stride..],
stride * 2,
roots,
roots_stride * 2,
1
1,
);
}

Expand All @@ -165,4 +172,4 @@ pub fn fft_g1_fast(
} else {
ret[0] = data[0];
}
}
}
4 changes: 2 additions & 2 deletions arkworks3/src/kzg_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
extern crate alloc;
use crate::kzg_types::{ArkFp, ArkFr, ArkG1Affine};
use crate::kzg_types::{ArkFr as BlstFr, ArkG1, ArkG2};
use alloc::sync::Arc;
use ark_bls12_381::Bls12_381;
use ark_ec::PairingEngine;
use alloc::sync::Arc;
use ark_ec::ProjectiveCurve;
use ark_std::One;
use kzg::eip_4844::hash_to_bls_field;
Expand Down Expand Up @@ -83,4 +83,4 @@ pub fn pairings_verify(a1: &ArkG1, a2: &ArkG2, b1: &ArkG1, b2: &ArkG2) -> bool {
(ark_b1.into(), ark_b2.into()),
])
.is_one()
}
}
31 changes: 15 additions & 16 deletions arkworks3/src/kzg_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,34 @@ pub use crate::kzg_proofs::{expand_root_of_unity, pairings_verify, LFFTSettings,
// use crate::poly::{poly_fast_div, poly_inverse, poly_long_div, poly_mul_direct, poly_mul_fft};
use crate::recover::{scale_poly, unscale_poly};
use crate::utils::{
blst_fp_into_pc_fq, blst_p1_into_pc_g1projective, blst_p2_into_pc_g2projective, pc_g1projective_into_blst_p1, pc_g2projective_into_blst_p2, PolyData
blst_fp_into_pc_fq, blst_p1_into_pc_g1projective, blst_p2_into_pc_g2projective,
pc_g1projective_into_blst_p1, pc_g2projective_into_blst_p2, PolyData,
};
use crate::P2;
use ark_bls12_381::{g1, g2, G1Affine};
use ark_ec::{AffineCurve, ModelParameters};
use ark_ec::{models::short_weierstrass_jacobian::GroupProjective, ProjectiveCurve};
use ark_ec::{AffineCurve, ModelParameters};
use ark_ff::{BigInteger, Field};
use ark_std::{One, Zero};
use std::ops::{AddAssign, Sub};
use blst::{
blst_bendian_from_scalar, blst_fp, blst_fp2, blst_fr, blst_fr_add, blst_fr_cneg, blst_fr_eucl_inverse, blst_fr_from_scalar, blst_fr_from_uint64, blst_fr_inverse, blst_fr_mul, blst_fr_sqr, blst_fr_sub, blst_p1, blst_p1_affine, blst_p1_compress, blst_p1_from_affine, blst_p1_in_g1, blst_p1_uncompress, blst_p2, blst_p2_affine, blst_p2_from_affine, blst_p2_uncompress, blst_scalar, blst_scalar_fr_check, blst_scalar_from_bendian, blst_scalar_from_fr, blst_uint64_from_fr, BLST_ERROR
blst_bendian_from_scalar, blst_fp, blst_fp2, blst_fr, blst_fr_add, blst_fr_cneg,
blst_fr_eucl_inverse, blst_fr_from_scalar, blst_fr_from_uint64, blst_fr_inverse, blst_fr_mul,
blst_fr_sqr, blst_fr_sub, blst_p1, blst_p1_affine, blst_p1_compress, blst_p1_from_affine,
blst_p1_in_g1, blst_p1_uncompress, blst_p2, blst_p2_affine, blst_p2_from_affine,
blst_p2_uncompress, blst_scalar, blst_scalar_fr_check, blst_scalar_from_bendian,
blst_scalar_from_fr, blst_uint64_from_fr, BLST_ERROR,
};
use kzg::common_utils::{log2_u64, reverse_bit_order};
use kzg::eip_4844::{
BYTES_PER_FIELD_ELEMENT, BYTES_PER_G1, BYTES_PER_G2, FIELD_ELEMENTS_PER_BLOB,
FIELD_ELEMENTS_PER_CELL, FIELD_ELEMENTS_PER_EXT_BLOB, TRUSTED_SETUP_NUM_G2_POINTS
FIELD_ELEMENTS_PER_CELL, FIELD_ELEMENTS_PER_EXT_BLOB, TRUSTED_SETUP_NUM_G2_POINTS,
};
use kzg::msm::precompute::{precompute, PrecomputationTable};
use kzg::{
FFTFr, FFTSettings, FFTSettingsPoly, Fr as KzgFr, G1Affine as G1AffineTrait, G1Fp, G1GetFp,
G1LinComb, G1Mul, G1ProjAddAffine, G2Mul, KZGSettings, PairingVerify, Poly, Scalar256, G1, G2,
};
use std::ops::{AddAssign, Sub};

extern crate alloc;
use alloc::sync::Arc;
Expand All @@ -45,7 +51,6 @@ use alloc::sync::Arc;
pub struct ArkFr(pub blst_fr);

// impl Fr for ArkFr {


// fn bigint_check_mod_256(a: &[u64; 4]) -> bool {
// let (_, overflow) = a[0].overflowing_sub(BLS12_381_MOD_256[0]);
Expand Down Expand Up @@ -336,7 +341,6 @@ impl G1 for ArkG1 {
})
}


fn generator() -> Self {
ArkG1::from_blst_p1(blst_p1 {
x: blst_fp {
Expand Down Expand Up @@ -372,7 +376,6 @@ impl G1 for ArkG1 {
})
}


fn negative_generator() -> Self {
ArkG1::from_blst_p1(blst_p1 {
x: blst_fp {
Expand Down Expand Up @@ -416,7 +419,6 @@ impl G1 for ArkG1 {
Self(GroupProjective::rand(&mut rng))
}


#[allow(clippy::bind_instead_of_map)]
fn from_bytes(bytes: &[u8]) -> Result<Self, String> {
bytes
Expand Down Expand Up @@ -552,7 +554,8 @@ impl PairingVerify<ArkG1, ArkG2> for ArkG1 {
}

#[repr(C)]
#[derive(Debug, Default, PartialEq, Eq, Clone)]pub struct ArkG2(pub GroupProjective<g2::Parameters>);
#[derive(Debug, Default, PartialEq, Eq, Clone)]
pub struct ArkG2(pub GroupProjective<g2::Parameters>);

impl ArkG2 {
pub fn from_blst_p2(p2: blst::blst_p2) -> Self {
Expand Down Expand Up @@ -719,7 +722,6 @@ impl G2 for ArkG2 {
})
}


#[allow(clippy::bind_instead_of_map)]
fn from_bytes(bytes: &[u8]) -> Result<Self, String> {
bytes
Expand Down Expand Up @@ -749,7 +751,6 @@ impl G2 for ArkG2 {
<[u8; 96]>::try_from(self.0.x.c0.0.to_bytes_le()).unwrap()
}


fn add_or_dbl(&mut self, b: &Self) -> Self {
Self(self.0 + b.0)
}
Expand Down Expand Up @@ -1027,7 +1028,6 @@ impl FFTSettingsPoly<ArkFr, PolyData, LFFTSettings> for LFFTSettings {
}
}


impl Default for LFFTSettings {
fn default() -> Self {
Self {
Expand Down Expand Up @@ -1529,7 +1529,6 @@ impl G1AffineTrait<ArkG1, ArkFp> for ArkG1Affine {
ArkG1(self.aff.into_projective())
}


fn x(&self) -> &ArkFp {
unsafe {
// Transmute safe due to repr(C) on FsFp
Expand All @@ -1551,7 +1550,7 @@ impl G1AffineTrait<ArkG1, ArkFp> for ArkG1Affine {
fn is_zero(&self) -> bool {
self.aff.is_zero()
}

fn zero() -> Self {
Self {
aff: G1Affine::new(ArkFp::zero().0, ArkFp::zero().0, true),
Expand Down Expand Up @@ -1582,4 +1581,4 @@ impl G1ProjAddAffine<ArkG1, ArkFp, ArkG1Affine> for ArkG1ProjAddAffine {
fn add_or_double_assign_affine(proj: &mut ArkG1, aff: &ArkG1Affine) {
proj.0.add_assign_mixed(&aff.aff);
}
}
}
2 changes: 1 addition & 1 deletion arkworks3/src/poly.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ impl PolyData {
self.mul_fft(multiplier, output_len)
}
}
}
}
4 changes: 3 additions & 1 deletion arkworks3/tests/eip_4844.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ mod tests {
};
use rust_kzg_arkworks3::consts::SCALE2_ROOT_OF_UNITY;
use rust_kzg_arkworks3::eip_4844::load_trusted_setup_filename_rust;
use rust_kzg_arkworks3::kzg_proofs::{expand_root_of_unity, LFFTSettings, LKZGSettings as KZGSettings};
use rust_kzg_arkworks3::kzg_proofs::{
expand_root_of_unity, LFFTSettings, LKZGSettings as KZGSettings,
};
use rust_kzg_arkworks3::kzg_types::{ArkFp, ArkFr, ArkG1, ArkG1Affine, ArkG2};
use rust_kzg_arkworks3::utils::PolyData;

Expand Down
4 changes: 3 additions & 1 deletion arkworks3/tests/fk20_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ mod tests {
use kzg_bench::tests::fk20_proofs::*;

use rust_kzg_arkworks3::fk20_proofs::{KzgFK20MultiSettings, KzgFK20SingleSettings};
use rust_kzg_arkworks3::kzg_proofs::{generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings};
use rust_kzg_arkworks3::kzg_proofs::{
generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings,
};
use rust_kzg_arkworks3::kzg_types::{ArkFp, ArkFr as BlstFr, ArkG1Affine};
use rust_kzg_arkworks3::kzg_types::{ArkG1, ArkG2};
use rust_kzg_arkworks3::utils::PolyData;
Expand Down
4 changes: 3 additions & 1 deletion arkworks3/tests/kzg_proofs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ mod tests {
use kzg_bench::tests::kzg_proofs::{
commit_to_nil_poly, commit_to_too_long_poly_returns_err, proof_multi, proof_single,
};
use rust_kzg_arkworks3::kzg_proofs::{generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings};
use rust_kzg_arkworks3::kzg_proofs::{
generate_trusted_setup, LFFTSettings as FFTSettings, LKZGSettings as KZGSettings,
};
use rust_kzg_arkworks3::kzg_types::{ArkFp, ArkFr, ArkG1, ArkG1Affine, ArkG2};
use rust_kzg_arkworks3::utils::PolyData;

Expand Down

0 comments on commit d14d5b3

Please sign in to comment.