State Related Functions
State Model of ZKWASM
We support a build-in set of merkle tree manipulating APIs as follows.
The build-in merkle tree is of depth 32 and the leafs are of index from 0 to 2^32-1. Also the host APIs follows a io convention. For instance, to get the data at leaf [index=0] with merkle root where root is of type [u64; 4], we need
set the leaf index we would like to query
set the merkle root which indicates which merkle we are querying
call merkle_get to get query the data
get the merkle root again (this is for the convention of the merkle host circuits)
Similarly, when set a leaf of a given merkle tree (specified by the merkel root of type [u64; 4] we need to follow the following convention:
Please refer to https://github.com/DelphinusLab/zkWasm-rust/blob/main/src/merkle.rs for more details about using the Merkle APIs to construct a sparse Merkle tree of depth 256.
It is high recommended that instead of using the raw Merkle APIs, using the structured implementation for your data storage.
Last updated