From 2dac615035d1f1a51c6be3f9c427f14e47cabdb4 Mon Sep 17 00:00:00 2001 From: kunxian xia Date: Wed, 27 Dec 2023 21:32:09 +0800 Subject: [PATCH] clippy --- halo2_proofs/benches/lookups.rs | 5 +-- halo2_proofs/src/arithmetic.rs | 34 +++++++++---------- .../src/circuit/floor_planner/single_pass.rs | 3 -- halo2_proofs/src/circuit/floor_planner/v1.rs | 3 +- halo2_proofs/src/dev.rs | 19 +++++------ halo2_proofs/src/dev/graph/layout.rs | 7 ---- halo2_proofs/src/helpers.rs | 1 - halo2_proofs/src/lib.rs | 3 +- halo2_proofs/src/plonk/circuit.rs | 6 ++-- halo2_proofs/src/plonk/evaluation.rs | 12 ++----- halo2_proofs/src/plonk/mv_lookup.rs | 7 ++-- halo2_proofs/src/plonk/mv_lookup/prover.rs | 31 +++++------------ halo2_proofs/src/plonk/mv_lookup/verifier.rs | 4 +-- .../src/plonk/permutation/verifier.rs | 2 +- halo2_proofs/src/plonk/prover.rs | 2 +- halo2_proofs/src/plonk/vanishing/prover.rs | 2 +- halo2_proofs/src/plonk/verifier.rs | 2 +- halo2_proofs/src/poly/commitment.rs | 3 +- halo2_proofs/src/poly/domain.rs | 17 ++++------ halo2_proofs/src/poly/ipa/commitment.rs | 4 +-- halo2_proofs/src/poly/ipa/multiopen.rs | 2 +- halo2_proofs/src/poly/kzg/commitment.rs | 5 +-- .../src/poly/kzg/multiopen/gwc/prover.rs | 4 +-- .../src/poly/kzg/multiopen/gwc/verifier.rs | 4 +-- .../src/poly/kzg/multiopen/shplonk.rs | 2 +- halo2_proofs/src/poly/multiopen_test.rs | 2 +- halo2_proofs/tests/plonk_api.rs | 7 ++-- 27 files changed, 72 insertions(+), 121 deletions(-) diff --git a/halo2_proofs/benches/lookups.rs b/halo2_proofs/benches/lookups.rs index 601b1a4285..aca5cecc94 100644 --- a/halo2_proofs/benches/lookups.rs +++ b/halo2_proofs/benches/lookups.rs @@ -41,6 +41,7 @@ fn criterion_benchmark(c: &mut Criterion) { impl Circuit for MyCircuit { type Config = MyConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self::default() @@ -58,8 +59,8 @@ fn criterion_benchmark(c: &mut Criterion) { meta.create_gate("degree 6 gate", |meta| { let dummy_selector = meta.query_selector(dummy_selector); - let constraints = vec![dummy_selector.clone(); 4] - .iter() + let constraints = std::iter::repeat(dummy_selector.clone()) + .take(4) .fold(dummy_selector.clone(), |acc, val| acc * val.clone()); Constraints::with_selector(dummy_selector, Some(constraints)) }); diff --git a/halo2_proofs/src/arithmetic.rs b/halo2_proofs/src/arithmetic.rs index 84034a106d..450bf0d287 100644 --- a/halo2_proofs/src/arithmetic.rs +++ b/halo2_proofs/src/arithmetic.rs @@ -188,7 +188,7 @@ pub fn best_multiexp(coeffs: &[C::Scalar], bases: &[C]) -> C::Cu pub fn best_fft>(a: &mut [G], omega: Scalar, log_n: u32) { let threads = multicore::current_num_threads(); let log_split = log2_floor(threads) as usize; - let n = a.len() as usize; + let n = a.len(); let sub_n = n >> log_split; let split_m = 1 << log_split; @@ -215,7 +215,7 @@ fn serial_fft>(a: &mut [G], omega: Scalar, lo for k in 0..n as usize { let rk = bitreverse(k, log_n as usize); if k < rk { - a.swap(rk as usize, k as usize); + a.swap(rk, k); } } @@ -258,7 +258,7 @@ fn serial_split_fft>( let high_idx = omega_idx >> SPARSE_TWIDDLE_DEGREE; let mut w_m = twiddle_lut[low_idx]; if high_idx > 0 { - w_m = w_m * twiddle_lut[(1 << SPARSE_TWIDDLE_DEGREE) + high_idx]; + w_m *= twiddle_lut[(1 << SPARSE_TWIDDLE_DEGREE) + high_idx]; } let mut k = 0; @@ -298,28 +298,28 @@ fn split_radix_fft>( // used to be: vec![G::identity; split_m]; // let mut t1 = a.clone(); // if unsafe code is allowed, a 10% performance improvement can be achieved - let mut t1: Vec = Vec::with_capacity(split_m as usize); + let mut t1: Vec = Vec::with_capacity(split_m); unsafe { - t1.set_len(split_m as usize); + t1.set_len(split_m); } for i in 0..split_m { - t1[bitreverse(i, log_split)] = a[(i * sub_n + sub_fft_offset)]; + t1[bitreverse(i, log_split)] = a[i * sub_n + sub_fft_offset]; } serial_split_fft(&mut t1, twiddle_lut, sub_n, log_split as u32); let sparse_degree = SPARSE_TWIDDLE_DEGREE; - let omega_idx = sub_fft_offset as usize; + let omega_idx = sub_fft_offset; let low_idx = omega_idx % (1 << sparse_degree); let high_idx = omega_idx >> sparse_degree; let mut omega = twiddle_lut[low_idx]; if high_idx > 0 { - omega = omega * twiddle_lut[(1 << sparse_degree) + high_idx]; + omega *= twiddle_lut[(1 << sparse_degree) + high_idx]; } let mut w_m = Scalar::ONE; for i in 0..split_m { t1[i] *= &w_m; tmp[i] = t1[i]; - w_m = w_m * omega; + w_m *= omega; } } @@ -339,7 +339,7 @@ pub fn generate_twiddle_lookup_table( let mut w_n = omega.pow_vartime([start as u64, 0, 0, 0]); for twiddle_lut in twiddle_lut.iter_mut() { *twiddle_lut = w_n; - w_n = w_n * omega; + w_n *= omega; } }); return twiddle_lut; @@ -348,14 +348,14 @@ pub fn generate_twiddle_lookup_table( // sparse let low_degree_lut_len = 1 << sparse_degree; let high_degree_lut_len = 1 << (log_n - sparse_degree - without_last_level as u32); - let mut twiddle_lut = vec![F::ZERO; (low_degree_lut_len + high_degree_lut_len) as usize]; + let mut twiddle_lut = vec![F::ZERO; low_degree_lut_len + high_degree_lut_len]; parallelize( &mut twiddle_lut[..low_degree_lut_len], |twiddle_lut, start| { let mut w_n = omega.pow_vartime([start as u64, 0, 0, 0]); for twiddle_lut in twiddle_lut.iter_mut() { *twiddle_lut = w_n; - w_n = w_n * omega; + w_n *= omega; } }, ); @@ -366,7 +366,7 @@ pub fn generate_twiddle_lookup_table( let mut w_n = high_degree_omega.pow_vartime([start as u64, 0, 0, 0]); for twiddle_lut in twiddle_lut.iter_mut() { *twiddle_lut = w_n; - w_n = w_n * high_degree_omega; + w_n *= high_degree_omega; } }, ); @@ -374,7 +374,7 @@ pub fn generate_twiddle_lookup_table( } pub fn parallel_fft>(a: &mut [G], omega: Scalar, log_n: u32) { - let n = a.len() as usize; + let n = a.len(); assert_eq!(n, 1 << log_n); let log_split = log2_floor(multicore::current_num_threads()) as usize; @@ -580,7 +580,7 @@ pub(crate) fn parallelize_internal(points: &[F], evals: &[F]) -> Vec { .enumerate() .filter(|&(k, _)| k != j) .map(|a| a.1) - .zip(denoms.into_iter()) + .zip(denoms) { product.resize(tmp.len() + 1, F::ZERO); for ((a, b), product) in tmp @@ -665,7 +665,7 @@ pub fn lagrange_interpolate(points: &[F], evals: &[F]) -> Vec { } assert_eq!(tmp.len(), points.len()); assert_eq!(product.len(), points.len() - 1); - for (final_coeff, interpolation_coeff) in final_poly.iter_mut().zip(tmp.into_iter()) { + for (final_coeff, interpolation_coeff) in final_poly.iter_mut().zip(tmp) { *final_coeff += interpolation_coeff * eval; } } diff --git a/halo2_proofs/src/circuit/floor_planner/single_pass.rs b/halo2_proofs/src/circuit/floor_planner/single_pass.rs index af604f6a06..4a6d78e7a8 100644 --- a/halo2_proofs/src/circuit/floor_planner/single_pass.rs +++ b/halo2_proofs/src/circuit/floor_planner/single_pass.rs @@ -2,8 +2,6 @@ use std::cmp; use std::collections::HashMap; use std::fmt; use std::marker::PhantomData; -use std::ops::Range; -use std::sync::{Arc, Mutex}; use std::time::Instant; use rayon::prelude::{IndexedParallelIterator, IntoParallelIterator, ParallelIterator}; @@ -18,7 +16,6 @@ use crate::{ table_layouter::{compute_table_lengths, SimpleTableLayouter}, Cell, Layouter, Region, RegionIndex, RegionStart, Table, Value, }, - multicore, plonk::{ Advice, Any, Assigned, Assignment, Challenge, Circuit, Column, Error, Fixed, FloorPlanner, Instance, Selector, TableColumn, diff --git a/halo2_proofs/src/circuit/floor_planner/v1.rs b/halo2_proofs/src/circuit/floor_planner/v1.rs index 0e512f1eca..642be88d54 100644 --- a/halo2_proofs/src/circuit/floor_planner/v1.rs +++ b/halo2_proofs/src/circuit/floor_planner/v1.rs @@ -128,8 +128,7 @@ impl FloorPlanner for V1 { if constant_positions().count() < plan.constants.len() { return Err(Error::NotEnoughColumnsForConstants); } - for ((fixed_column, fixed_row), (value, advice)) in - constant_positions().zip(plan.constants.into_iter()) + for ((fixed_column, fixed_row), (value, advice)) in constant_positions().zip(plan.constants) { plan.cs.assign_fixed( || format!("Constant({:?})", value.evaluate()), diff --git a/halo2_proofs/src/dev.rs b/halo2_proofs/src/dev.rs index 7452df52cd..817e03a08d 100644 --- a/halo2_proofs/src/dev.rs +++ b/halo2_proofs/src/dev.rs @@ -5,12 +5,10 @@ use std::collections::HashSet; use std::iter; use std::ops::{Add, Mul, Neg, Range}; use std::sync::Arc; -use std::time::Instant; use blake2b_simd::blake2b; use ff::Field; use ff::FromUniformBytes; -use group::Group; use crate::plonk::permutation::keygen::Assembly; use crate::{ @@ -25,8 +23,6 @@ use crate::{ use crate::{plonk::sealed::SealedPhase, plonk::FirstPhase, plonk::Phase}; #[cfg(feature = "multiphase-mock-prover")] use ff::BatchInvert; -#[cfg(feature = "multiphase-mock-prover")] -use group::Group; #[cfg(feature = "multicore")] use crate::multicore::{ @@ -875,11 +871,13 @@ impl<'a, F: Field> Assignment for MockProver<'a, F> { } #[cfg(not(feature = "multiphase-mock-prover"))] - *self - .advice - .get_mut(column.index()) - .and_then(|v| v.get_mut(row - self.rw_rows.start)) - .ok_or(Error::BoundsFailure)? = assigned; + { + *self + .advice + .get_mut(column.index()) + .and_then(|v| v.get_mut(row - self.rw_rows.start)) + .ok_or(Error::BoundsFailure)? = assigned; + } #[cfg(feature = "phase-check")] // if false && self.current_phase.0 > column.column_type().phase.0 { @@ -1091,7 +1089,6 @@ impl<'a, F: FromUniformBytes<64> + Ord> MockProver<'a, F> { #[cfg(not(feature = "circuit-params"))] let config = ConcreteCircuit::configure(&mut cs); let cs = cs.chunk_lookups(); - let cs = cs; assert!( n >= cs.minimum_rows(), @@ -1300,7 +1297,7 @@ impl<'a, F: FromUniformBytes<64> + Ord> MockProver<'a, F> { debug_assert_eq!(Arc::strong_count(&prover.fixed_vec), 1); #[cfg(feature = "thread-safe-region")] - prover.permutation.build_ordered_mapping(); + prover.permutation.as_mut().unwrap().build_ordered_mapping(); Ok(prover) } diff --git a/halo2_proofs/src/dev/graph/layout.rs b/halo2_proofs/src/dev/graph/layout.rs index 489f08fb7d..7d00434aa2 100644 --- a/halo2_proofs/src/dev/graph/layout.rs +++ b/halo2_proofs/src/dev/graph/layout.rs @@ -321,10 +321,3 @@ impl CircuitLayout { Ok(()) } } -fn query_advice(&self, _column: Column, _row: usize) -> Result { - Ok(F::ZERO) -} - -fn query_fixed(&self, _column: Column, _row: usize) -> Result { - Ok(F::ZERO) -} diff --git a/halo2_proofs/src/helpers.rs b/halo2_proofs/src/helpers.rs index bec329cc50..179bdbed26 100644 --- a/halo2_proofs/src/helpers.rs +++ b/halo2_proofs/src/helpers.rs @@ -1,6 +1,5 @@ use crate::plonk::{Any, Column}; use crate::poly::Polynomial; -use ff::Field; use ff::{FromUniformBytes, PrimeField}; use halo2curves::{serde::SerdeObject, CurveAffine}; use num_bigint::BigUint; diff --git a/halo2_proofs/src/lib.rs b/halo2_proofs/src/lib.rs index 266b6626b5..d670143b21 100644 --- a/halo2_proofs/src/lib.rs +++ b/halo2_proofs/src/lib.rs @@ -8,9 +8,10 @@ #![feature(stmt_expr_attributes)] // #![deny(missing_docs)] // #![deny(unsafe_code)] +#![allow(clippy::uninit_vec)] +#![allow(clippy::too_many_arguments)] #[cfg(feature = "counter")] -#[macro_use] extern crate lazy_static; #[cfg(feature = "counter")] diff --git a/halo2_proofs/src/plonk/circuit.rs b/halo2_proofs/src/plonk/circuit.rs index 9793090c6d..24ca881589 100644 --- a/halo2_proofs/src/plonk/circuit.rs +++ b/halo2_proofs/src/plonk/circuit.rs @@ -9,12 +9,10 @@ use core::cmp::max; use core::ops::{Add, Mul}; use ff::Field; use sealed::SealedPhase; -use std::collections::{BTreeMap, HashMap}; +use std::collections::BTreeMap; use std::fmt::Debug; //use std::fmt::Debug; -use std::hash::Hasher; use std::iter::{Product, Sum}; -use std::marker::PhantomData; use std::ops::Range; use std::{ convert::TryFrom, @@ -1890,7 +1888,7 @@ impl ConstraintSystem { pub fn lookup_any>( &mut self, // FIXME use name in debug messages - name: &'static str, + _name: S, table_map: impl FnOnce(&mut VirtualCells<'_, F>) -> Vec<(Expression, Expression)>, ) { let mut cells = VirtualCells::new(self); diff --git a/halo2_proofs/src/plonk/evaluation.rs b/halo2_proofs/src/plonk/evaluation.rs index bfa4c2425f..08d15c25e7 100644 --- a/halo2_proofs/src/plonk/evaluation.rs +++ b/halo2_proofs/src/plonk/evaluation.rs @@ -1,17 +1,11 @@ use crate::multicore; -use crate::plonk::{ - mv_lookup, permutation, AdviceQuery, Any, FixedQuery, InstanceQuery, ProvingKey, -}; +use crate::plonk::{mv_lookup, permutation, Any, ProvingKey}; use crate::poly::Basis; use crate::{ - arithmetic::{eval_polynomial, parallelize, CurveAffine}, + arithmetic::{parallelize, CurveAffine}, poly::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial, Rotation}, }; -use group::ff::{BatchInvert, Field, PrimeField, WithSmallOrderMulGroup}; -use rayon::prelude::IntoParallelIterator; -use rayon::prelude::ParallelIterator; -use std::process::exit; -use std::sync::atomic::fence; +use group::ff::{Field, PrimeField, WithSmallOrderMulGroup}; use super::{shuffle, ConstraintSystem, Expression}; diff --git a/halo2_proofs/src/plonk/mv_lookup.rs b/halo2_proofs/src/plonk/mv_lookup.rs index b4fd2d825f..5c26c20b78 100644 --- a/halo2_proofs/src/plonk/mv_lookup.rs +++ b/halo2_proofs/src/plonk/mv_lookup.rs @@ -57,11 +57,8 @@ impl Argument { input_degree }; - let inputs_expressions_degree: usize = self - .inputs_expressions - .iter() - .map(|input_expressions| expr_degree(input_expressions)) - .sum(); + let inputs_expressions_degree: usize = + self.inputs_expressions.iter().map(expr_degree).sum(); let table_degree = expr_degree(&self.table_expressions); diff --git a/halo2_proofs/src/plonk/mv_lookup/prover.rs b/halo2_proofs/src/plonk/mv_lookup/prover.rs index 52d434289b..6cc6abc4a1 100644 --- a/halo2_proofs/src/plonk/mv_lookup/prover.rs +++ b/halo2_proofs/src/plonk/mv_lookup/prover.rs @@ -1,6 +1,5 @@ use super::super::{ - circuit::Expression, ChallengeBeta, ChallengeGamma, ChallengeTheta, ChallengeX, Error, - ProvingKey, + circuit::Expression, ChallengeBeta, ChallengeTheta, ChallengeX, Error, ProvingKey, }; use super::Argument; use crate::plonk::evaluation::evaluate; @@ -8,30 +7,20 @@ use crate::{ arithmetic::{eval_polynomial, parallelize, CurveAffine}, poly::{ commitment::{Blind, Params}, - Coeff, EvaluationDomain, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial, ProverQuery, - Rotation, + Coeff, EvaluationDomain, LagrangeCoeff, Polynomial, ProverQuery, Rotation, }, transcript::{EncodedChallenge, TranscriptWrite}, }; use ark_std::{end_timer, start_timer}; -use blake2b_simd::Hash; -use ff::{BitViewSized, PrimeField, PrimeFieldBits, WithSmallOrderMulGroup}; -use group::{ - ff::{BatchInvert, Field}, - Curve, -}; +use ff::{PrimeField, WithSmallOrderMulGroup}; +use group::{ff::Field, Curve}; use rand_core::RngCore; -use rayon::current_num_threads; -use std::collections::{BTreeSet, HashSet}; -use std::time::Instant; -use std::{any::TypeId, convert::TryInto, num::ParseIntError, ops::Index}; use std::{ - collections::BTreeMap, iter, ops::{Mul, MulAssign}, }; -use crate::arithmetic::{par_invert, parallelize_internal}; +use crate::arithmetic::par_invert; use rayon::prelude::{ IndexedParallelIterator, IntoParallelRefIterator, ParallelIterator, ParallelSliceMut, }; @@ -134,7 +123,6 @@ impl + Ord> Argument { let m_time = start_timer!(|| "m(X) values"); let m_values: Vec = { use std::sync::atomic::{AtomicU64, Ordering}; - use std::sync::RwLock; let m_values: Vec = (0..params.n()).map(|_| AtomicU64::new(0)).collect(); for compressed_input_expression in compressed_inputs_expressions.iter() { @@ -154,7 +142,7 @@ impl + Ord> Argument { m_values .par_iter() - .map(|mi| F::from(mi.load(Ordering::Relaxed) as u64)) + .map(|mi| F::from(mi.load(Ordering::Relaxed))) .collect() }; end_timer!(m_time); @@ -315,13 +303,13 @@ impl Prepared { let active_size = params.n() as usize - blinding_factors; let chunk = { let num_threads = crate::multicore::current_num_threads(); - let mut chunk = (active_size as usize) / num_threads; + let mut chunk = (active_size) / num_threads; if chunk < num_threads { chunk = 1; } chunk }; - let num_chunks = (active_size as usize + chunk - 1) / chunk; + let num_chunks = (active_size + chunk - 1) / chunk; let mut segment_sum = vec![C::Scalar::ZERO; num_chunks]; let mut grand_sum = iter::once(C::Scalar::ZERO) .chain(log_derivatives_diff) @@ -479,6 +467,7 @@ impl Evaluated { } } +#[cfg(test)] mod benches { use ark_std::rand::thread_rng; use ff::Field; @@ -498,7 +487,6 @@ mod benches { let n = 1 << log_n; let dur = Instant::now(); let _table: BTreeMap = (0..n) - .into_iter() .map(|_| Fr::random(&mut rng)) .enumerate() .map(|(i, x)| (x, i)) @@ -514,7 +502,6 @@ mod benches { let n = 1 << log_n; let dur = Instant::now(); let _table: BTreeMap = (0..n) - .into_iter() .map(Fr::from) .enumerate() .map(|(i, x)| (x, i)) diff --git a/halo2_proofs/src/plonk/mv_lookup/verifier.rs b/halo2_proofs/src/plonk/mv_lookup/verifier.rs index bcebd0be72..0593f3bcca 100644 --- a/halo2_proofs/src/plonk/mv_lookup/verifier.rs +++ b/halo2_proofs/src/plonk/mv_lookup/verifier.rs @@ -1,8 +1,6 @@ use std::iter; -use super::super::{ - circuit::Expression, ChallengeBeta, ChallengeGamma, ChallengeTheta, ChallengeX, -}; +use super::super::{circuit::Expression, ChallengeBeta, ChallengeTheta, ChallengeX}; use super::Argument; use crate::{ arithmetic::CurveAffine, diff --git a/halo2_proofs/src/plonk/permutation/verifier.rs b/halo2_proofs/src/plonk/permutation/verifier.rs index 5af15a5326..080acf24e7 100644 --- a/halo2_proofs/src/plonk/permutation/verifier.rs +++ b/halo2_proofs/src/plonk/permutation/verifier.rs @@ -184,7 +184,7 @@ impl Evaluated { let mut right = set.permutation_product_eval; let mut current_delta = (*beta * &*x) * &(::DELTA - .pow_vartime(&[(chunk_index * chunk_len) as u64])); + .pow_vartime([(chunk_index * chunk_len) as u64])); for eval in columns.iter().map(|&column| match column.column_type() { Any::Advice(_) => { advice_evals[vk.cs.get_any_query_index(column, Rotation::cur())] diff --git a/halo2_proofs/src/plonk/prover.rs b/halo2_proofs/src/plonk/prover.rs index 4c1347954e..4ed6195ebc 100644 --- a/halo2_proofs/src/plonk/prover.rs +++ b/halo2_proofs/src/plonk/prover.rs @@ -1,5 +1,5 @@ use crate::plonk::shuffle; -use ff::{Field, FromUniformBytes, PrimeField, WithSmallOrderMulGroup}; +use ff::{Field, FromUniformBytes, WithSmallOrderMulGroup}; use group::Curve; use rand_core::RngCore; use std::collections::BTreeSet; diff --git a/halo2_proofs/src/plonk/vanishing/prover.rs b/halo2_proofs/src/plonk/vanishing/prover.rs index 50b287178c..1b055682b0 100644 --- a/halo2_proofs/src/plonk/vanishing/prover.rs +++ b/halo2_proofs/src/plonk/vanishing/prover.rs @@ -1,4 +1,4 @@ -use std::{collections::HashMap, iter}; +use std::iter; use ff::Field; use group::Curve; diff --git a/halo2_proofs/src/plonk/verifier.rs b/halo2_proofs/src/plonk/verifier.rs index 14324d6228..5bf873d759 100644 --- a/halo2_proofs/src/plonk/verifier.rs +++ b/halo2_proofs/src/plonk/verifier.rs @@ -6,7 +6,7 @@ use super::{ vanishing, ChallengeBeta, ChallengeGamma, ChallengeTheta, ChallengeX, ChallengeY, Error, VerifyingKey, }; -use crate::arithmetic::{compute_inner_product, CurveAffine}; +use crate::arithmetic::compute_inner_product; use crate::poly::commitment::{CommitmentScheme, Verifier}; use crate::poly::VerificationStrategy; use crate::poly::{ diff --git a/halo2_proofs/src/poly/commitment.rs b/halo2_proofs/src/poly/commitment.rs index a98487f872..590767e68e 100644 --- a/halo2_proofs/src/poly/commitment.rs +++ b/halo2_proofs/src/poly/commitment.rs @@ -6,8 +6,7 @@ use super::{ use crate::poly::Error; use crate::transcript::{EncodedChallenge, TranscriptRead, TranscriptWrite}; use ff::Field; -use group::{Curve, Group}; -use halo2curves::{CurveAffine, CurveExt}; +use halo2curves::CurveAffine; use rand_core::RngCore; use std::{ fmt::Debug, diff --git a/halo2_proofs/src/poly/domain.rs b/halo2_proofs/src/poly/domain.rs index 4e7d72fded..0f3f01c014 100644 --- a/halo2_proofs/src/poly/domain.rs +++ b/halo2_proofs/src/poly/domain.rs @@ -8,10 +8,7 @@ use crate::{ use super::{Coeff, ExtendedLagrangeCoeff, LagrangeCoeff, Polynomial, Rotation}; use ff::WithSmallOrderMulGroup; -use group::{ - ff::{BatchInvert, Field, PrimeField}, - Group, -}; +use group::ff::{BatchInvert, Field}; use std::marker::PhantomData; @@ -91,8 +88,8 @@ impl> EvaluationDomain { { // Compute the evaluations of t(X) = X^n - 1 in the coset evaluation domain. // We don't have to compute all of them, because it will repeat. - let orig = F::ZETA.pow_vartime(&[n as u64, 0, 0, 0]); - let step = extended_omega.pow_vartime(&[n as u64, 0, 0, 0]); + let orig = F::ZETA.pow_vartime([n, 0, 0, 0]); + let step = extended_omega.pow_vartime([n, 0, 0, 0]); let mut cur = orig; loop { t_evaluations.push(cur); @@ -178,7 +175,7 @@ impl> EvaluationDomain { &self, values: Vec>, ) -> Polynomial { - assert_eq!(values.len(), (self.extended_len() >> self.k) as usize); + assert_eq!(values.len(), (self.extended_len() >> self.k)); assert_eq!(values[0].len(), self.n as usize); // transpose the values in parallel @@ -459,10 +456,10 @@ impl> EvaluationDomain { /// fn distribute_powers(&self, a: &mut [F], c: F) { parallelize(a, |a, index| { - let mut c_power = c.pow_vartime(&[index as u64, 0, 0, 0]); + let mut c_power = c.pow_vartime([index as u64, 0, 0, 0]); for a in a { - *a = *a * (&c_power); - c_power = c_power * c; + *a *= &c_power; + c_power *= c; } }); } diff --git a/halo2_proofs/src/poly/ipa/commitment.rs b/halo2_proofs/src/poly/ipa/commitment.rs index b11ee1998d..9e30355121 100644 --- a/halo2_proofs/src/poly/ipa/commitment.rs +++ b/halo2_proofs/src/poly/ipa/commitment.rs @@ -229,15 +229,13 @@ impl<'params, C: CurveAffine> ParamsProver<'params, C> for ParamsIPA { #[cfg(test)] mod test { - use crate::arithmetic::{best_fft, best_multiexp, parallelize, CurveAffine, CurveExt}; use crate::poly::commitment::ParamsProver; use crate::poly::commitment::{Blind, Params, MSM}; use crate::poly::ipa::commitment::{create_proof, verify_proof, ParamsIPA}; use crate::poly::ipa::msm::MSMIPA; - use group::{prime::PrimeCurveAffine, Curve, Group}; + use group::Curve; use ff::Field; - use group::Curve; #[test] fn test_commit_lagrange_epaffine() { diff --git a/halo2_proofs/src/poly/ipa/multiopen.rs b/halo2_proofs/src/poly/ipa/multiopen.rs index fd6aa78544..b78acb5934 100644 --- a/halo2_proofs/src/poly/ipa/multiopen.rs +++ b/halo2_proofs/src/poly/ipa/multiopen.rs @@ -4,7 +4,7 @@ //! [halo]: https://eprint.iacr.org/2019/1021 use super::*; -use crate::{arithmetic::CurveAffine, poly::query::Query, transcript::ChallengeScalar}; +use crate::{poly::query::Query, transcript::ChallengeScalar}; use ff::Field; use std::collections::{BTreeMap, BTreeSet}; diff --git a/halo2_proofs/src/poly/kzg/commitment.rs b/halo2_proofs/src/poly/kzg/commitment.rs index e2f35300d1..08a1a88869 100644 --- a/halo2_proofs/src/poly/kzg/commitment.rs +++ b/halo2_proofs/src/poly/kzg/commitment.rs @@ -106,7 +106,7 @@ where } let n_inv = Option::::from(E::Scalar::from(n).invert()) .expect("inversion should be ok for n = 1<::new(K); diff --git a/halo2_proofs/src/poly/kzg/multiopen/gwc/prover.rs b/halo2_proofs/src/poly/kzg/multiopen/gwc/prover.rs index eeb3db89bb..89b629bfa4 100644 --- a/halo2_proofs/src/poly/kzg/multiopen/gwc/prover.rs +++ b/halo2_proofs/src/poly/kzg/multiopen/gwc/prover.rs @@ -1,5 +1,5 @@ use super::{construct_intermediate_sets, ChallengeV, Query}; -use crate::arithmetic::{eval_polynomial, kate_division, powers, CurveAffine}; +use crate::arithmetic::{kate_division, powers}; use crate::helpers::SerdeCurveAffine; use crate::poly::commitment::ParamsProver; use crate::poly::commitment::Prover; @@ -8,7 +8,7 @@ use crate::poly::query::ProverQuery; use crate::poly::{commitment::Blind, Polynomial}; use crate::transcript::{EncodedChallenge, TranscriptWrite}; -use ff::{Field, PrimeField}; +use ff::PrimeField; use group::Curve; use halo2curves::pairing::Engine; use rand_core::RngCore; diff --git a/halo2_proofs/src/poly/kzg/multiopen/gwc/verifier.rs b/halo2_proofs/src/poly/kzg/multiopen/gwc/verifier.rs index 901904a575..ee01bd05bc 100644 --- a/halo2_proofs/src/poly/kzg/multiopen/gwc/verifier.rs +++ b/halo2_proofs/src/poly/kzg/multiopen/gwc/verifier.rs @@ -1,7 +1,7 @@ use std::fmt::Debug; use super::{construct_intermediate_sets, ChallengeU, ChallengeV}; -use crate::arithmetic::{eval_polynomial, lagrange_interpolate, powers, CurveAffine}; +use crate::arithmetic::powers; use crate::helpers::SerdeCurveAffine; use crate::poly::commitment::Verifier; use crate::poly::commitment::MSM; @@ -69,7 +69,7 @@ where let mut witness_with_aux = MSMKZG::::new(); for ((commitment_at_a_point, wi), power_of_u) in - commitment_data.iter().zip(w.into_iter()).zip(powers(*u)) + commitment_data.iter().zip(w).zip(powers(*u)) { assert!(!commitment_at_a_point.queries.is_empty()); let z = commitment_at_a_point.point; diff --git a/halo2_proofs/src/poly/kzg/multiopen/shplonk.rs b/halo2_proofs/src/poly/kzg/multiopen/shplonk.rs index 6b6a969b43..2af5ab5e43 100644 --- a/halo2_proofs/src/poly/kzg/multiopen/shplonk.rs +++ b/halo2_proofs/src/poly/kzg/multiopen/shplonk.rs @@ -199,7 +199,7 @@ mod proptests { col_indices in vec(select((0..num_cols).collect::>()), num_queries), point_indices in vec(select((0..num_points).collect::>()), num_queries) ) -> Vec<(usize, usize)> { - col_indices.into_iter().zip(point_indices.into_iter()).collect() + col_indices.into_iter().zip(point_indices).collect() } } diff --git a/halo2_proofs/src/poly/multiopen_test.rs b/halo2_proofs/src/poly/multiopen_test.rs index 5d6f4da3d8..47c6731167 100644 --- a/halo2_proofs/src/poly/multiopen_test.rs +++ b/halo2_proofs/src/poly/multiopen_test.rs @@ -14,7 +14,7 @@ mod test { Blake2bRead, Blake2bWrite, Challenge255, EncodedChallenge, Keccak256Read, Keccak256Write, TranscriptReadBuffer, TranscriptWriterBuffer, }; - use ff::{Field, PrimeField, WithSmallOrderMulGroup}; + use ff::WithSmallOrderMulGroup; use group::Curve; use rand_core::OsRng; diff --git a/halo2_proofs/tests/plonk_api.rs b/halo2_proofs/tests/plonk_api.rs index 1f1f0a2aa7..57ef88b403 100644 --- a/halo2_proofs/tests/plonk_api.rs +++ b/halo2_proofs/tests/plonk_api.rs @@ -514,7 +514,7 @@ fn plonk_api() { let cs = StandardPlonk::new(config); #[cfg(feature = "parallel_syn")] - let mut is_first_pass_vec = vec![true; 8]; + let mut is_first_pass_vec = [true; 8]; let _ = cs.public_input(&mut layouter, || Value::known(F::ONE + F::ONE))?; @@ -525,8 +525,7 @@ fn plonk_api() { layouter.assign_regions( || "regions", (0..8) - .into_iter() - .zip(is_first_pass_vec.chunks_mut(1).into_iter()) + .zip(is_first_pass_vec.chunks_mut(1)) .map(|(_, is_first_pass)| { |mut region: Region<'_, F>| -> Result<(), Error> { let n = 1 << 13; @@ -1222,6 +1221,7 @@ fn plonk_api_with_many_subregions() { impl Circuit for MyCircuit { type Config = PlonkConfig; type FloorPlanner = SimpleFloorPlanner; + type Params = (); fn without_witnesses(&self) -> Self { Self { @@ -1249,7 +1249,6 @@ fn plonk_api_with_many_subregions() { layouter.assign_regions( || "regions", (0..(1 << 14)) - .into_iter() .map(|_| { let mut is_first_pass = true; move |mut region: Region<'_, F>| -> Result<(), Error> {