Skip to content

Commit

Permalink
cargo fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
anupsv committed Jan 27, 2025
1 parent 95d9a0a commit 9cf384d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
20 changes: 12 additions & 8 deletions kzg/src/kzg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,11 @@ impl KZG {
}

/// Commit the polynomial with the srs values loaded into [Kzg].
pub fn commit_eval_form(&self, polynomial: &PolynomialEvalForm, srs: &SRS) -> Result<G1Affine, KzgError> {
pub fn commit_eval_form(
&self,
polynomial: &PolynomialEvalForm,
srs: &SRS,
) -> Result<G1Affine, KzgError> {
if polynomial.len() > srs.g1.len() {
return Err(KzgError::SerializationError(
"polynomial length is not correct".to_string(),
Expand All @@ -251,7 +255,7 @@ impl KZG {
pub fn commit_coeff_form(
&self,
polynomial: &PolynomialCoeffForm,
srs: &SRS
srs: &SRS,
) -> Result<G1Affine, KzgError> {
if polynomial.len() > srs.g1.len() {
return Err(KzgError::SerializationError(
Expand All @@ -273,7 +277,7 @@ impl KZG {
&self,
polynomial: &PolynomialEvalForm,
z_fr: &Fr,
srs: &SRS
srs: &SRS,
) -> Result<G1Affine, KzgError> {
// Verify polynomial length matches that of the roots of unity
if polynomial.len() != self.expanded_roots_of_unity.len() {
Expand Down Expand Up @@ -332,7 +336,7 @@ impl KZG {
&self,
polynomial: &PolynomialEvalForm,
index: u64,
srs: &SRS
srs: &SRS,
) -> Result<G1Affine, KzgError> {
// Convert u64 index to usize for array indexing
let usized_index = index.to_usize().ok_or(KzgError::GenericError(
Expand All @@ -359,8 +363,8 @@ impl KZG {
pub fn compute_proof(
&self,
polynomial: &PolynomialEvalForm,
z_fr: &Fr,
srs: &SRS
z_fr: &Fr,
srs: &SRS,
) -> Result<G1Affine, KzgError> {
// Verify that polynomial length matches roots of unity length
if polynomial.len() != self.expanded_roots_of_unity.len() {
Expand Down Expand Up @@ -432,8 +436,8 @@ impl KZG {
pub fn compute_blob_proof(
&self,
blob: &Blob,
commitment: &G1Affine,
srs: &SRS
commitment: &G1Affine,
srs: &SRS,
) -> Result<G1Affine, KzgError> {
// Validate that the commitment is a valid point on the G1 curve
// This prevents potential invalid curve attacks
Expand Down
6 changes: 4 additions & 2 deletions primitives/tests/helpers_test.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
use std::{fs::File, io::{BufRead, BufReader, Read}};
use std::{
fs::File,
io::{BufRead, BufReader, Read},
};

use ark_bn254::{Fq, Fq2, Fr, G1Affine, G1Projective, G2Affine, G2Projective};
use ark_ff::{PrimeField, UniformRand};
Expand Down Expand Up @@ -45,7 +48,6 @@ fn test_g2_is_on_curve() {
// Tests deserialization of data and equivalence.
#[test]
fn test_blob_to_polynomial() {

let file = File::open("tests/test-files/blobs.txt").unwrap();
let mut reader = BufReader::new(file);
let mut buffer = [0u8; SIZE_OF_G1_AFFINE_COMPRESSED];
Expand Down

0 comments on commit 9cf384d

Please sign in to comment.