Trait tasm_lib::snippet::Snippet

source ·
pub trait Snippet {
Show 18 methods // Required methods fn entrypoint(&self) -> String; fn inputs(&self) -> Vec<String>; fn input_types(&self) -> Vec<DataType>; fn output_types(&self) -> Vec<DataType>; fn outputs(&self) -> Vec<String>; fn stack_diff(&self) -> isize; fn function_code(&self, library: &mut SnippetState) -> String; fn crash_conditions(&self) -> Vec<String>; fn gen_input_states(&self) -> Vec<ExecutionState>; fn common_case_input_state(&self) -> ExecutionState; fn worst_case_input_state(&self) -> ExecutionState; fn rust_shadowing( &self, stack: &mut Vec<BFieldElement>, std_in: Vec<BFieldElement>, secret_in: Vec<BFieldElement>, memory: &mut HashMap<BFieldElement, BFieldElement> ); // Provided methods fn function_code_as_instructions( &self, library: &mut SnippetState ) -> Vec<LabelledInstruction> { ... } fn link_for_isolated_run(&self, words_statically_allocated: usize) -> String { ... } fn link_and_run_tasm_for_test( &self, stack: &mut Vec<BFieldElement>, std_in: Vec<BFieldElement>, secret_in: Vec<BFieldElement>, memory: &mut HashMap<BFieldElement, BFieldElement>, words_statically_allocated: usize ) -> VmOutputState { ... } fn link_and_run_tasm_for_bench( &self, stack: &mut Vec<BFieldElement>, std_in: Vec<BFieldElement>, secret_in: Vec<BFieldElement>, memory: &mut HashMap<BFieldElement, BFieldElement>, words_statically_allocated: usize ) -> Result<ExecutionResult> { ... } fn link_and_run_tasm_from_state_for_test( &self, execution_state: &mut ExecutionState ) -> VmOutputState { ... } fn link_and_run_tasm_from_state_for_bench( &self, execution_state: &mut ExecutionState ) -> Result<ExecutionResult> { ... }
}

Required Methods§

source

fn entrypoint(&self) -> String

The name of a Snippet

This is used as a unique identifier, e.g. when generating labels.

source

fn inputs(&self) -> Vec<String>

The input stack

source

fn input_types(&self) -> Vec<DataType>

source

fn output_types(&self) -> Vec<DataType>

source

fn outputs(&self) -> Vec<String>

The output stack

source

fn stack_diff(&self) -> isize

The stack difference

source

fn function_code(&self, library: &mut SnippetState) -> String

The function

source

fn crash_conditions(&self) -> Vec<String>

Ways in which this snippet can crash at runtime

source

fn gen_input_states(&self) -> Vec<ExecutionState>

Examples of valid initial states for running this snippet

source

fn common_case_input_state(&self) -> ExecutionState

source

fn worst_case_input_state(&self) -> ExecutionState

source

fn rust_shadowing( &self, stack: &mut Vec<BFieldElement>, std_in: Vec<BFieldElement>, secret_in: Vec<BFieldElement>, memory: &mut HashMap<BFieldElement, BFieldElement> )

Provided Methods§

source

fn function_code_as_instructions( &self, library: &mut SnippetState ) -> Vec<LabelledInstruction>

Implementors§

source§

impl Snippet for U32IsOdd

source§

impl Snippet for IsU32

source§

impl Snippet for LeadingZerosU32

source§

impl Snippet for OrU32

source§

impl Snippet for SafeAdd

source§

impl Snippet for SafeMul

source§

impl Snippet for SafeSub

source§

impl Snippet for ShiftLeftU32

source§

impl Snippet for ShiftRightU32

source§

impl Snippet for AddU64

source§

impl Snippet for AndU64

source§

impl Snippet for DecrU64

source§

impl Snippet for Div2U64

source§

impl Snippet for DivModU64

source§

impl Snippet for DoublePow2U64

source§

impl Snippet for EqU64

source§

impl Snippet for IncrU64

source§

impl Snippet for IndexOfLastNonZeroBitU64

source§

impl Snippet for LeadingZerosU64

source§

impl Snippet for Log2FloorU64

source§

impl Snippet for LtStandardU64

This lt_standard_u64 does consume its argument.

The fastest way we know is to calculate without consuming, and then pop the operands. This is because there are three branches, so sharing cleanup unconditionally means less branching (fewer cycles) and less local cleanup (smaller program).

source§

impl Snippet for LtU64

This lt_u64 does not consume its arguments, which is the norm for tasm functions.

See LtStandardU64 for a variant that does.

source§

impl Snippet for OrU64

source§

impl Snippet for PopCountU64

source§

impl Snippet for Pow2U64

source§

impl Snippet for SafeMulU64

source§

impl Snippet for ShiftLeftU64

source§

impl Snippet for ShiftRightU64

source§

impl Snippet for SubU64

source§

impl Snippet for WrappingMulU64

source§

impl Snippet for XorU64

source§

impl Snippet for AddU128

source§

impl Snippet for ShiftLeftU128

source§

impl Snippet for ShiftRightU128

source§

impl Snippet for SubU128

source§

impl Snippet for EqDigest

source§

impl Snippet for HashVarlen

source§

impl Snippet for LoadAuthPathFromSecretInSafeList

source§

impl Snippet for LoadAuthPathFromSecretInUnsafeList

source§

impl Snippet for LoadAuthPathFromStdInSafeList

source§

impl Snippet for LoadAuthPathFromStdInUnsafeList

source§

impl Snippet for ReverseDigest

source§

impl Snippet for SampleIndices

source§

impl Snippet for SwapDigest

source§

impl Snippet for LoadFromInput

Load a list of words from the input source into memory. The first element of the input source is the length of the list that is loaded into memory. Returns a pointer to the first element in memory.

source§

impl Snippet for LoadStructFromInput

Load several list of words from the input source into memory. The first element of each list is the length of the list that is loaded into memory. Returns a pointer to the first element in memory. This function is named load_struct_from_input because structs are encoded as a sequence of length-prepended lists of words. Note that the field_count input argument may never be set through user input, rather it should be known statically. This snippet assumes that the dynamic allocator will allocate all fields contiguously in memory.

source§

impl Snippet for ReadSecret

source§

impl Snippet for ReadStdIn

source§

impl Snippet for GetLength

source§

impl Snippet for GetPointerList

source§

impl Snippet for All

source§

impl Snippet for Filter

source§

impl Snippet for Map

source§

impl Snippet for Zip

source§

impl Snippet for MultisetEquality

source§

impl Snippet for Range

source§

impl Snippet for SafeGet

source§

impl Snippet for SafeLength

source§

impl Snippet for SafeNew

source§

impl Snippet for SafePop

source§

impl Snippet for SafePush

source§

impl Snippet for SafeSet

source§

impl Snippet for SafeSetLength

source§

impl Snippet for UnsafeGet

source§

impl Snippet for UnsafeLength

source§

impl Snippet for UnsafeNew

source§

impl Snippet for UnsafePop

source§

impl Snippet for UnsafePush

A parameterized version of Push where N is the size of an element in the list

source§

impl Snippet for UnsafeSet

source§

impl Snippet for UnsafeSetLength

source§

impl Snippet for DynMalloc

source§

impl Snippet for MemCpy

source§

impl Snippet for PushRamToStack

source§

impl Snippet for BagPeaks

source§

impl Snippet for CalculateNewPeaksFromAppend

source§

impl Snippet for MmrCalculateNewPeaksFromLeafMutationMtIndices

source§

impl Snippet for DataIndexToNodeIndex

source§

impl Snippet for GetHeightFromDataIndex

source§

impl Snippet for MmrLeafIndexToMtIndexAndPeakIndex

source§

impl Snippet for MmrLeftChild

source§

impl Snippet for MmrLeftMostAncestor

source§

impl Snippet for MmrLoadFromSecretInThenVerify

source§

impl Snippet for MmrNonLeafNodesLeftUsingAnd

source§

impl Snippet for MmrRightChild

source§

impl Snippet for MmrRightChildAndHeight

source§

impl Snippet for MmrRightLineageCountAndHeight

source§

impl Snippet for MmrRightLineageLength

source§

impl Snippet for MmrVerifyFromMemory

source§

impl Snippet for MmrVerifyLeafMembershipFromSecretIn

source§

impl Snippet for Commit

source§

impl Snippet for GetSwbfIndices

source§

impl Snippet for BfeAdd

source§

impl Snippet for Lsb

source§

impl Snippet for Neg

source§

impl Snippet for Sub

source§

impl Snippet for DummyTestSnippetA

source§

impl Snippet for DummyTestSnippetB

source§

impl Snippet for DummyTestSnippetC

source§

impl Snippet for GetField

source§

impl Snippet for GetFieldWithSize

source§

impl<H: AlgebraicHasher + Debug> Snippet for MtApVerifyFromSecretInput<H>

TVM assembly to verify Merkle authentication paths

input: number of authentication paths, merkle root, authentication paths, each one preceded by the corresponding node index in the merkle tree, where the authentication path starts

output: Result<(), VMFail>

uses RAM at address 0 to store the number of authentication paths

source§

impl<const N: u8> Snippet for ShiftLeftStaticU128<N>

source§

impl<const N: u8> Snippet for ShiftRightStaticU128<N>