From 1991550adbc5de0cdea8bd406480c45bc2aecdb7 Mon Sep 17 00:00:00 2001 From: Ethen Pociask Date: Sun, 2 Jun 2024 00:25:13 -0400 Subject: [PATCH] chore: Updated clippy - update docs and kzg file --- README.md | 3 +++ src/kzg.rs | 25 ++++++++++--------------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 61afa0b..d659d13 100644 --- a/README.md +++ b/README.md @@ -19,6 +19,9 @@ This code is unaudited and under construction. This is experimental software and 2. Specify the files in `kzg.setup()` function, leave the `g2_points` empty, and specify the `srs_order` per the guide. 3. Note that this is process will take a few minutes to load since it is a bit intensive. +## Clippy +Linting can be triggered via running `cargo clippy --all --manifest-path Cargo.toml -- -D warnings`. + ## Quick Start 1. Check the test in `test_compute_kzg_proof` function to see the end to end usage of the library for quick start. diff --git a/src/kzg.rs b/src/kzg.rs index ddc1ed0..71cd6c8 100644 --- a/src/kzg.rs +++ b/src/kzg.rs @@ -49,16 +49,12 @@ impl Kzg { let g1_points = Self::parallel_read_g1_points(path_to_g1_points.to_owned(), srs_points_to_load) .map_err(|e| KzgError::SerializationError(e.to_string()))?; - - let g2_points: Vec; - if !path_to_g2_points.is_empty() { - g2_points = - Self::parallel_read_g2_points(path_to_g2_points.to_owned(), srs_points_to_load) - .map_err(|e| KzgError::SerializationError(e.to_string()))?; - } else if !g2_power_of2_path.is_empty() { - g2_points = Self::read_g2_point_on_power_of_2(g2_power_of2_path)?; - } else { - return Err(KzgError::GenericError( + + let g2_points_result: Result, KzgError> = match (path_to_g2_points.is_empty(), g2_power_of2_path.is_empty()) { + (false, _) => Self::parallel_read_g2_points(path_to_g2_points.to_owned(), srs_points_to_load) + .map_err(|e| KzgError::SerializationError(e.to_string())), + (_, false) => Self::read_g2_point_on_power_of_2(g2_power_of2_path), + (true, true) => return Err(KzgError::GenericError( "both g2 point files are empty, need the proper file specified".to_string(), )), }; @@ -525,10 +521,10 @@ impl Kzg { roots_of_unities: &[Fr], ) -> Fr { let mut quotient = Fr::zero(); - let mut fi: Fr; - let mut numerator: Fr; - let mut denominator: Fr; - let mut temp: Fr; + let mut fi: Fr = Fr::zero(); + let mut numerator: Fr = Fr::zero(); + let mut denominator: Fr = Fr::zero(); + let mut temp: Fr = Fr::zero(); roots_of_unities.iter().enumerate().for_each(|(i, omega_i)| { if *omega_i == z_fr { @@ -540,7 +536,6 @@ impl Kzg { denominator *= z_fr; temp = numerator.div(denominator); quotient += temp; - }); quotient