diff --git a/src/gadgets/arithmetic_extension.rs b/src/gadgets/arithmetic_extension.rs index 30c49bf4..cc82be68 100644 --- a/src/gadgets/arithmetic_extension.rs +++ b/src/gadgets/arithmetic_extension.rs @@ -45,8 +45,10 @@ impl, const D: usize> CircuitBuilder { } let result = if self.target_as_constant_ext(addend) == Some(F::Extension::ZERO) { + // If the addend is zero, we use a multiplication gate. self.add_mul_extension_operation(operation) } else { + // Otherwise, we use an arithmetic gate. self.add_arithmetic_extension_operation(operation) }; // Otherwise, we must actually perform the operation using an ArithmeticExtensionGate slot. @@ -579,7 +581,7 @@ mod tests { for (&v, &t) in vs.iter().zip(&ts) { pw.set_extension_target(t, v); } - // let mul0 = builder.mul_many_extension(&ts); + let mul0 = builder.mul_many_extension(&ts); let mul1 = { let mut acc = builder.one_extension(); for &t in &ts { @@ -589,7 +591,7 @@ mod tests { }; let mul2 = builder.constant_extension(vs.into_iter().product()); - // builder.connect_extension(mul0, mul1); + builder.connect_extension(mul0, mul1); builder.connect_extension(mul1, mul2); let data = builder.build(); diff --git a/src/gates/multiplication_extension.rs b/src/gates/multiplication_extension.rs index 16cc6315..4c385b79 100644 --- a/src/gates/multiplication_extension.rs +++ b/src/gates/multiplication_extension.rs @@ -12,11 +12,11 @@ use crate::plonk::circuit_builder::CircuitBuilder; use crate::plonk::circuit_data::CircuitConfig; use crate::plonk::vars::{EvaluationTargets, EvaluationVars, EvaluationVarsBase}; -/// A gate which can perform a weighted multiply-add, i.e. `result = c0 x y + c1 z`. If the config +/// A gate which can perform a weighted multiplication, i.e. `result = c0 x y`. If the config /// supports enough routed wires, it can support several such operations in one gate. #[derive(Debug)] pub struct MulExtensionGate { - /// Number of arithmetic operations performed by an arithmetic gate. + /// Number of multiplications performed by the gate. pub num_ops: usize, } diff --git a/src/plonk/circuit_builder.rs b/src/plonk/circuit_builder.rs index eda31ece..730699b9 100644 --- a/src/plonk/circuit_builder.rs +++ b/src/plonk/circuit_builder.rs @@ -71,7 +71,7 @@ pub struct CircuitBuilder, const D: usize> { marked_targets: Vec>, /// Generators used to generate the witness. - pub generators: Vec>>, + generators: Vec>>, constants_to_targets: HashMap, targets_to_constants: HashMap,