Enum miden_core::Operation
source · [−]pub enum Operation {
Show 79 variants
Noop,
Assert,
FmpAdd,
FmpUpdate,
Join,
Split,
Loop,
Span,
End,
Repeat,
Respan,
Halt,
Add,
Neg,
Mul,
Inv,
Incr,
And,
Or,
Not,
Eq,
Eqz,
U32split,
U32add,
U32assert2,
U32add3,
U32sub,
U32mul,
U32madd,
U32div,
U32and,
U32or,
U32xor,
Pad,
Drop,
Dup0,
Dup1,
Dup2,
Dup3,
Dup4,
Dup5,
Dup6,
Dup7,
Dup9,
Dup11,
Dup13,
Dup15,
Swap,
SwapW,
SwapW2,
SwapW3,
SwapDW,
MovUp2,
MovUp3,
MovUp4,
MovUp5,
MovUp6,
MovUp7,
MovUp8,
MovDn2,
MovDn3,
MovDn4,
MovDn5,
MovDn6,
MovDn7,
MovDn8,
CSwap,
CSwapW,
Push(Felt),
Read,
ReadW,
MLoadW,
MStoreW,
MLoad,
MStore,
SDepth,
RpPerm,
MpVerify,
MrUpdate(bool),
}
Expand description
TODO: add docs
Variants
Noop
Advances cycle counter, but does not change the state of user stack.
Assert
Pops the stack; if the popped value is not 1, execution fails.
FmpAdd
Pops an element off the stack, adds the current value of the fmp
register to it, and
pushes the result back onto the stack.
FmpUpdate
Pops an element off the stack and adds it to the current value of fmp
register.
Join
Marks the beginning of a join block.
Split
Marks the beginning of a split block.
Loop
Marks the beginning of a loop block.
Span
Marks the beginning of a span code block.
End
Marks the end of a program block.
Repeat
Indicates that body of an executing loop should be executed again.
Respan
Starts processing a new operation batch.
Halt
Indicates the end of the program. This is used primarily to pad the execution trace to the required length. Once HALT operation is executed, no other operations can be executed by the VM (HALT operation itself excepted).
Add
Pops two elements off the stack, adds them, and pushes the result back onto the stack.
Neg
Pops an element off the stack, negates it, and pushes the result back onto the stack.
Mul
Pops two elements off the stack, multiplies them, and pushes the result back onto the stack.
Inv
Pops an element off the stack, computes its multiplicative inverse, and pushes the result back onto the stack.
Incr
Pops an element off the stack, adds 1 to it, and pushes the result back onto the stack.
And
Pops two elements off the stack, multiplies them, and pushes the result back onto the stack.
If either of the elements is greater than 1, execution fails. This operation is equivalent to boolean AND.
Or
Pops two elements off the stack and subtracts their product from their sum.
If either of the elements is greater than 1, execution fails. This operation is equivalent to boolean OR.
Not
Pops an element off the stack and subtracts it from 1.
If the element is greater than one, the execution fails. This operation is equivalent to boolean NOT.
Eq
Pops two elements off the stack and compares them. If the elements are equal, pushes 1 onto the stack, otherwise pushes 0 onto the stack.
Eqz
Pops an element off the stack and compares it to 0. If the element is 0, pushes 1 onto the stack, otherwise pushes 0 onto the stack.
U32split
Pops an element off the stack, splits it into upper and lower 32-bit values, and pushes these values back onto the stack.
U32add
Pops two elements off the stack, adds them, and splits the result into upper and lower 32-bit values. Then pushes these values back onto the stack.
If either of these elements is greater than or equal to 2^32, the result of this operation is undefined.
U32assert2
Pops two elements off the stack and checks if each of them represents a 32-bit value. If both of them are, they are pushed back onto the stack, otherwise an error is returned.
U32add3
Pops three elements off the stack, adds them together, and splits the result into upper and lower 32-bit values. Then pushes the result back onto the stack.
U32sub
Pops two elements off the stack and subtracts the first element from the second. Then, the result, together with a flag indicating whether subtraction underflowed is pushed onto the stack.
If their of the values is greater than or equal to 2^32, the result of this operation is undefined.
U32mul
Pops two elements off the stack, multiplies them, and splits the result into upper and lower 32-bit values. Then pushes these values back onto the stack.
If their of the values is greater than or equal to 2^32, the result of this operation is undefined.
U32madd
Pops two elements off the stack and multiplies them. Then pops the third element off the stack, and adds it to the result. Finally, splits the result into upper and lower 32-bit values, and pushes them onto the stack.
If any of the three values is greater than or equal to 2^32, the result of this operation is undefined.
U32div
Pops two elements off the stack and divides the second element by the first. Then pushes the integer result of the division, together with the remainder, onto the stack.
If their of the values is greater than or equal to 2^32, the result of this operation is undefined.
U32and
Pops two elements off the stack, computes their binary AND, and pushes the result back onto the stack.
If either of the elements is greater than or equal to 2^32, execution fails.
U32or
Pops two elements off the stack, computes their binary OR, and pushes the result back onto the stack.
If either fo the elements is greater than or equal to 2^32, execution fails.
U32xor
Pops two elements off the stack, computes their binary XOR, and pushes the result back onto the stack.
If either of the elements is greater than or equal to 2^32, execution fails.
Pad
Pushes 0 onto the stack.
Drop
Removes to element from the stack.
Dup0
Pushes a copy of stack element 0 onto the stack.
Dup1
Pushes a copy of stack element 1 onto the stack.
Dup2
Pushes a copy of stack element 2 onto the stack.
Dup3
Pushes a copy of stack element 3 onto the stack.
Dup4
Pushes a copy of stack element 4 onto the stack.
Dup5
Pushes a copy of stack element 5 onto the stack.
Dup6
Pushes a copy of stack element 6 onto the stack.
Dup7
Pushes a copy of stack element 7 onto the stack.
Dup9
Pushes a copy of stack element 9 onto the stack.
Dup11
Pushes a copy of stack element 11 onto the stack.
Dup13
Pushes a copy of stack element 13 onto the stack.
Dup15
Pushes a copy of stack element 15 onto the stack.
Swap
Swaps stack elements 0 and 1.
SwapW
Swaps stack elements 0, 1, 2, and 3 with elements 4, 5, 6, and 7.
SwapW2
Swaps stack elements 0, 1, 2, and 3 with elements 8, 9, 10, and 11.
SwapW3
Swaps stack elements 0, 1, 2, and 3, with elements 12, 13, 14, and 15.
SwapDW
Swaps stack elements 0, 1, 2, 3, 4, 5, 6, and 7 with elements 8, 9, 10, 11, 12, 13, 14, and 15.
MovUp2
Moves stack element 2 to the top of the stack.
MovUp3
Moves stack element 3 to the top of the stack.
MovUp4
Moves stack element 4 to the top of the stack.
MovUp5
Moves stack element 5 to the top of the stack.
MovUp6
Moves stack element 6 to the top of the stack.
MovUp7
Moves stack element 7 to the top of the stack.
MovUp8
Moves stack element 8 to the top of the stack.
MovDn2
Moves the top stack element to position 2 on the stack.
MovDn3
Moves the top stack element to position 3 on the stack.
MovDn4
Moves the top stack element to position 4 on the stack.
MovDn5
Moves the top stack element to position 5 on the stack.
MovDn6
Moves the top stack element to position 6 on the stack.
MovDn7
Moves the top stack element to position 7 on the stack.
MovDn8
Moves the top stack element to position 8 on the stack.
CSwap
Pops an element off the stack, and if the element is 1, swaps the top two remaining elements on the stack. If the popped element is 0, the stack remains unchanged.
If the popped element is neither 0 nor 1, execution fails.
CSwapW
Pops an element off the stack, and if the element is 1, swaps the remaining elements 0, 1, 2, and 3 with elements 4, 5, 6, and 7. If the popped element is 0, the stack remains unchanged.
If the popped element is neither 0 nor 1, execution fails.
Push(Felt)
Pushes the immediate value onto the stack.
Read
Removes the next element from the advice tape and pushes it onto the stack.
ReadW
Removes a a word (4 elements) from the advice tape and overwrites the top four stack elements with it.
MLoadW
Pops an element off the stack, interprets it as a memory address, and replaces the remaining 4 elements at the top of the stack with values located at the specified address.
MStoreW
Pops an element off the stack, interprets it as a memory address, and writes the remaining 4 elements at the top of the stack into memory at the specified address.
MLoad
Pops an element off the stack, interprets it as a memory address, and pushes the first element of the word located at the specified address to the stack.
MStore
Pops an element off the stack, interprets it as a memory address, and writes the remaining element at the top of the stack into the first element of the word located at the specified memory address. The remaining 3 elements of the word are not affected.
SDepth
Pushes the current depth of the stack onto the stack.
RpPerm
Applies Rescue Prime permutation to the top 12 elements of the stack. The rate part of the sponge is assumed to be on top of the stack, and the capacity is expected to be deepest in the stack, starting at stack[8]. For a Rescue Prime permutation of [A, B, C] where A is the capacity, the stack should look like [C, B, A, …] from the top.
MpVerify
Verifies that a Merkle path from the specified node resolves to the specified root. This operation can be used to prove that the prover knows a path in the specified Merkle tree which starts with the specified node.
The stack is expected to be arranged as follows (from the top):
- depth of the path, 1 element.
- index of the node, 1 element.
- value of the node, 4 elements.
- root of the tree, 4 elements.
The Merkle path itself is expected to be provided by the prover non-deterministically (via advice sets). If the prover is not able to provide the required path, the operation fails. Otherwise, the state of the stack does not change.
MrUpdate(bool)
Computes a new root of a Merkle tree where a node at the specified position is updated to the specified value.
The stack is expected to be arranged as follows (from the top):
- depth of the node, 1 element
- index of the node, 1 element
- old value of the node, 4 element
- new value of the node, 4 element
- current root of the tree, 4 elements
The Merkle path for the node is expected to be provided by the prover non-deterministically (via advice sets). At the end of the operation, the old node value is replaced with the old root value computed based on the provided path, the new node value is replaced by the new root value computed based on the same path. Everything else on the stack remains the same.
If the boolean parameter is set to false, at the end of the operation the advice set with the specified root will be removed from the advice provider. Otherwise, the advice provider will keep track of both, the old and the new advice sets.
Implementations
sourceimpl Operation
impl Operation
pub const OP_BITS: usize = 7usize
sourcepub fn op_code(&self) -> u8
pub fn op_code(&self) -> u8
Returns the opcode of this operation.
Opcode patterns have the following meanings:
- 00xxxxx operations do not shift the stack; constraint degree can be up to 2.
- 010xxxx operations shift the stack the left; constraint degree can be up to 2.
- 011xxxx operations shift the stack to the right; constraint degree can be up to 2.
- 100xxx-: operations consume 4 range checks; constraint degree can be up to 3. These are used to encode most u32 operations.
- 101xxx-: operations where constraint degree can be up to 3. These include control flow operations and some other operations requiring high degree constraints.
- 11xxx–: operations where constraint degree can be up to 5. These include control flow operations and some other operations requiring very high degree constraints.
sourcepub fn is_control_op(&self) -> bool
pub fn is_control_op(&self) -> bool
Returns true if this operation is a control operation.
Trait Implementations
impl Copy for Operation
impl Eq for Operation
impl StructuralEq for Operation
impl StructuralPartialEq for Operation
Auto Trait Implementations
impl RefUnwindSafe for Operation
impl Send for Operation
impl Sync for Operation
impl Unpin for Operation
impl UnwindSafe for Operation
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more