mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-05 07:13:08 +00:00
Fixes
This commit is contained in:
parent
6d2c9b11a6
commit
5e3177520b
@ -120,7 +120,8 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
_ => {
|
||||
let num_addends = to_add.len();
|
||||
let gate = U32AddManyGate::<F, D>::new_from_config(&self.config, num_addends);
|
||||
let (gate_index, copy) = self.find_u32_add_many_gate(num_addends);
|
||||
let (gate_index, copy) =
|
||||
self.find_slot(gate, &[F::from_canonical_usize(num_addends)], &[]);
|
||||
|
||||
for j in 0..num_addends {
|
||||
self.connect(
|
||||
@ -153,7 +154,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
let num_addends = to_add.len();
|
||||
|
||||
let gate = U32AddManyGate::<F, D>::new_from_config(&self.config, num_addends);
|
||||
let (gate_index, copy) = self.find_u32_add_many_gate(num_addends);
|
||||
let (gate_index, copy) = self.find_slot(gate, &[F::from_canonical_usize(num_addends)], &[]);
|
||||
|
||||
for j in 0..num_addends {
|
||||
self.connect(
|
||||
|
||||
@ -47,7 +47,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
pub fn range_check_u32(&mut self, vals: Vec<U32Target>) {
|
||||
let num_input_limbs = vals.len();
|
||||
let gate = U32RangeCheckGate::<F, D>::new(num_input_limbs);
|
||||
let gate_index = self.add_gate(gate, vec![]);
|
||||
let gate_index = self.add_gate(gate, vec![], vec![]);
|
||||
|
||||
for i in 0..num_input_limbs {
|
||||
self.connect(
|
||||
|
||||
@ -5,6 +5,7 @@ use plonky2_util::ceil_div_usize;
|
||||
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::field::field_types::Field;
|
||||
use crate::gates::batchable::MultiOpsGate;
|
||||
use crate::gates::gate::Gate;
|
||||
use crate::gates::util::StridedConstraintConsumer;
|
||||
use crate::hash::hash_types::RichField;
|
||||
@ -271,6 +272,22 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for U32AddManyGate
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: RichField + Extendable<D>, const D: usize> MultiOpsGate<F, D> for U32AddManyGate<F, D> {
|
||||
fn num_ops(&self) -> usize {
|
||||
self.num_ops
|
||||
}
|
||||
|
||||
fn dependencies_ith_op(&self, gate_index: usize, i: usize) -> Vec<Target> {
|
||||
U32AddManyGenerator {
|
||||
gate: *self,
|
||||
gate_index,
|
||||
i,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
.dependencies()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
struct U32AddManyGenerator<F: RichField + Extendable<D>, const D: usize> {
|
||||
gate: U32AddManyGate<F, D>,
|
||||
|
||||
@ -239,11 +239,13 @@ impl<F: RichField + Extendable<D>, const D: usize> MultiOpsGate<F, D> for U32Ari
|
||||
}
|
||||
|
||||
fn dependencies_ith_op(&self, gate_index: usize, i: usize) -> Vec<Target> {
|
||||
vec![
|
||||
Target::wire(gate_index, self.wire_ith_multiplicand_0(i)),
|
||||
Target::wire(gate_index, self.wire_ith_multiplicand_1(i)),
|
||||
Target::wire(gate_index, self.wire_ith_addend(i)),
|
||||
]
|
||||
U32ArithmeticGenerator {
|
||||
gate: *self,
|
||||
gate_index,
|
||||
i,
|
||||
_phantom: PhantomData,
|
||||
}
|
||||
.dependencies()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -4,6 +4,7 @@ use plonky2_util::ceil_div_usize;
|
||||
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::field::field_types::Field;
|
||||
use crate::gates::batchable::MultiOpsGate;
|
||||
use crate::gates::gate::Gate;
|
||||
use crate::gates::util::StridedConstraintConsumer;
|
||||
use crate::hash::hash_types::RichField;
|
||||
@ -166,6 +167,16 @@ impl<F: RichField + Extendable<D>, const D: usize> Gate<F, D> for U32RangeCheckG
|
||||
}
|
||||
}
|
||||
|
||||
impl<F: RichField + Extendable<D>, const D: usize> MultiOpsGate<F, D> for U32RangeCheckGate<F, D> {
|
||||
fn num_ops(&self) -> usize {
|
||||
1
|
||||
}
|
||||
|
||||
fn dependencies_ith_op(&self, _gate_index: usize, _i: usize) -> Vec<Target> {
|
||||
unreachable!()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct U32RangeCheckGenerator<F: RichField + Extendable<D>, const D: usize> {
|
||||
gate: U32RangeCheckGate<F, D>,
|
||||
|
||||
@ -16,7 +16,6 @@ use crate::gadgets::arithmetic::BaseArithmeticOperation;
|
||||
use crate::gadgets::arithmetic_extension::ExtensionArithmeticOperation;
|
||||
use crate::gadgets::arithmetic_u32::U32Target;
|
||||
use crate::gadgets::polynomial::PolynomialCoeffsExtTarget;
|
||||
use crate::gates::add_many_u32::U32AddManyGate;
|
||||
use crate::gates::arithmetic_base::ArithmeticGate;
|
||||
use crate::gates::arithmetic_extension::ArithmeticExtensionGate;
|
||||
use crate::gates::batchable::{BatchableGate, CurrentSlot, GateRef};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user