Skip to main content

kimchi/circuits/witness/
variable_cell.rs

1use super::{variables::Variables, WitnessCell};
2use alloc::{boxed::Box, vec::Vec};
3use ark_ff::Field;
4
5/// Witness cell assigned from a variable
6/// See [Variables] for more details
7pub struct VariableCell<'a> {
8    name: &'a str,
9}
10
11impl<'a> VariableCell<'a> {
12    /// Create witness cell assigned from a variable name
13    pub fn create(name: &'a str) -> Box<VariableCell<'a>> {
14        Box::new(VariableCell { name })
15    }
16}
17
18impl<'a, F: Field, const W: usize> WitnessCell<F, F, W> for VariableCell<'a> {
19    fn value(&self, _witness: &mut [Vec<F>; W], variables: &Variables<F>, _index: usize) -> F {
20        variables[self.name]
21    }
22}