kimchi/circuits/witness/
copy_bits_cell.rs1use ark_ff::Field;
2use o1_utils::FieldHelpers;
3
4use super::{variables::Variables, WitnessCell};
5
6pub struct CopyBitsCell {
8 row: usize,
9 col: usize,
10 start: usize, end: usize, }
13
14impl CopyBitsCell {
15 pub fn create(row: usize, col: usize, start: usize, end: usize) -> Box<CopyBitsCell> {
17 Box::new(CopyBitsCell {
18 row,
19 col,
20 start,
21 end,
22 })
23 }
24}
25
26impl<F: Field, const W: usize> WitnessCell<F, F, W> for CopyBitsCell {
27 fn value(&self, witness: &mut [Vec<F>; W], _variables: &Variables<F>, _index: usize) -> F {
28 F::from_bits(&witness[self.col][self.row].to_bits()[self.start..self.end])
29 .expect("failed to deserialize field bits for copy bits cell")
30 }
31}