mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-07 16:23:12 +00:00
Comments
This commit is contained in:
parent
4f11713c49
commit
22f4c18083
@ -45,8 +45,10 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
}
|
||||
|
||||
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();
|
||||
|
||||
@ -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<const D: usize> {
|
||||
/// Number of arithmetic operations performed by an arithmetic gate.
|
||||
/// Number of multiplications performed by the gate.
|
||||
pub num_ops: usize,
|
||||
}
|
||||
|
||||
|
||||
@ -71,7 +71,7 @@ pub struct CircuitBuilder<F: RichField + Extendable<D>, const D: usize> {
|
||||
marked_targets: Vec<MarkedTargets<D>>,
|
||||
|
||||
/// Generators used to generate the witness.
|
||||
pub generators: Vec<Box<dyn WitnessGenerator<F>>>,
|
||||
generators: Vec<Box<dyn WitnessGenerator<F>>>,
|
||||
|
||||
constants_to_targets: HashMap<F, Target>,
|
||||
targets_to_constants: HashMap<Target, F>,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user