Type Alias AsmBuilder

Source
pub type AsmBuilder<F, EF> = Builder<AsmConfig<F, EF>>;
Expand description

A builder that compiles assembly code.

Aliased Type§

struct AsmBuilder<F, EF> {
    pub operations: TracedVec<DslIr<AsmConfig<F, EF>>>,
    pub flags: BuilderFlags,
    pub is_sub_builder: bool,
    /* private fields */
}

Fields§

§operations: TracedVec<DslIr<AsmConfig<F, EF>>>§flags: BuilderFlags§is_sub_builder: bool

Implementations§

Source§

impl<F: PrimeField32 + TwoAdicField, EF: ExtensionField<F> + TwoAdicField> AsmBuilder<F, EF>

Source

pub fn compile_isa(self) -> Program<F>

Source

pub fn compile_isa_with_options(self, options: CompilerOptions) -> Program<F>

Source§

impl<C: Config> Builder<C>

Source

pub fn num2bits_f( &mut self, num: Felt<C::F>, num_bits: u32, ) -> Array<C, Var<C::N>>

Converts a felt to bits. Will result in a failed assertion if num has more than num_bits bits. Only works for C::F = BabyBear

Source

pub fn num2bits_f_circuit(&mut self, num: Felt<C::F>) -> Vec<Var<C::N>>

Converts a felt to bits inside a circuit.

Source

pub fn bits2num_v_circuit(&mut self, bits: &[Var<C::N>]) -> Var<C::N>

Convert bits to a variable inside a circuit.

Source

pub fn var_to_64bits_f_circuit(&mut self, value: Var<C::N>) -> [Felt<C::F>; 4]

Decompose a Var into 64-bit Felt limbs.

Source§

impl<C: Config> Builder<C>

Source

pub fn create_sub_builder(&self) -> Self

Creates a new builder with a given number of counts for each type.

Source

pub fn push(&mut self, op: DslIr<C>)

Pushes an operation to the builder.

Source

pub fn trace_push(&mut self, op: DslIr<C>)

Pushes an operation to the builder and records a trace if RUST_BACKTRACE=1.

Source

pub fn uninit<V: Variable<C>>(&mut self) -> V

Creates an uninitialized variable.

Source

pub fn eval<V: Variable<C>, E: Into<V::Expression>>(&mut self, expr: E) -> V

Evaluates an expression and returns a variable.

Source

pub fn eval_expr(&mut self, expr: impl Into<SymbolicVar<C::N>>) -> RVar<C::N>

Evaluates an expression and returns a right value.

Source

pub fn inc(&mut self, u: &Usize<C::N>)

Increments Usize by one.

Source

pub fn constant<V: FromConstant<C>>(&mut self, value: V::Constant) -> V

Evaluates a constant expression and returns a variable.

Source

pub fn assign<V: Variable<C>, E: Into<V::Expression>>( &mut self, dst: &V, expr: E, )

Assigns an expression to a variable.

Source

pub fn cast_felt_to_var(&mut self, felt: Felt<C::F>) -> Var<C::N>

Casts a Felt to a Var.

Source

pub fn unsafe_cast_var_to_felt(&mut self, var: Var<C::N>) -> Felt<C::F>

Casts a Var to a Felt.

Source

pub fn assert_nonzero(&mut self, u: &Usize<C::N>)

Asserts that a Usize is non-zero

Source

pub fn assert_eq<V: Variable<C>>( &mut self, lhs: impl Into<V::Expression>, rhs: impl Into<V::Expression>, )

Asserts that two expressions are equal.

Source

pub fn assert_var_eq<LhsExpr: Into<SymbolicVar<C::N>>, RhsExpr: Into<SymbolicVar<C::N>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, )

Assert that two vars are equal.

Source

pub fn assert_felt_eq<LhsExpr: Into<SymbolicFelt<C::F>>, RhsExpr: Into<SymbolicFelt<C::F>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, )

Assert that two felts are equal.

Source

pub fn assert_ext_eq<LhsExpr: Into<SymbolicExt<C::F, C::EF>>, RhsExpr: Into<SymbolicExt<C::F, C::EF>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, )

Assert that two exts are equal.

Source

pub fn assert_usize_eq<LhsExpr: Into<SymbolicVar<C::N>>, RhsExpr: Into<SymbolicVar<C::N>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, )

Source

pub fn assert_var_array_eq( &mut self, lhs: &Array<C, Var<C::N>>, rhs: &Array<C, Var<C::N>>, )

Assert that two arrays are equal.

Source

pub fn if_eq<LhsExpr: Into<SymbolicVar<C::N>>, RhsExpr: Into<SymbolicVar<C::N>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, ) -> IfBuilder<'_, C>

Evaluate a block of operations if two expressions are equal.

Source

pub fn if_ne<LhsExpr: Into<SymbolicVar<C::N>>, RhsExpr: Into<SymbolicVar<C::N>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, ) -> IfBuilder<'_, C>

Evaluate a block of operations if two expressions are not equal.

Source

pub fn assert_less_than_slow_small_rhs<LhsExpr: Into<SymbolicVar<C::N>>, RhsExpr: Into<SymbolicVar<C::N>>>( &mut self, lhs: LhsExpr, rhs: RhsExpr, )

Asserts that lhs is less than rhs in time O(rhs).

Source

pub fn assert_less_than_slow_bit_decomp( &mut self, lhs: Var<C::N>, rhs: Var<C::N>, )

Asserts that lhs is less than rhs in time O(log(lhs) + log(rhs)).

Only works for Felt == BabyBear and in the VM.

Uses bit decomposition hint, which has large constant factor overhead, so prefer Self::assert_less_than_slow_small_rhs when rhs is small.

Source

pub fn range_check_var(&mut self, x: Var<C::N>, num_bits: usize)

asserts that x has at most num_bits bits

Source

pub fn range( &mut self, start: impl Into<RVar<C::N>>, end: impl Into<RVar<C::N>>, ) -> IteratorBuilder<'_, C>

Evaluate a block of operations over a range from start to end.

Source

pub fn range_with_step( &mut self, start: impl Into<RVar<C::N>>, end: impl Into<RVar<C::N>>, step: C::N, ) -> IteratorBuilder<'_, C>

Evaluate a block of operations over a range from start to end with a custom step.

Source

pub fn zip<'a>( &'a mut self, arrays: &'a [Box<dyn ArrayLike<C> + 'a>], ) -> IteratorBuilder<'a, C>

Source

pub fn print_debug(&mut self, val: usize)

Source

pub fn print_v(&mut self, dst: Var<C::N>)

Print a variable.

Source

pub fn print_f(&mut self, dst: Felt<C::F>)

Print a felt.

Source

pub fn print_e(&mut self, dst: Ext<C::F, C::EF>)

Print an ext.

Source

pub fn hint_var(&mut self) -> Var<C::N>

Source

pub fn hint_felt(&mut self) -> Felt<C::F>

Source

pub fn hint_ext(&mut self) -> Ext<C::F, C::EF>

Source

pub fn hint_vars(&mut self) -> Array<C, Var<C::N>>

Hint a vector of variables.

Writes the next element of the witness stream into memory and returns it.

Source

pub fn hint_felts(&mut self) -> Array<C, Felt<C::F>>

Hint a vector of felts.

Source

pub fn hint_felts_fixed( &mut self, len: impl Into<RVar<C::N>>, ) -> Array<C, Felt<C::F>>

Source

pub fn hint_exts(&mut self) -> Array<C, Ext<C::F, C::EF>>

Hint a vector of exts.

Emits two hint opcodes: the first for the number of exts, the second for the list of exts themselves.

Source

pub fn hint_load(&mut self) -> Var<C::N>

Move data from input stream into hint space. Return an ID which can be used to load the data at runtime.

Source

pub fn witness_var(&mut self) -> Var<C::N>

Source

pub fn witness_felt(&mut self) -> Felt<C::F>

Source

pub fn witness_ext(&mut self) -> Ext<C::F, C::EF>

Source

pub fn witness_load(&mut self, witness_refs: Vec<WitnessRef>) -> Usize<C::N>

Source

pub fn get_witness_refs(&self, id: Usize<C::N>) -> &[WitnessRef]

Source

pub fn error(&mut self)

Throws an error.

Source

pub fn static_commit_public_value(&mut self, index: usize, val: Var<C::N>)

Commits a Var as public value. This value will be constrained when verified. This method should only be used in static mode.

Source

pub fn commit_public_value(&mut self, val: Felt<C::F>)

Register and commits a felt as public value. This value will be constrained when verified.

Source

pub fn commit_public_values(&mut self, vals: &Array<C, Felt<C::F>>)

Commits an array of felts in public values.

Source

pub fn cycle_tracker_start(&mut self, name: &str)

Source

pub fn cycle_tracker_end(&mut self, name: &str)

Source

pub fn halt(&mut self)

Source§

impl<C: Config> Builder<C>

Source

pub fn array<V: MemVariable<C>>( &mut self, len: impl Into<RVar<C::N>>, ) -> Array<C, V>

Initialize an array of fixed length len. The entries will be uninitialized.

Source

pub fn vec<V: MemVariable<C>>(&mut self, v: Vec<V>) -> Array<C, V>

Creates an array from a vector.

Source

pub fn uninit_fixed_array<V: Variable<C>>(&mut self, len: usize) -> Array<C, V>

Create an uninitialized Array::Fixed.

Source

pub fn dyn_array<V: MemVariable<C>>( &mut self, len: impl Into<RVar<C::N>>, ) -> Array<C, V>

Creates a dynamic array for a length.

Source

pub fn get<V: MemVariable<C>, I: Into<RVar<C::N>>>( &mut self, slice: &Array<C, V>, index: I, ) -> V

Source

pub fn iter_ptr_get<V: MemVariable<C>>( &mut self, slice: &Array<C, V>, ptr: RVar<C::N>, ) -> V

Intended to be used with ptr from zip. Assumes that:

  • if slice is Array::Fixed, then ptr is a constant index in [0, slice.len()).
  • if slice is Array::Dyn, then ptr is a variable iterator over the entries of slice.

In both cases, loads and returns the corresponding element of slice.

Source

pub fn iter_ptr_set<V: MemVariable<C>, Expr: Into<V::Expression>>( &mut self, slice: &Array<C, V>, ptr: RVar<C::N>, value: Expr, )

Intended to be used with ptr from zip. Assumes that:

  • if slice is Array::Fixed, then ptr is a constant index in [0, slice.len()).
  • if slice is Array::Dyn, then ptr is a variable iterator over the entries of slice.

In both cases, stores the given value at the corresponding element of slice.

Source

pub fn set<V: MemVariable<C>, I: Into<RVar<C::N>>, Expr: Into<V::Expression>>( &mut self, slice: &Array<C, V>, index: I, value: Expr, )

Source

pub fn set_value<V: MemVariable<C>, I: Into<RVar<C::N>>>( &mut self, slice: &Array<C, V>, index: I, value: V, )

Source§

impl<C: Config> Builder<C>

Source

pub fn fri_single_reduced_opening_eval( &mut self, alpha: Ext<C::F, C::EF>, hint_id: Var<C::N>, is_init: Var<C::N>, at_x_array: &Array<C, Felt<C::F>>, at_z_array: &Array<C, Ext<C::F, C::EF>>, ) -> Ext<C::F, C::EF>

Source§

impl<C: Config> Builder<C>

Source

pub fn poseidon2_permute( &mut self, array: &Array<C, Felt<C::F>>, ) -> Array<C, Felt<C::F>>

Applies the Poseidon2 permutation to the given array.

Reference

Source

pub fn poseidon2_permute_mut(&mut self, array: &Array<C, Felt<C::F>>)

Applies the Poseidon2 permutation to the given array.

Reference

Source

pub fn poseidon2_compress( &mut self, left: &Array<C, Felt<C::F>>, right: &Array<C, Felt<C::F>>, ) -> Array<C, Felt<C::F>>

Applies the Poseidon2 compression function to the given array.

Reference

Source

pub fn poseidon2_compress_x( &mut self, result: &Array<C, Felt<C::F>>, left: &Array<C, Felt<C::F>>, right: &Array<C, Felt<C::F>>, )

Applies the Poseidon2 compression to the given array.

Reference

Source

pub fn poseidon2_hash_x( &mut self, array: &Array<C, Array<C, Felt<C::F>>>, ) -> Array<C, Felt<C::F>>

Source

pub fn poseidon2_hash_ext( &mut self, array: &Array<C, Array<C, Ext<C::F, C::EF>>>, ) -> Array<C, Felt<C::F>>

Source§

impl<C: Config> Builder<C>

Source

pub fn alloc(&mut self, len: impl Into<RVar<C::N>>, size: usize) -> Ptr<C::N>

Allocates an array on the heap.

Source

pub fn load<V: MemVariable<C>>( &mut self, var: V, ptr: Ptr<C::N>, index: MemIndex<C::N>, )

Loads a value from memory.

Source

pub fn store<V: MemVariable<C>>( &mut self, ptr: Ptr<C::N>, index: MemIndex<C::N>, value: V, )

Stores a value to memory.

Source

pub fn load_heap_ptr(&mut self) -> Ptr<C::N>

Source

pub fn store_heap_ptr(&mut self, ptr: Ptr<C::N>)

Source§

impl<C: Config> Builder<C>

Source

pub fn generator(&mut self) -> Felt<C::F>

The generator for the field.

Reference: openvm_stark_sdk::p3_baby_bear::BabyBear

Source

pub fn select_v( &mut self, cond: Var<C::N>, a: Var<C::N>, b: Var<C::N>, ) -> Var<C::N>

Select a variable based on a condition.

Source

pub fn select_f( &mut self, cond: Var<C::N>, a: Felt<C::F>, b: Felt<C::F>, ) -> Felt<C::F>

Select a felt based on a condition.

Source

pub fn select_ef( &mut self, cond: Var<C::N>, a: Ext<C::F, C::EF>, b: Ext<C::F, C::EF>, ) -> Ext<C::F, C::EF>

Select an extension based on a condition.

Source

pub fn exp_bits_big_endian<V>( &mut self, x: V, power_bits: &Array<C, Var<C::N>>, ) -> V
where V::Expression: FieldAlgebra, V: Copy + Mul<Output = V::Expression> + Variable<C> + CanSelect<C>,

Exponentiates a variable to a list of big endian bits with a given length.

Example: if power_bits = [1, 0, 1, 0], then the result should be x^8 * x^2 = x^10.

Source

pub fn exp_power_of_2_v<V>( &mut self, base: impl Into<V::Expression>, power_log: impl Into<RVar<C::N>>, ) -> V
where V: Variable<C> + Copy + Mul<Output = V::Expression>,

Exponentiates a variable to a list of bits in little endian.

Source

pub fn sll<V>(&mut self, base: impl Into<V::Expression>, shift: RVar<C::N>) -> V
where V: Variable<C> + Clone + Add<Output = V::Expression>,

Multiplies base by 2^{log_power}.

Source

pub fn ext_from_base_slice(&mut self, arr: &[Felt<C::F>]) -> Ext<C::F, C::EF>

Creates an ext from a slice of felts.

Source

pub fn felts2ext(&mut self, felts: &[Felt<C::F>]) -> Ext<C::F, C::EF>

Source

pub fn ext2felt(&mut self, value: Ext<C::F, C::EF>) -> Array<C, Felt<C::F>>

Converts an ext to a slice of felts.

Source

pub fn ext2felt_circuit(&mut self, value: Ext<C::F, C::EF>) -> [Felt<C::F>; 4]

Converts an ext to a slice of felts inside a circuit.

Source

pub fn felt_reduce_circuit(&mut self, value: Felt<C::F>)

Source

pub fn ext_reduce_circuit(&mut self, value: Ext<C::F, C::EF>)

Source§

impl<C: Config> Builder<C>

Source

pub fn verify_batch_felt( &mut self, dimensions: &Array<C, Usize<C::F>>, opened_values: &Array<C, Array<C, Felt<C::F>>>, proof_id: Var<C::N>, index_bits: &Array<C, Var<C::N>>, commit: &Array<C, Felt<C::F>>, )

  • Requires dimensions.len() == opened_values.len()
  • proof is an array of arrays where inner arrays are of length CHUNK
  • commit.len() = CHUNK
Source

pub fn verify_batch_ext( &mut self, dimensions: &Array<C, Usize<C::F>>, opened_values: &Array<C, Array<C, Ext<C::F, C::EF>>>, proof_id: Var<C::N>, index_bits: &Array<C, Var<C::N>>, commit: &Array<C, Felt<C::F>>, )

Version of Self::verify_batch_felt where opened_values are extension field elements.

  • Requires dimensions.len() == opened_values.len()
  • proof is an array of arrays where inner arrays are of length CHUNK
  • commit.len() = CHUNK

Trait Implementations

Source§

impl<C: Clone + Config> Clone for Builder<C>
where C::N: Clone,

Source§

fn clone(&self) -> Builder<C>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug + Config> Debug for Builder<C>
where C::N: Debug,

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<C: Default + Config> Default for Builder<C>
where C::N: Default,

Source§

fn default() -> Builder<C>

Returns the “default value” for a type. Read more