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 at row_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 at row_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>

source

pub fn write_column_raw(&mut self, position: Column, value: F)

source

pub fn next_row(&mut self)

Progress to the computations on the next row.

source

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>

source

pub fn create() -> Self

Create a new empty-state witness builder.

source

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).

source

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.

source

pub fn get_relation_witness(&self, domain_size: usize) -> Witness<N_WIT, Vec<F>>

source

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.

source

pub fn get_logup_witness( &self, domain_size: usize, lookup_tables_data: BTreeMap<LT, Vec<Vec<Vec<F>>>> ) -> BTreeMap<LT, LogupWitness<F, LT>>

source

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>

§

type Variable = F

source§

fn assert_zero(&mut self, cst: Self::Variable)

Asserts that the value is zero.
source§

fn set_assert_mapper( &mut self, mapper: Box<dyn Fn(Self::Variable) -> Self::Variable> )

Sets an assert predicate f(X) such that when assert_zero is called on x, it will actually perform assert_zero(f(x)).
source§

fn constant(value: F) -> Self::Variable

Turns a constant value into a variable.
source§

fn read_column(&self, ix: CIx) -> Self::Variable

Reads value from a column position.
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>

source§

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>

source§

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>

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§

fn hcopy(&mut self, value: &Self::Variable, ix: CIx) -> Self::Variable

Given variable x and position ix, it (hybrid) writes x into ix, and returns the value.
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>

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

Returns the bits between [highest_bit, lowest_bit] of the variable x, and copy the result in the column position. The value x is expected to be encoded in big-endian
source§

impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> LookupCap<F, CIx, LT> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>

source§

fn lookup( &mut self, table_id: LT, value: Vec<<Self as ColAccessCap<F, CIx>>::Variable> )

Look up (read) value from a lookup table.
source§

fn lookup_runtime_write(&mut self, table_id: LT, value: Vec<Self::Variable>)

Write a value into a runtime table. Panics if called on a fixed table.
source§

impl<F: PrimeField, CIx: ColumnIndexer, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT: LookupTableID> MultiRowReadCap<F, CIx> for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>

source§

fn read_row_column(&mut self, row: usize, col: CIx) -> Self::Variable

Read value from a (row,column) position.

source§

fn next_row(&mut self)

Progresses to the next row.

source§

fn curr_row(&self) -> usize

Returns the current row.

Auto Trait Implementations§

§

impl<F, CIx, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT> !RefUnwindSafe for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>

§

impl<F, CIx, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT> !Send for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>

§

impl<F, CIx, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT> !Sync for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>

§

impl<F, CIx, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT> Unpin for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>where CIx: Unpin, F: Unpin,

§

impl<F, CIx, const N_WIT: usize, const N_REL: usize, const N_DSEL: usize, const N_FSEL: usize, LT> !UnwindSafe for WitnessBuilderEnv<F, CIx, N_WIT, N_REL, N_DSEL, N_FSEL, LT>

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> Pointable for T

§

const ALIGN: usize = mem::align_of::<T>()

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V