pub enum AdviceInjector {
    MerkleNodeMerge,
    MerkleNodeToStack,
    MapValueToStack {
        include_len: bool,
        key_offset: usize,
    },
    DivU64,
    Ext2Inv,
    Ext2Intt,
    SmtGet,
    MemToMap,
    HdwordToMap {
        domain: Felt,
    },
}
Expand description

Defines a set of actions which can be initiated from the VM to inject new data into the advice provider.

These actions can affect all 3 components of the advice provider: Merkle store, advice stack, and advice map.

All actions, except for MerkleNodeMerge and Ext2Inv, can be invoked directly from Miden assembly via dedicated instructions.

Variants§

§

MerkleNodeMerge

Creates a new Merkle tree in the advice provider by combining Merkle trees with the specified roots. The root of the new tree is defined as Hash(LEFT_ROOT, RIGHT_ROOT).

Inputs: Operand stack: [RIGHT_ROOT, LEFT_ROOT, …] Merkle store: {RIGHT_ROOT, LEFT_ROOT}

Outputs: Operand stack: [RIGHT_ROOT, LEFT_ROOT, …] Merkle store: {RIGHT_ROOT, LEFT_ROOT, hash(LEFT_ROOT, RIGHT_ROOT)}

After the operation, both the original trees and the new tree remains in the advice provider (i.e., the input trees are not removed).

§

MerkleNodeToStack

Pushes a node of the Merkle tree specified by the values on the top of the operand stack onto the advice stack.

Inputs: Operand stack: [depth, index, TREE_ROOT, …] Advice stack: […] Merkle store: {TREE_ROOT<-NODE}

Outputs: Operand stack: [depth, index, TREE_ROOT, …] Advice stack: [NODE, …] Merkle store: {TREE_ROOT<-NODE}

§

MapValueToStack

Fields

§include_len: bool
§key_offset: usize

Pushes a list of field elements onto the advice stack. The list is looked up in the advice map using the specified word from the operand stack as the key. If include_len is set to true, the number of elements in the value is also pushed onto the advice stack.

Inputs: Operand stack: […, KEY, …] Advice stack: […] Advice map: {KEY: values}

Outputs: Operand stack: […, KEY, …] Advice stack: [values_len?, values, …] Advice map: {KEY: values}

The key_offset value specifies the location of the KEY on the stack. For example, offset value of 0 indicates that the top word on the stack should be used as the key, the offset value of 4, indicates that the second word on the stack should be used as the key etc.

The valid values of key_offset are 0 through 12 (inclusive).

§

DivU64

Pushes the result of u64 division (both the quotient and the remainder) onto the advice stack.

Inputs: Operand stack: [b1, b0, a1, a0, …] Advice stack: […]

Outputs: Operand stack: [b1, b0, a1, a0, …] Advice stack: [q0, q1, r0, r1, …]

Where (a0, a1) and (b0, b1) are the 32-bit limbs of the dividend and the divisor respectively (with a0 representing the 32 lest significant bits and a1 representing the 32 most significant bits). Similarly, (q0, q1) and (r0, r1) represent the quotient and the remainder respectively.

§

Ext2Inv

Given an element in a quadratic extension field on the top of the stack (i.e., a0, b1), computes its multiplicative inverse and push the result onto the advice stack.

Inputs: Operand stack: [a1, a0, …] Advice stack: […]

Outputs: Operand stack: [a1, a0, …] Advice stack: [b0, b1…]

Where (b0, b1) is the multiplicative inverse of the extension field element (a0, a1) at the top of the stack.

§

Ext2Intt

Given evaluations of a polynomial over some specified domain, interpolates the evaluations into a polynomial in coefficient form and pushes the result into the advice stack.

The interpolation is performed using the iNTT algorithm. The evaluations are expected to be in the quadratic extension.

Inputs: Operand stack: [output_size, input_size, input_start_ptr, …] Advice stack: […]

Outputs: Operand stack: [output_size, input_size, input_start_ptr, …] Advice stack: [coefficients…]

  • input_size is the number of evaluations (each evaluation is 2 base field elements). Must be a power of 2 and greater 1.
  • output_size is the number of coefficients in the interpolated polynomial (each coefficient is 2 base field elements). Must be smaller than or equal to the number of input evaluations.
  • input_start_ptr is the memory address of the first evaluation.
  • coefficients are the coefficients of the interpolated polynomial such that lowest degree coefficients are located at the top of the advice stack.
§

SmtGet

Pushes values onto the advice stack which are required for successful retrieval of a value from a Sparse Merkle Tree data structure.

The Sparse Merkle Tree is tiered, meaning it will have leaf depths in {16, 32, 48, 64}. The depth flags define the tier on which the leaf is located.

Inputs: Operand stack: [KEY, ROOT, …] Advice stack: […]

Outputs: Operand stack: [KEY, ROOT, …] Advice stack: [f0, f1, K, V, f2]

Where:

  • f0 is a boolean flag set to 1 if the depth is 16 or 48.
  • f1 is a boolean flag set to 1 if the depth is 16 or 32.
  • K is the remaining key word; will be zeroed if the tree don’t contain a mapped value for the key.
  • V is the value word; will be zeroed if the tree don’t contain a mapped value for the key.
  • f2 is a boolean flag set to 1 if a remaining key is not zero.
§

MemToMap

Reads words from memory at the specified range and inserts them into the advice map under the key KEY located at the top of the stack.

Inputs: Operand stack: [KEY, start_addr, end_addr, …] Advice map: {…}

Outputs: Operand stack: [KEY, start_addr, end_addr, …] Advice map: {KEY: values}

Where values are the elements located in memory[start_addr..end_addr].

§

HdwordToMap

Fields

§domain: Felt

Reads two word from the operand stack and inserts them into the advice map under the key defined by the hash of these words.

Inputs: Operand stack: [B, A, …] Advice map: {…}

Outputs: Operand stack: [B, A, …] Advice map: {KEY: [a0, a1, a2, a3, b0, b1, b2, b3]}

Where KEY is computed as hash(A || B, domain), where domain is provided via the immediate value.

Trait Implementations§

source§

impl Clone for AdviceInjector

source§

fn clone(&self) -> AdviceInjector

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 Debug for AdviceInjector

source§

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

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

impl Display for AdviceInjector

source§

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

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

impl PartialEq<AdviceInjector> for AdviceInjector

source§

fn eq(&self, other: &AdviceInjector) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Copy for AdviceInjector

source§

impl Eq for AdviceInjector

source§

impl StructuralEq for AdviceInjector

source§

impl StructuralPartialEq for AdviceInjector

Auto Trait Implementations§

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.

source§

impl<T> Same<T> for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
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.