Struct kimchi_msm::circuit_design::witness::WitnessBuilderEnv
source · pub struct WitnessBuilderEnv<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> {
pub witness: Vec<Witness<N_WIT, F>>,
pub lookup_multiplicities: BTreeMap<LT, Vec<u64>>,
pub lookup_reads: BTreeMap<LT, Vec<Vec<Vec<F>>>>,
pub runtime_lookup_writes: BTreeMap<LT, Vec<Vec<Vec<F>>>>,
pub fixed_selectors: Vec<Vec<F>>,
pub assert_mapper: Box<dyn Fn(F) -> F>,
pub phantom_cix: PhantomData<CIx>,
}
Expand description
Witness builder environment. Operates on multiple rows at the same
time. CIx::N_COL
must be equal to N_WIT + N_FSEL
; passing these two
separately is due to a rust limitation.
Fields§
§witness: Vec<Witness<N_WIT, F>>
The witness columns that the environment is working with. Every element of the vector is a row, and the builder is always processing the last row.
lookup_multiplicities: BTreeMap<LT, Vec<u64>>
Lookup multiplicities, a vector of values m_i
per lookup
table, where m_i
is how many times the lookup value number
i
was looked up.
lookup_reads: BTreeMap<LT, Vec<Vec<Vec<F>>>>
Lookup “read” requests per table. Each element of the map is a vector of <#number_of_reads_per_row> columns. Each column is a vector of elements. Each element is vector of field elements.
lookup_reads[table_id][read_i]
is a column corresponding to a read #read_i
per row.lookup_reads[table_id][read_i][row_i]
is a value-vector that’s looked up atrow_i
runtime_lookup_writes: BTreeMap<LT, Vec<Vec<Vec<F>>>>
Values for runtime tables. Each element (value) in the map is a set of on-the-fly built columns, one column per write.
Format is the same as lookup_reads
.
runtime_tables[table_id][write_i]
is a column corresponding to a write #write_i
per row.runtime_tables[table_id][write_i][row_i]
is a value-vector that’s looked up atrow_i
fixed_selectors: Vec<Vec<F>>
Fixed values for selector columns. fixed_selectors[i][j]
is the
value for row #j of the selector #i.
assert_mapper: Box<dyn Fn(F) -> F>
Function used to map assertions.
phantom_cix: PhantomData<CIx>
Implementations§
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
pub fn write_column_raw(&mut self, position: Column, value: F)
sourcepub fn get_lookup_multiplicities(
&self,
domain_size: usize,
table_id: LT
) -> Vec<Vec<F>>
pub fn get_lookup_multiplicities( &self, domain_size: usize, table_id: LT ) -> Vec<Vec<F>>
Getting multiplicities for range check tables less or equal than 15 bits. Return value is a vector of columns, where each column represents a “read”. Fixed lookup tables always return a single-column vector, while runtime tables may return more.
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
sourcepub fn set_fixed_selector_cix(&mut self, sel: CIx, sel_values: Vec<F>)
pub fn set_fixed_selector_cix(&mut self, sel: CIx, sel_values: Vec<F>)
Sets a fixed selector, the vector of length equal to the domain size (circuit height).
sourcepub fn set_fixed_selectors(&mut self, selectors: Vec<Vec<F>>)
pub fn set_fixed_selectors(&mut self, selectors: Vec<Vec<F>>)
Sets all fixed selectors directly. Each item in selectors
is
a vector of domain_size
length.
pub fn get_relation_witness(&self, domain_size: usize) -> Witness<N_WIT, Vec<F>>
sourcepub fn get_runtime_tables(
&self,
domain_size: usize
) -> BTreeMap<LT, Vec<Vec<Vec<F>>>>
pub fn get_runtime_tables( &self, domain_size: usize ) -> BTreeMap<LT, Vec<Vec<Vec<F>>>>
Return all runtime tables collected so far, padded to the domain size.
pub fn get_logup_witness( &self, domain_size: usize, lookup_tables_data: BTreeMap<LT, Vec<Vec<Vec<F>>>> ) -> BTreeMap<LT, LogupWitness<F, LT>>
sourcepub fn get_proof_inputs(
&self,
domain_size: usize,
lookup_tables_data: BTreeMap<LT, Vec<Vec<Vec<F>>>>
) -> ProofInputs<N_WIT, F, LT>
pub fn get_proof_inputs( &self, domain_size: usize, lookup_tables_data: BTreeMap<LT, Vec<Vec<Vec<F>>>> ) -> ProofInputs<N_WIT, F, LT>
Generates proof inputs, repacking/collecting internal witness builder state.
Trait Implementations§
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> ColAccessCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> ColAccessCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
type Variable = F
source§fn assert_zero(&mut self, cst: Self::Variable)
fn assert_zero(&mut self, cst: Self::Variable)
source§fn set_assert_mapper(
&mut self,
mapper: Box<dyn Fn(Self::Variable) -> Self::Variable>
)
fn set_assert_mapper( &mut self, mapper: Box<dyn Fn(Self::Variable) -> Self::Variable> )
f(X)
such that when assert_zero is
called on x, it will actually perform assert_zero(f(x))
.source§fn read_column(&self, ix: CIx) -> Self::Variable
fn read_column(&self, ix: CIx) -> Self::Variable
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> ColWriteCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> ColWriteCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
fn write_column(&mut self, ix: CIx, value: &Self::Variable)
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> DirectWitnessCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> DirectWitnessCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
source§fn variable_to_field(value: Self::Variable) -> F
fn variable_to_field(value: Self::Variable) -> F
Convert an abstract variable to a field element! Inverse of Env::constant().
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> HybridCopyCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> HybridCopyCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>
If Env
implements real write (“for sure” writes), you can implement
hybrid copy (that is only required to “maybe” copy). The other way
around violates the semantics.
Sadly, rust does not allow “cover” instances to define this impl
for every T: ColWriteCap
.
source§impl<F: PrimeField, CIx: ColumnIndexer, const N_COL: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> HybridSerHelpers<F, CIx, LT> for WitnessBuilderEnv<F, CIx, N_COL, N_REL, N_DSEL, N_FSEL, LT>
impl<F: PrimeField, CIx: ColumnIndexer, const N_COL: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> HybridSerHelpers<F, CIx, LT> for WitnessBuilderEnv<F, CIx, N_COL, N_REL, N_DSEL, N_FSEL, LT>
source§fn bitmask_be(
&mut self,
x: &<Self as ColAccessCap<F, CIx>>::Variable,
highest_bit: u32,
lowest_bit: u32,
position: CIx
) -> <Self as ColAccessCap<F, CIx>>::Variable
fn bitmask_be( &mut self, x: &<Self as ColAccessCap<F, CIx>>::Variable, highest_bit: u32, lowest_bit: u32, position: CIx ) -> <Self as ColAccessCap<F, CIx>>::Variable
x
,
and copy the result in the column position
.
The value x
is expected to be encoded in big-endian