diff --git a/src/field/crandall_field.rs b/src/field/crandall_field.rs index 051b0fd0..36cea17b 100644 --- a/src/field/crandall_field.rs +++ b/src/field/crandall_field.rs @@ -4,7 +4,6 @@ use std::hash::{Hash, Hasher}; use std::iter::{Product, Sum}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use itertools::Itertools; use num::bigint::BigUint; use num::Integer; use rand::Rng; diff --git a/src/field/extension_field/quadratic.rs b/src/field/extension_field/quadratic.rs index 5324ad2a..fbbb535f 100644 --- a/src/field/extension_field/quadratic.rs +++ b/src/field/extension_field/quadratic.rs @@ -3,7 +3,6 @@ use std::hash::Hash; use std::iter::{Product, Sum}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use itertools::Itertools; use num::bigint::BigUint; use rand::Rng; use serde::{Deserialize, Serialize}; diff --git a/src/field/extension_field/quartic.rs b/src/field/extension_field/quartic.rs index f38f103a..ef356232 100644 --- a/src/field/extension_field/quartic.rs +++ b/src/field/extension_field/quartic.rs @@ -3,7 +3,6 @@ use std::hash::Hash; use std::iter::{Product, Sum}; use std::ops::{Add, AddAssign, Div, DivAssign, Mul, MulAssign, Neg, Sub, SubAssign}; -use itertools::Itertools; use num::bigint::BigUint; use num::traits::Pow; use rand::Rng; diff --git a/src/field/field_testing.rs b/src/field/field_testing.rs index ffab1d9d..d0930fb9 100644 --- a/src/field/field_testing.rs +++ b/src/field/field_testing.rs @@ -151,7 +151,7 @@ macro_rules! test_field_arithmetic { ($field:ty) => { mod field_arithmetic { use num::{bigint::BigUint, One, Zero}; - use rand::{thread_rng, Rng}; + use rand::Rng; use crate::field::field::Field; diff --git a/src/gadgets/arithmetic.rs b/src/gadgets/arithmetic.rs index bf16a820..48104117 100644 --- a/src/gadgets/arithmetic.rs +++ b/src/gadgets/arithmetic.rs @@ -181,11 +181,7 @@ impl, const D: usize> CircuitBuilder { let gate = ExponentiationGate::new(self.config.clone()); let gate_index = self.add_gate(gate.clone(), vec![]); - let two = self.constant(F::TWO); - let exponent = reduce_with_powers_recursive(self, &exp_bits_vec[..], two); - self.route(base, Target::wire(gate_index, gate.wire_base())); - self.route(exponent, Target::wire(gate_index, gate.wire_power())); exp_bits_vec.iter().enumerate().for_each(|(i, bit)| { self.route(*bit, Target::wire(gate_index, gate.wire_power_bit(i))); }); diff --git a/src/gadgets/insert.rs b/src/gadgets/insert.rs index 8406b83a..e9345ef7 100644 --- a/src/gadgets/insert.rs +++ b/src/gadgets/insert.rs @@ -1,5 +1,3 @@ -use std::marker::PhantomData; - use crate::circuit_builder::CircuitBuilder; use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::Extendable; diff --git a/src/gates/base_sum.rs b/src/gates/base_sum.rs index 3ec017f3..723cc84f 100644 --- a/src/gates/base_sum.rs +++ b/src/gates/base_sum.rs @@ -4,7 +4,7 @@ use crate::circuit_builder::CircuitBuilder; use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::Extendable; use crate::field::field::Field; -use crate::gates::gate::{Gate, GateRef}; +use crate::gates::gate::Gate; use crate::generator::{GeneratedValues, SimpleGenerator, WitnessGenerator}; use crate::plonk_common::{reduce_with_powers, reduce_with_powers_ext_recursive}; use crate::target::Target; @@ -186,7 +186,6 @@ impl SimpleGenerator for BaseSplitGenerator { mod tests { use crate::field::crandall_field::CrandallField; use crate::gates::base_sum::BaseSumGate; - use crate::gates::gate::GateRef; use crate::gates::gate_testing::test_low_degree; #[test] diff --git a/src/gates/constant.rs b/src/gates/constant.rs index 1d8f50dd..11592c90 100644 --- a/src/gates/constant.rs +++ b/src/gates/constant.rs @@ -2,7 +2,7 @@ use crate::circuit_builder::CircuitBuilder; use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::Extendable; use crate::field::field::Field; -use crate::gates::gate::{Gate, GateRef}; +use crate::gates::gate::Gate; use crate::generator::{GeneratedValues, SimpleGenerator, WitnessGenerator}; use crate::target::Target; use crate::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase}; diff --git a/src/gates/exponentiation.rs b/src/gates/exponentiation.rs index a7cd8b1c..d114874a 100644 --- a/src/gates/exponentiation.rs +++ b/src/gates/exponentiation.rs @@ -39,23 +39,19 @@ impl, const D: usize> ExponentiationGate { 0 } - pub fn wire_power(&self) -> usize { - 1 - } - /// The `i`th bit of the exponent, in little-endian order. pub fn wire_power_bit(&self, i: usize) -> usize { debug_assert!(i < self.num_power_bits); - 2 + i + 1 + i } pub fn wire_output(&self) -> usize { - 2 + self.num_power_bits + 1 + self.num_power_bits } pub fn wire_intermediate_value(&self, i: usize) -> usize { debug_assert!(i < self.num_power_bits); - 3 + self.num_power_bits + i + 2 + self.num_power_bits + i } } @@ -66,7 +62,6 @@ impl, const D: usize> Gate for ExponentiationGate { fn eval_unfiltered(&self, vars: EvaluationVars) -> Vec { let base = vars.local_wires[self.wire_base()]; - let power = vars.local_wires[self.wire_power()]; let power_bits: Vec<_> = (0..self.num_power_bits) .map(|i| vars.local_wires[self.wire_power_bit(i)]) @@ -79,9 +74,6 @@ impl, const D: usize> Gate for ExponentiationGate { let mut constraints = Vec::new(); - let computed_power = reduce_with_powers(&power_bits, F::Extension::TWO); - constraints.push(power - computed_power); - for i in 0..self.num_power_bits { let prev_intermediate_value = if i == 0 { F::Extension::ONE @@ -105,7 +97,6 @@ impl, const D: usize> Gate for ExponentiationGate { fn eval_unfiltered_base(&self, vars: EvaluationVarsBase) -> Vec { let base = vars.local_wires[self.wire_base()]; - let power = vars.local_wires[self.wire_power()]; let power_bits: Vec<_> = (0..self.num_power_bits) .map(|i| vars.local_wires[self.wire_power_bit(i)]) @@ -118,9 +109,6 @@ impl, const D: usize> Gate for ExponentiationGate { let mut constraints = Vec::new(); - let computed_power = reduce_with_powers(&power_bits, F::TWO); - constraints.push(power - computed_power); - for i in 0..self.num_power_bits { let prev_intermediate_value = if i == 0 { F::ONE @@ -148,7 +136,6 @@ impl, const D: usize> Gate for ExponentiationGate { vars: EvaluationTargets, ) -> Vec> { let base = vars.local_wires[self.wire_base()]; - let power = vars.local_wires[self.wire_power()]; let power_bits: Vec<_> = (0..self.num_power_bits) .map(|i| vars.local_wires[self.wire_power_bit(i)]) @@ -161,11 +148,6 @@ impl, const D: usize> Gate for ExponentiationGate { let mut constraints = Vec::new(); - let two = builder.constant(F::TWO); - let computed_power = reduce_with_powers_ext_recursive(builder, &power_bits, two); - let power_diff = builder.sub_extension(power, computed_power); - constraints.push(power_diff); - let one = builder.constant_extension(F::Extension::ONE); for i in 0..self.num_power_bits { let prev_intermediate_value = if i == 0 { @@ -216,7 +198,7 @@ impl, const D: usize> Gate for ExponentiationGate { } fn num_constraints(&self) -> usize { - self.num_power_bits + 2 + self.num_power_bits + 1 } } @@ -232,7 +214,6 @@ impl, const D: usize> SimpleGenerator for ExponentiationGene let mut deps = Vec::with_capacity(self.gate.num_power_bits + 2); deps.push(local_target(self.gate.wire_base())); - deps.push(local_target(self.gate.wire_power())); for i in 0..self.gate.num_power_bits { deps.push(local_target(self.gate.wire_power_bit(i))); } @@ -281,7 +262,7 @@ impl, const D: usize> SimpleGenerator for ExponentiationGene mod tests { use std::marker::PhantomData; - use rand::{thread_rng, Rng}; + use rand::Rng; use crate::circuit_data::CircuitConfig; use crate::field::crandall_field::CrandallField; @@ -305,12 +286,11 @@ mod tests { }; assert_eq!(gate.wire_base(), 0); - assert_eq!(gate.wire_power(), 1); - assert_eq!(gate.wire_power_bit(0), 2); - assert_eq!(gate.wire_power_bit(4), 6); - assert_eq!(gate.wire_output(), 7); - assert_eq!(gate.wire_intermediate_value(0), 8); - assert_eq!(gate.wire_intermediate_value(4), 12); + assert_eq!(gate.wire_power_bit(0), 1); + assert_eq!(gate.wire_power_bit(4), 5); + assert_eq!(gate.wire_output(), 6); + assert_eq!(gate.wire_intermediate_value(0), 7); + assert_eq!(gate.wire_intermediate_value(4), 11); } #[test] @@ -350,7 +330,6 @@ mod tests { let num_power_bits = power_bits.len(); - let power_F = F::from_canonical_u64(power); let power_bits_F: Vec<_> = power_bits .iter() .map(|b| F::from_canonical_u64(*b)) @@ -358,7 +337,6 @@ mod tests { let mut v = Vec::new(); v.push(base); - v.push(power_F); v.extend(power_bits_F.clone()); let mut intermediate_values = Vec::new(); diff --git a/src/gates/gate_testing.rs b/src/gates/gate_testing.rs index 4a6c80df..e0b72477 100644 --- a/src/gates/gate_testing.rs +++ b/src/gates/gate_testing.rs @@ -1,6 +1,6 @@ use crate::field::extension_field::Extendable; use crate::field::field::Field; -use crate::gates::gate::{Gate, GateRef}; +use crate::gates::gate::Gate; use crate::polynomial::polynomial::{PolynomialCoeffs, PolynomialValues}; use crate::proof::Hash; use crate::util::{log2_ceil, transpose}; diff --git a/src/gates/gmimc.rs b/src/gates/gmimc.rs index 2c8ca297..ec2aab6c 100644 --- a/src/gates/gmimc.rs +++ b/src/gates/gmimc.rs @@ -334,7 +334,7 @@ mod tests { use crate::field::crandall_field::CrandallField; use crate::field::extension_field::quartic::QuarticCrandallField; use crate::field::field::Field; - use crate::gates::gate::{Gate, GateRef}; + use crate::gates::gate::Gate; use crate::gates::gate_testing::test_low_degree; use crate::gates::gmimc::{GMiMCGate, W}; use crate::generator::generate_partial_witness; diff --git a/src/gates/interpolation.rs b/src/gates/interpolation.rs index 47fa6d4a..36e90c53 100644 --- a/src/gates/interpolation.rs +++ b/src/gates/interpolation.rs @@ -8,7 +8,7 @@ use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::{Extendable, FieldExtension}; use crate::field::interpolation::interpolant; use crate::gadgets::polynomial::PolynomialCoeffsExtAlgebraTarget; -use crate::gates::gate::{Gate, GateRef}; +use crate::gates::gate::Gate; use crate::generator::{GeneratedValues, SimpleGenerator, WitnessGenerator}; use crate::polynomial::polynomial::PolynomialCoeffs; use crate::target::Target; @@ -288,7 +288,6 @@ mod tests { use crate::field::crandall_field::CrandallField; use crate::field::extension_field::quartic::QuarticCrandallField; - use crate::field::extension_field::FieldExtension; use crate::field::field::Field; use crate::gates::gate::Gate; use crate::gates::gate_testing::test_low_degree; @@ -319,7 +318,6 @@ mod tests { #[test] fn low_degree() { - type F = CrandallField; test_low_degree::(InterpolationGate::new(4)); } diff --git a/src/gates/noop.rs b/src/gates/noop.rs index 0787c9fa..3245f7b7 100644 --- a/src/gates/noop.rs +++ b/src/gates/noop.rs @@ -1,7 +1,7 @@ use crate::circuit_builder::CircuitBuilder; use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::Extendable; -use crate::gates::gate::{Gate, GateRef}; +use crate::gates::gate::Gate; use crate::generator::WitnessGenerator; use crate::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase}; diff --git a/src/gates/public_input.rs b/src/gates/public_input.rs index e8299b26..ae9d2377 100644 --- a/src/gates/public_input.rs +++ b/src/gates/public_input.rs @@ -3,7 +3,7 @@ use std::ops::Range; use crate::circuit_builder::CircuitBuilder; use crate::field::extension_field::target::ExtensionTarget; use crate::field::extension_field::Extendable; -use crate::gates::gate::{Gate, GateRef}; +use crate::gates::gate::Gate; use crate::generator::WitnessGenerator; use crate::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase}; diff --git a/src/gates/reducing.rs b/src/gates/reducing.rs index 0129a156..cea7267a 100644 --- a/src/gates/reducing.rs +++ b/src/gates/reducing.rs @@ -219,7 +219,6 @@ mod tests { #[test] fn low_degree() { - type F = CrandallField; test_low_degree::(ReducingGate::new(22)); } } diff --git a/src/prover.rs b/src/prover.rs index 7d209667..865489a0 100644 --- a/src/prover.rs +++ b/src/prover.rs @@ -129,7 +129,7 @@ pub(crate) fn prove, const D: usize>( &gammas, &alphas, ), - "to compute vanishing polys" + "to compute quotient polys" ); // Compute the quotient polynomials, aka `t` in the Plonk paper. @@ -146,7 +146,7 @@ pub(crate) fn prove, const D: usize>( quotient_poly.chunks(degree) }) .collect(), - "to compute quotient polys" + "to split up quotient polys" ); let quotient_polys_commitment = timed!(