current progress

This commit is contained in:
Nicholas Ward 2021-07-06 10:28:39 -07:00
parent 50ffb1c48f
commit 2bee1c6721

View File

@ -10,9 +10,21 @@ use crate::wire::Wire;
use crate::witness::PartialWitness; use crate::witness::PartialWitness;
/// A gate for inserting a value into a list at a non-deterministic location. /// A gate for inserting a value into a list at a non-deterministic location.
pub struct InsertionGate; #[derive(Clone, Debug)]
pub(crate) struct InsertionGate<F: Extendable<D>, const D: usize> {
pub vec_size: usize,
pub _phantom: PhantomData<F>,
}
impl InsertionGate { impl InsertionGate {
pub fn new(vec_size: usize) -> GateRef<F, D> {
let gate = Self {
vec_size,
_phantom: PhantomData,
};
GateRef::new(gate)
}
pub fn get<F: Extendable<D>, const D: usize>() -> GateRef<F, D> { pub fn get<F: Extendable<D>, const D: usize>() -> GateRef<F, D> {
GateRef::new(InsertionGate) GateRef::new(InsertionGate)
@ -49,9 +61,10 @@ impl<F: Extendable<D>, const D: usize> Gate<F, D> for InsertionGate {
gate_index: usize, gate_index: usize,
local_constants: &[F], local_constants: &[F],
) -> Vec<Box<dyn WitnessGenerator<F>>> { ) -> Vec<Box<dyn WitnessGenerator<F>>> {
let gen = ConstantGenerator { let gen = InsertionGenerator::<F, D> {
gate_index, gate_index,
constant: local_constants[0], gate: self.clone(),
_phantom: PhantomData,
}; };
vec![Box::new(gen)] vec![Box::new(gen)]
} }
@ -76,7 +89,8 @@ impl<F: Extendable<D>, const D: usize> Gate<F, D> for InsertionGate {
#[derive(Debug)] #[derive(Debug)]
struct InsertionGenerator<F: Field> { struct InsertionGenerator<F: Field> {
gate_index: usize, gate_index: usize,
gate: InterpolationGate<F, D>,
_phantom: PhantomData<F>,
} }
impl<F: Field> SimpleGenerator<F> for InsertionGenerator<F> { impl<F: Field> SimpleGenerator<F> for InsertionGenerator<F> {