This commit is contained in:
wborgeaud 2021-08-13 15:22:03 +02:00
parent 75ad055f40
commit 7da4412de5
4 changed files with 48 additions and 38 deletions

View File

@ -25,24 +25,6 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
second_multiplicand_1: ExtensionTarget<D>,
second_addend: ExtensionTarget<D>,
) -> (ExtensionTarget<D>, ExtensionTarget<D>) {
// 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::<D>::wires_third_multiplicand_0(),
@ -497,10 +479,26 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
c: ExtensionTarget<D>,
) -> ExtensionTarget<D> {
let zero = self.zero_extension();
let gate = self.num_gates();
let first_out =
ExtensionTarget::from_range(gate, ArithmeticExtensionGate::<D>::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::<D>::wires_third_output())
} else {
(
self.num_gates(),
ArithmeticExtensionGate::<D>::wires_first_output(),
)
}
} else {
(
self.num_gates(),
ArithmeticExtensionGate::<D>::wires_first_output(),
)
};
let first_out = ExtensionTarget::from_range(gate, range);
// let gate = self.num_gates();
// let first_out =
// ExtensionTarget::from_range(gate, ArithmeticExtensionGate::<D>::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::<F, D>::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);

View File

@ -97,13 +97,8 @@ impl<F: Extendable<D>, const D: usize> CircuitBuilder<F, D> {
.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,

View File

@ -363,8 +363,9 @@ pub(crate) fn eval_vanishing_poly_recursively<F: Extendable<D>, 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<F: Extendable<D>, const D: usize>(
]
.concat();
for (i, &v) in vanishing_terms.iter().enumerate() {
builder.add_marked(v.into(), &format!("v {}", i));
}
alphas
.iter()
.map(|&alpha| {

View File

@ -176,8 +176,6 @@ impl<const D: usize> ReducingFactorTarget<D> {
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<const D: usize> ReducingFactorTarget<D> {
pair[1],
)
.1;
// dbg!(countt, acc);
// builder.add_marked(acc.into(), &format!("acc {}", countt));
countt += 1;
}
acc
}