mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 09:13:09 +00:00
updates
This commit is contained in:
parent
8440a0f5cb
commit
ebcfde1d81
@ -1,15 +1,10 @@
|
||||
use std::collections::BTreeMap;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use crate::field::field_types::RichField;
|
||||
use crate::field::{extension_field::Extendable, field_types::Field};
|
||||
use crate::field::extension_field::Extendable;
|
||||
use crate::gates::arithmetic_u32::{U32ArithmeticGate, NUM_U32_ARITHMETIC_OPS};
|
||||
use crate::gates::switch::SwitchGate;
|
||||
use crate::iop::generator::{GeneratedValues, SimpleGenerator};
|
||||
use crate::iop::target::Target;
|
||||
use crate::iop::witness::{PartitionWitness, Witness};
|
||||
use crate::plonk::circuit_builder::CircuitBuilder;
|
||||
use crate::util::bimap::bimap_from_lists;
|
||||
|
||||
pub struct U32Target(Target);
|
||||
|
||||
@ -20,8 +15,7 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
|
||||
pub fn add_virtual_u32_targets(&self, n: usize) -> Vec<U32Target> {
|
||||
self.add_virtual_targets(n)
|
||||
.iter()
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.map(U32Target)
|
||||
.collect()
|
||||
}
|
||||
@ -52,9 +46,6 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
Some((gate_index, copy)) => (gate_index, copy),
|
||||
};
|
||||
|
||||
let output_low = self.add_virtual_u32_target();
|
||||
let output_high = self.add_virtual_u32_target();
|
||||
|
||||
self.connect(
|
||||
Target::wire(
|
||||
gate_index,
|
||||
@ -73,27 +64,18 @@ impl<F: RichField + Extendable<D>, const D: usize> CircuitBuilder<F, D> {
|
||||
Target::wire(gate_index, U32ArithmeticGate::<F, D>::wire_ith_addend(copy)),
|
||||
z.0,
|
||||
);
|
||||
self.connect(
|
||||
Target::wire(
|
||||
gate_index,
|
||||
U32ArithmeticGate::<F, D>::wire_ith_output_low_half(copy),
|
||||
),
|
||||
output_low.0,
|
||||
);
|
||||
self.connect(
|
||||
Target::wire(
|
||||
gate_index,
|
||||
U32ArithmeticGate::<F, D>::wire_ith_output_high_half(copy),
|
||||
),
|
||||
output_high.0,
|
||||
);
|
||||
|
||||
let output_low = U32Target(Target::wire(
|
||||
gate_index,
|
||||
U32ArithmeticGate::<F, D>::wire_ith_output_low_half(copy),
|
||||
));
|
||||
let output_high = U32Target(Target::wire(
|
||||
gate_index,
|
||||
U32ArithmeticGate::<F, D>::wire_ith_output_high_half(copy),
|
||||
));
|
||||
|
||||
if copy == NUM_U32_ARITHMETIC_OPS - 1 {
|
||||
let gate = U32ArithmeticGate {
|
||||
_phantom: PhantomData,
|
||||
};
|
||||
let gate_index = self.add_gate(gate, vec![]);
|
||||
self.current_u32_arithmetic_gate = Some((gate_index, 0));
|
||||
self.current_u32_arithmetic_gate = None;
|
||||
} else {
|
||||
self.current_u32_arithmetic_gate = Some((gate_index, copy + 1));
|
||||
}
|
||||
|
||||
@ -309,8 +309,7 @@ impl<F: RichField + Extendable<D>, const D: usize> SimpleGenerator<F>
|
||||
.take(num_limbs)
|
||||
.collect();
|
||||
let output_limbs_f: Vec<_> = output_limbs_u64
|
||||
.iter()
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.map(F::from_canonical_u64)
|
||||
.collect();
|
||||
|
||||
@ -385,8 +384,7 @@ mod tests {
|
||||
output /= limb_base;
|
||||
}
|
||||
let mut output_limbs_f: Vec<_> = output_limbs
|
||||
.iter()
|
||||
.cloned()
|
||||
.into_iter()
|
||||
.map(F::from_canonical_u64)
|
||||
.collect();
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user