diff --git a/plonky2/src/gates/batchable.rs b/plonky2/src/gates/batchable.rs new file mode 100644 index 00000000..b0aaa87a --- /dev/null +++ b/plonky2/src/gates/batchable.rs @@ -0,0 +1,28 @@ +use std::collections::HashMap; +use std::hash::Hash; +use std::sync::Arc; + +use plonky2_field::extension_field::Extendable; + +use crate::gates::gate::Gate; +use crate::hash::hash_types::RichField; +use crate::plonk::circuit_builder::CircuitBuilder; + +pub trait BatchableGate, const D: usize>: Gate { + type Parameters: Copy; + + fn find_available_slot(&self, params: Self::Parameters) -> (usize, usize); + + fn fill_gate(&self, params: Self::Parameters, builder: &mut CircuitBuilder); +} + +pub struct CurrentSlot, const D: usize, G: BatchableGate> { + current_slot: HashMap, +} + +// pub struct Yo, const D: usize>( +// CurrentSlot>, +// ); +pub struct GateRef, const D: usize>( + pub(crate) Arc>, +); diff --git a/plonky2/src/gates/mod.rs b/plonky2/src/gates/mod.rs index aae46dc5..3070b087 100644 --- a/plonky2/src/gates/mod.rs +++ b/plonky2/src/gates/mod.rs @@ -6,6 +6,7 @@ pub mod arithmetic_extension; pub mod arithmetic_u32; pub mod assert_le; pub mod base_sum; +pub mod batchable; pub mod comparison; pub mod constant; pub mod exponentiation; diff --git a/plonky2/src/plonk/circuit_builder.rs b/plonky2/src/plonk/circuit_builder.rs index 2456d6fd..cc4a19a4 100644 --- a/plonky2/src/plonk/circuit_builder.rs +++ b/plonky2/src/plonk/circuit_builder.rs @@ -18,6 +18,7 @@ use crate::gadgets::arithmetic_u32::U32Target; use crate::gates::arithmetic_base::ArithmeticGate; use crate::gates::arithmetic_extension::ArithmeticExtensionGate; use crate::gates::arithmetic_u32::U32ArithmeticGate; +use crate::gates::batchable::{BatchableGate, CurrentSlot}; use crate::gates::constant::ConstantGate; use crate::gates::gate::{Gate, GateInstance, GateRef, PrefixedGate}; use crate::gates::gate_tree::Tree; @@ -83,6 +84,7 @@ pub struct CircuitBuilder, const D: usize> { /// Memoized results of `arithmetic_extension` calls. pub(crate) arithmetic_results: HashMap, ExtensionTarget>, + // yo: Vec>, batched_gates: BatchedGates, }