Skip to main content

kimchi/circuits/witness/
copy_cell.rs

1use alloc::{boxed::Box, vec::Vec};
2use ark_ff::Field;
3
4use super::{variables::Variables, WitnessCell};
5
6/// Witness cell copied from another witness cell
7pub struct CopyCell {
8    row: usize,
9    col: usize,
10}
11
12impl CopyCell {
13    /// Create a witness cell copied from the witness cell at position (row, col)
14    pub fn create(row: usize, col: usize) -> Box<CopyCell> {
15        Box::new(CopyCell { row, col })
16    }
17}
18
19impl<F: Field, const W: usize> WitnessCell<F, F, W> for CopyCell {
20    fn value(&self, witness: &mut [Vec<F>; W], _variables: &Variables<F>, _index: usize) -> F {
21        witness[self.col][self.row]
22    }
23}