diff --git a/src/gadgets/arithmetic_extension.rs b/src/gadgets/arithmetic_extension.rs index b76a2482..1d65180e 100644 --- a/src/gadgets/arithmetic_extension.rs +++ b/src/gadgets/arithmetic_extension.rs @@ -25,24 +25,6 @@ impl, const D: usize> CircuitBuilder { second_multiplicand_1: ExtensionTarget, second_addend: ExtensionTarget, ) -> (ExtensionTarget, ExtensionTarget) { - // for et in &mut [ - // first_multiplicand_0, - // first_multiplicand_1, - // first_addend, - // second_multiplicand_0, - // second_multiplicand_1, - // second_addend, - // ] { - // for t in &mut et.0 { - // if let Target::Wire(Wire { gate: g, input }) = t { - // if *g > gate { - // *g = gate; - // *input += 8 * D; - // dbg!(*g, *t); - // } - // } - // } - // } let wire_third_multiplicand_0 = ExtensionTarget::from_range( gate, ArithmeticExtensionGate::::wires_third_multiplicand_0(), @@ -497,10 +479,26 @@ impl, const D: usize> CircuitBuilder { c: ExtensionTarget, ) -> ExtensionTarget { let zero = self.zero_extension(); - let gate = self.num_gates(); - let first_out = - ExtensionTarget::from_range(gate, ArithmeticExtensionGate::::wires_first_output()); - self.double_arithmetic_extension(F::ONE, F::ZERO, a, b, zero, c, first_out, zero) + let (gate, range) = if let Some((g, c_0, c_1)) = self.free_arithmetic { + if g == self.num_gates() - 1 && c_0 == F::ONE && c_1 == F::ONE { + (g, ArithmeticExtensionGate::::wires_third_output()) + } else { + ( + self.num_gates(), + ArithmeticExtensionGate::::wires_first_output(), + ) + } + } else { + ( + self.num_gates(), + ArithmeticExtensionGate::::wires_first_output(), + ) + }; + let first_out = ExtensionTarget::from_range(gate, range); + // let gate = self.num_gates(); + // let first_out = + // ExtensionTarget::from_range(gate, ArithmeticExtensionGate::::wires_first_output()); + self.double_arithmetic_extension(F::ONE, F::ONE, a, b, zero, c, first_out, zero) .1 } @@ -763,6 +761,31 @@ mod tests { use crate::plonk::circuit_data::CircuitConfig; use crate::plonk::verifier::verify; + #[test] + fn test_gaga() -> Result<()> { + type F = CrandallField; + type FF = QuarticCrandallField; + const D: usize = 4; + + let config = CircuitConfig { + num_routed_wires: 64, + ..CircuitConfig::large_config() + }; + + let mut pw = PartialWitness::new(config.num_wires); + let mut builder = CircuitBuilder::::new(config); + + let n = 6; + let vs = FF::rand_vec(n); + let ts = builder.add_virtual_extension_targets(n); + pw.set_extension_targets(&ts, &vs); + let mul0 = builder.mul_many_extension(&ts); + let data = builder.build(); + let proof = data.prove(pw)?; + + verify(proof, &data.verifier_only, &data.common) + } + #[test] fn test_mul_many() -> Result<()> { type F = CrandallField; @@ -818,7 +841,6 @@ mod tests { let yt = builder.constant_extension(y); let zt = builder.constant_extension(z); let comp_zt = builder.mul_extension(xt, yt); - dbg!(comp_zt); builder.add_marked(zt.into(), "yo"); builder.add_marked(comp_zt.into(), "ya"); builder.assert_equal_extension(zt, comp_zt); diff --git a/src/plonk/recursive_verifier.rs b/src/plonk/recursive_verifier.rs index 792c8270..ab8554b4 100644 --- a/src/plonk/recursive_verifier.rs +++ b/src/plonk/recursive_verifier.rs @@ -97,13 +97,8 @@ impl, const D: usize> CircuitBuilder { .chunks(inner_common_data.quotient_degree_factor) .enumerate() { - dbg!(chunk.len()); let recombined_quotient = scale.reduce(chunk, self); - self.add_marked(z_h_zeta.into(), &format!("zhz {}", i)); - self.add_marked(recombined_quotient.into(), &format!("recomb {}", i)); let computed_vanishing_poly = self.mul_extension(z_h_zeta, recombined_quotient); - self.add_marked(vanishing_polys_zeta[i].into(), &format!("yo {}", i)); - self.add_marked(computed_vanishing_poly.into(), &format!("ya {}", i)); self.named_assert_equal_extension( vanishing_polys_zeta[i], computed_vanishing_poly, diff --git a/src/plonk/vanishing_poly.rs b/src/plonk/vanishing_poly.rs index 1f7526e2..a2a97d4b 100644 --- a/src/plonk/vanishing_poly.rs +++ b/src/plonk/vanishing_poly.rs @@ -363,8 +363,9 @@ pub(crate) fn eval_vanishing_poly_recursively, const D: usize>( .chunks(max_degree) .zip(partial_product_check.iter_mut()) .for_each(|(d, q)| { - let tmp = builder.mul_many_extension(d); - *q = builder.mul_extension(*q, tmp); + let mut v = d.to_vec(); + v.push(*q); + *q = builder.mul_many_extension(&v); }); vanishing_partial_products_terms.extend(partial_product_check); @@ -382,9 +383,6 @@ pub(crate) fn eval_vanishing_poly_recursively, const D: usize>( ] .concat(); - for (i, &v) in vanishing_terms.iter().enumerate() { - builder.add_marked(v.into(), &format!("v {}", i)); - } alphas .iter() .map(|&alpha| { diff --git a/src/util/reducing.rs b/src/util/reducing.rs index 479e7e39..3d10956a 100644 --- a/src/util/reducing.rs +++ b/src/util/reducing.rs @@ -176,8 +176,6 @@ impl ReducingFactorTarget { terms_vec.reverse(); let mut acc = zero; - let mut countt = 0; - dbg!(terms_vec.len()); for pair in terms_vec.chunks(2) { // We will route the output of the first arithmetic operation to the multiplicand of the // second, i.e. we compute the following: @@ -212,9 +210,6 @@ impl ReducingFactorTarget { pair[1], ) .1; - // dbg!(countt, acc); - // builder.add_marked(acc.into(), &format!("acc {}", countt)); - countt += 1; } acc }