Skip to content

MerkleTreeWithHistoryPoseidon.sol

Implementation

Description

The MerkleTreeWithHistoryPoseidon is abstract contract and data structure which holds the commitments of deposits - which are hashes of secret values picked by the user. When a user wishes to withdraw from the mixer, the user needs to submit a proof which shows the knowledge of these secret values.

Variables

hasher

Type: public immutable IPoseidonT3

levels

Type: public immutable uint32

filledSubtrees

Type: public mapping(uint256 => bytes32)

roots

Type: public mapping(uint256 => bytes32)

ROOT_HISTORY_SIZE

Type: public constant uint32

currentRootIndex

Type: public uint32

nextIndex

Type: public uint32

Constructor

Details

Signature

constructor(uint32 _levels, IPoseidonT3 _hasher)

Requires

  • require(_levels > 0)
  • require(_levels < 32)

External Functions

hashLeftRight

Details

Signature

function hashLeftRight(IPoseidonT3 _hasher, bytes32 _left, bytes32 _right) public pure returns (bytes32)

Requires

  • require(..., "_left should be inside the field")
  • require(..., "_right should be instide the field")

View Functions

isKnownRoot

Details

Signature

isKnownRoot(bytes32 _root) public view returns (bool)

getLastRoot

Details

Signature

getLastRoot() public view returns (bytes32)

zeros

Details

Signature

zeros(uint256 i) public pure returns (bytes32)

Internal Functions

_insert

Details

Signature

_insert(bytes32 _leaf) internal returns (uint32 index)

Requires

  • require(..., "merkle tree is full")