kimchi/circuits/witness/
copy_shift_cell.rs

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