diff --git a/src/gates/reducing.rs b/src/gates/reducing.rs index f85bb3c2..9404cf93 100644 --- a/src/gates/reducing.rs +++ b/src/gates/reducing.rs @@ -34,15 +34,19 @@ impl ReducingGate { pub fn wires_old_acc() -> Range { 2 * D..3 * D } - pub const START_COEFFS: usize = 3 * D; + const START_COEFFS: usize = 3 * D; pub fn wires_coeffs(&self) -> Range { Self::START_COEFFS..Self::START_COEFFS + self.num_coeffs } - pub fn start_accs(&self) -> usize { + fn start_accs(&self) -> usize { Self::START_COEFFS + self.num_coeffs } - pub fn wires_accs(&self, i: usize) -> Range { - self.start_accs() + 4 * i..self.start_accs() + 4 * (i + 1) + fn wires_accs(&self, i: usize) -> Range { + if i == self.num_coeffs - 1 { + // The last accumulator is the output. + return Self::wires_output(); + } + self.start_accs() + D * i..self.start_accs() + D * (i + 1) } } @@ -70,7 +74,6 @@ impl, const D: usize> Gate for ReducingGate { acc = accs[i]; } - constraints.push(output - acc); constraints .into_iter() .flat_map(|alg| alg.to_basefield_array()) @@ -96,7 +99,6 @@ impl, const D: usize> Gate for ReducingGate { acc = accs[i]; } - constraints.push(output - acc); constraints .into_iter() .flat_map(|alg| alg.to_basefield_array()) @@ -130,7 +132,6 @@ impl, const D: usize> Gate for ReducingGate { acc = accs[i]; } - constraints.push(builder.sub_ext_algebra(output, acc)); constraints .into_iter() .flat_map(|alg| alg.to_ext_target_array()) @@ -216,14 +217,8 @@ impl, const D: usize> SimpleGenerator for ReducingGenerator< #[cfg(test)] 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; use crate::gates::reducing::ReducingGate; - use crate::proof::Hash; - use crate::vars::EvaluationVars; #[test] fn low_degree() { diff --git a/src/util/reducing.rs b/src/util/reducing.rs index 1b01763a..6a4a1168 100644 --- a/src/util/reducing.rs +++ b/src/util/reducing.rs @@ -108,8 +108,6 @@ impl ReducingFactorTarget { self.count += terms.len() as u64; let zero = builder.zero(); let zero_ext = builder.zero_extension(); - let mut gate; - let mut gate_index; let mut acc = zero_ext; let mut reversed_terms = terms.to_vec(); while reversed_terms.len() % max_coeffs_len != 0 { @@ -117,8 +115,8 @@ impl ReducingFactorTarget { } reversed_terms.reverse(); for chunk in reversed_terms.chunks_exact(max_coeffs_len) { - gate = ReducingGate::new(max_coeffs_len); - gate_index = builder.add_gate(gate.clone(), Vec::new()); + let gate = ReducingGate::new(max_coeffs_len); + let gate_index = builder.add_gate(gate.clone(), Vec::new()); builder.route_extension( self.base, @@ -227,7 +225,6 @@ mod tests { use crate::circuit_data::CircuitConfig; use crate::field::crandall_field::CrandallField; use crate::field::extension_field::quartic::QuarticCrandallField; - use crate::field::extension_field::FieldExtension; use crate::verifier::verify; use crate::witness::PartialWitness;