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