From 1491b17747dda19e5e2b80b03a043e925a896cb4 Mon Sep 17 00:00:00 2001 From: querolita Date: Mon, 23 Oct 2023 17:48:28 +0200 Subject: [PATCH] switch N to W for column width --- kimchi/src/circuits/witness/constant_cell.rs | 4 ++-- kimchi/src/circuits/witness/copy_bits_cell.rs | 4 ++-- kimchi/src/circuits/witness/copy_cell.rs | 4 ++-- .../src/circuits/witness/copy_shift_cell.rs | 4 ++-- kimchi/src/circuits/witness/index_cell.rs | 4 ++-- kimchi/src/circuits/witness/mod.rs | 22 +++++++++---------- .../circuits/witness/variable_bits_cell.rs | 4 ++-- kimchi/src/circuits/witness/variable_cell.rs | 4 ++-- 8 files changed, 25 insertions(+), 25 deletions(-) diff --git a/kimchi/src/circuits/witness/constant_cell.rs b/kimchi/src/circuits/witness/constant_cell.rs index f35d2179f4..ea14b5de8c 100644 --- a/kimchi/src/circuits/witness/constant_cell.rs +++ b/kimchi/src/circuits/witness/constant_cell.rs @@ -13,8 +13,8 @@ impl ConstantCell { } } -impl WitnessCell for ConstantCell { - fn value(&self, _witness: &mut [Vec; N], _variables: &Variables, _index: usize) -> F { +impl WitnessCell for ConstantCell { + fn value(&self, _witness: &mut [Vec; W], _variables: &Variables, _index: usize) -> F { self.value } } diff --git a/kimchi/src/circuits/witness/copy_bits_cell.rs b/kimchi/src/circuits/witness/copy_bits_cell.rs index 69aae2a975..964e2f26bf 100644 --- a/kimchi/src/circuits/witness/copy_bits_cell.rs +++ b/kimchi/src/circuits/witness/copy_bits_cell.rs @@ -23,8 +23,8 @@ impl CopyBitsCell { } } -impl WitnessCell for CopyBitsCell { - fn value(&self, witness: &mut [Vec; N], _variables: &Variables, _index: usize) -> F { +impl WitnessCell for CopyBitsCell { + fn value(&self, witness: &mut [Vec; W], _variables: &Variables, _index: usize) -> F { F::from_bits(&witness[self.col][self.row].to_bits()[self.start..self.end]) .expect("failed to deserialize field bits for copy bits cell") } diff --git a/kimchi/src/circuits/witness/copy_cell.rs b/kimchi/src/circuits/witness/copy_cell.rs index fd594a3844..ffa8339094 100644 --- a/kimchi/src/circuits/witness/copy_cell.rs +++ b/kimchi/src/circuits/witness/copy_cell.rs @@ -15,8 +15,8 @@ impl CopyCell { } } -impl WitnessCell for CopyCell { - fn value(&self, witness: &mut [Vec; N], _variables: &Variables, _index: usize) -> F { +impl WitnessCell for CopyCell { + fn value(&self, witness: &mut [Vec; W], _variables: &Variables, _index: usize) -> F { witness[self.col][self.row] } } diff --git a/kimchi/src/circuits/witness/copy_shift_cell.rs b/kimchi/src/circuits/witness/copy_shift_cell.rs index b285092d2f..b0ed5d055a 100644 --- a/kimchi/src/circuits/witness/copy_shift_cell.rs +++ b/kimchi/src/circuits/witness/copy_shift_cell.rs @@ -15,8 +15,8 @@ impl CopyShiftCell { } } -impl WitnessCell for CopyShiftCell { - fn value(&self, witness: &mut [Vec; N], _variables: &Variables, _index: usize) -> F { +impl WitnessCell for CopyShiftCell { + fn value(&self, witness: &mut [Vec; W], _variables: &Variables, _index: usize) -> F { F::from(2u32).pow([self.shift]) * witness[self.col][self.row] } } diff --git a/kimchi/src/circuits/witness/index_cell.rs b/kimchi/src/circuits/witness/index_cell.rs index a039354c8f..9d6ebefea5 100644 --- a/kimchi/src/circuits/witness/index_cell.rs +++ b/kimchi/src/circuits/witness/index_cell.rs @@ -18,8 +18,8 @@ impl<'a> IndexCell<'a> { } } -impl<'a, const N: usize, F: Field> WitnessCell> for IndexCell<'a> { - fn value(&self, _witness: &mut [Vec; N], variables: &Variables>, index: usize) -> F { +impl<'a, const W: usize, F: Field> WitnessCell> for IndexCell<'a> { + fn value(&self, _witness: &mut [Vec; W], variables: &Variables>, index: usize) -> F { assert!(index < self.length, "index out of bounds of `IndexCell`"); variables[self.name][index] } diff --git a/kimchi/src/circuits/witness/mod.rs b/kimchi/src/circuits/witness/mod.rs index ec470330d9..8dad3a2a40 100644 --- a/kimchi/src/circuits/witness/mod.rs +++ b/kimchi/src/circuits/witness/mod.rs @@ -21,8 +21,8 @@ pub use self::{ }; /// Witness cell interface -pub trait WitnessCell { - fn value(&self, witness: &mut [Vec; N], variables: &Variables, index: usize) -> F; +pub trait WitnessCell { + fn value(&self, witness: &mut [Vec; W], variables: &Variables, index: usize) -> F; fn length(&self) -> usize { 1 @@ -40,25 +40,25 @@ pub trait WitnessCell { /// - layout: the partial layout to initialize from /// - variables: the hashmap of variables to get the values from #[allow(clippy::too_many_arguments)] -pub fn init_cell( - witness: &mut [Vec; N], +pub fn init_cell( + witness: &mut [Vec; W], offset: usize, row: usize, col: usize, cell: usize, index: usize, - layout: &[Vec>>], + layout: &[Vec>>], variables: &Variables, ) { witness[col][row + offset] = layout[row][cell].value(witness, variables, index); } /// Initialize a witness row based on layout and computed variables -pub fn init_row( - witness: &mut [Vec; N], +pub fn init_row( + witness: &mut [Vec; W], offset: usize, row: usize, - layout: &[Vec>>], + layout: &[Vec>>], variables: &Variables, ) { let mut col = 0; @@ -72,10 +72,10 @@ pub fn init_row( } /// Initialize a witness based on layout and computed variables -pub fn init( - witness: &mut [Vec; N], +pub fn init( + witness: &mut [Vec; W], offset: usize, - layout: &[Vec>>], + layout: &[Vec>>], variables: &Variables, ) { for row in 0..layout.len() { diff --git a/kimchi/src/circuits/witness/variable_bits_cell.rs b/kimchi/src/circuits/witness/variable_bits_cell.rs index bd414a7281..1fef513607 100644 --- a/kimchi/src/circuits/witness/variable_bits_cell.rs +++ b/kimchi/src/circuits/witness/variable_bits_cell.rs @@ -18,8 +18,8 @@ impl<'a> VariableBitsCell<'a> { } } -impl<'a, const N: usize, F: Field> WitnessCell for VariableBitsCell<'a> { - fn value(&self, _witness: &mut [Vec; N], variables: &Variables, _index: usize) -> F { +impl<'a, const W: usize, F: Field> WitnessCell for VariableBitsCell<'a> { + fn value(&self, _witness: &mut [Vec; W], variables: &Variables, _index: usize) -> F { let bits = if let Some(end) = self.end { F::from_bits(&variables[self.name].to_bits()[self.start..end]) } else { diff --git a/kimchi/src/circuits/witness/variable_cell.rs b/kimchi/src/circuits/witness/variable_cell.rs index c875326583..c24ce57d42 100644 --- a/kimchi/src/circuits/witness/variable_cell.rs +++ b/kimchi/src/circuits/witness/variable_cell.rs @@ -14,8 +14,8 @@ impl<'a> VariableCell<'a> { } } -impl<'a, const N: usize, F: Field> WitnessCell for VariableCell<'a> { - fn value(&self, _witness: &mut [Vec; N], variables: &Variables, _index: usize) -> F { +impl<'a, const W: usize, F: Field> WitnessCell for VariableCell<'a> { + fn value(&self, _witness: &mut [Vec; W], variables: &Variables, _index: usize) -> F { variables[self.name] } }