Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

RewardMerkleTreeVerifier

Git Source

Title: RewardMerkleTreeVerifier

Solidity verifier for RewardMerkleTreeV2 compatible with Espresso’s reward system

  • Arity: 2 (binary tree)
  • Depth: 160 levels
  • Key length: 20 bytes (160 bits) - Ethereum addresses
  • EVM native keccak hash
  • Double hashing of leaves as cheap domain separator

State Variables

TREE_DEPTH

uint256 public constant TREE_DEPTH = 160

Functions

_hashLeaf

function _hashLeaf(uint256 value) internal pure returns (bytes32);

_hashInternal

function _hashInternal(bytes32 left, bytes32 right) internal pure returns (bytes32 hash);

computeRoot

Compute reward commitment from a key-value pair and proof.

Designed to authenticate non-zero values for non-zero keys; caller must ensure neither key nor value is zero.

function computeRoot(address key, uint256 value, bytes32[TREE_DEPTH] memory proof)
    internal
    pure
    returns (bytes32);

Parameters

NameTypeDescription
keyaddressThe key to prove - Ethereum address
valueuint256The value to prove - lifetime earned rewards amount
proofbytes32[TREE_DEPTH]The membership proof containing sibling hashes and numLeaves

Returns

NameTypeDescription
<none>bytes32The computed reward commitment