Skip to main content

SparseMerkleTreeVerifier

SafeCastOverflowedUintDowncast

error SafeCastOverflowedUintDowncast(uint8 bits, uint256 value)

Value doesn't fit in a uint of bits size. This is based on OpenZeppelin's SafeCast library.

LeafIndexOutOfBounds

error LeafIndexOutOfBounds(uint32 leafIndex, uint32 maxAllowedIndex)

Custom error for when the leaf index is out of bounds.

_verifyMerkleProof

function _verifyMerkleProof(bytes32 _leafHash, bytes32[] _proof, uint32 _leafIndex, bytes32 _root) internal pure returns (bool proofIsValid)

Verify merkle proof

The depth of the tree is expected to be validated elsewhere beforehand.

Parameters

NameTypeDescription
_leafHashbytes32Leaf hash.
_proofbytes32[]Sparse merkle tree proof.
_leafIndexuint32Index of the leaf.
_rootbytes32Merkle root.

Return Values

NameTypeDescription
proofIsValidboolReturns if the proof is valid or not.

safeCastToUint32

function safeCastToUint32(uint256 _value) internal pure returns (uint32 castUint32)

Tries to safely cast to uint32.

This is based on OpenZeppelin's SafeCast library.

Parameters

NameTypeDescription
_valueuint256The value being cast to uint32.

Return Values

NameTypeDescription
castUint32uint32Returns a uint32 safely cast.