mirror of
https://github.com/logos-storage/plonky2.git
synced 2026-01-09 09:13:09 +00:00
First try
This commit is contained in:
parent
4f2ac97b0a
commit
5caf92a39a
28
plonky2/src/gates/batchable.rs
Normal file
28
plonky2/src/gates/batchable.rs
Normal file
@ -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<F: RichField + Extendable<D>, const D: usize>: Gate<F, D> {
|
||||
type Parameters: Copy;
|
||||
|
||||
fn find_available_slot(&self, params: Self::Parameters) -> (usize, usize);
|
||||
|
||||
fn fill_gate(&self, params: Self::Parameters, builder: &mut CircuitBuilder<F, D>);
|
||||
}
|
||||
|
||||
pub struct CurrentSlot<F: RichField + Extendable<D>, const D: usize, G: BatchableGate<F, D>> {
|
||||
current_slot: HashMap<G::Parameters, (usize, usize)>,
|
||||
}
|
||||
|
||||
// pub struct Yo<F: RichField + Extendable<D>, const D: usize>(
|
||||
// CurrentSlot<F, D, dyn BatchableGate<F, D>>,
|
||||
// );
|
||||
pub struct GateRef<F: RichField + Extendable<D>, const D: usize>(
|
||||
pub(crate) Arc<dyn BatchableGate<F, D>>,
|
||||
);
|
||||
@ -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;
|
||||
|
||||
@ -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<F: RichField + Extendable<D>, const D: usize> {
|
||||
/// Memoized results of `arithmetic_extension` calls.
|
||||
pub(crate) arithmetic_results: HashMap<ExtensionArithmeticOperation<F, D>, ExtensionTarget<D>>,
|
||||
|
||||
// yo: Vec<Yo<F, D, dyn Copy>>,
|
||||
batched_gates: BatchedGates<F, D>,
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user