SparseMerkleProof
Account​
The Account struct represents the state of the account including the storage root, nonce, balance and codesize
This is mapped directly to the output of the storage proof
struct Account {
uint64 nonce;
uint256 balance;
bytes32 storageRoot;
bytes32 mimcCodeHash;
bytes32 keccakCodeHash;
uint64 codeSize;
}
Leaf​
Represents the leaf structure in both account and storage tries
This is mapped directly to the output of the storage proof
struct Leaf {
uint256 prev;
uint256 next;
bytes32 hKey;
bytes32 hValue;
}
WrongBytesLength​
error WrongBytesLength(uint256 expectedLength, uint256 bytesLength)
Thrown when expected bytes length is incorrect
LengthNotMod32​
error LengthNotMod32()
Thrown when the length of bytes is not in exactly 32 byte chunks
MaxTreeLeafIndexExceed​
error MaxTreeLeafIndexExceed()
Thrown when the leaf index is higher than the tree depth
WrongProofLength​
error WrongProofLength(uint256 expectedLength, uint256 actualLength)
Thrown when the length of the unformatted proof is not provided exactly as expected (UNFORMATTED_PROOF_LENGTH)
TREE_DEPTH​
uint256 TREE_DEPTH
UNFORMATTED_PROOF_LENGTH​
uint256 UNFORMATTED_PROOF_LENGTH
ZERO_HASH​
bytes32 ZERO_HASH
MAX_TREE_LEAF_INDEX​
uint256 MAX_TREE_LEAF_INDEX
verifyProof​
function verifyProof(bytes[] _rawProof, uint256 _leafIndex, bytes32 _root) external pure returns (bool)
Formats input, computes root and returns true if it matches the provided merkle root
Parameters​
Name | Type | Description |
---|---|---|
_rawProof | bytes[] | Raw sparse merkle tree proof |
_leafIndex | uint256 | Index of the leaf |
_root | bytes32 | Sparse merkle root |
Return Values​
Name | Type | Description |
---|---|---|
[0] | bool | If the computed merkle root matches the provided one |
mimcHash​
function mimcHash(bytes _input) external pure returns (bytes32)
Hash a value using MIMC hash
Parameters​
Name | Type | Description |
---|---|---|
_input | bytes | Value to hash |
Return Values​
Name | Type | Description |
---|---|---|
[0] | bytes32 | bytes32 Mimc hash |
getLeaf​
function getLeaf(bytes _encodedLeaf) external pure returns (struct SparseMerkleProof.Leaf)
Get leaf
Parameters​
Name | Type | Description |
---|---|---|
_encodedLeaf | bytes | Encoded leaf bytes (prev, next, hKey, hValue) |
Return Values​
Name | Type | Description |
---|---|---|
[0] | struct SparseMerkleProof.Leaf | Leaf Formatted leaf struct |
getAccount​
function getAccount(bytes _encodedAccountValue) external pure returns (struct SparseMerkleProof.Account)
Get account
Parameters​
Name | Type | Description |
---|---|---|
_encodedAccountValue | bytes | Encoded account value bytes (nonce, balance, storageRoot, mimcCodeHash, keccakCodeHash, codeSize) |
Return Values​
Name | Type | Description |
---|---|---|
[0] | struct SparseMerkleProof.Account | Account Formatted account struct |
hashAccountValue​
function hashAccountValue(bytes _value) external pure returns (bytes32)
Hash account value
Parameters​
Name | Type | Description |
---|---|---|
_value | bytes | Encoded account value bytes (nonce, balance, storageRoot, mimcCodeHash, keccakCodeHash, codeSize) |
Return Values​
Name | Type | Description |
---|---|---|
[0] | bytes32 | bytes32 Account value hash |
hashStorageValue​
function hashStorageValue(bytes32 _value) external pure returns (bytes32)
Hash storage value
Parameters​
Name | Type | Description |
---|---|---|
_value | bytes32 | Encoded storage value bytes |
Return Values​
Name | Type | Description |
---|---|---|
[0] | bytes32 | bytes32 Storage value hash |
Contributions not accepted
These reference pages are automatically generated based on Linea's smart contracts. To ensure they accurately match the deployed smart contracts, we cannot accept any contributions that edit these pages.