// SPDX-License-Identifier: MIT pragma solidity ^0.8.13; library LibMerkle { function verifyCalldata( bytes32[] calldata proof, bytes32 root, bytes32 leaf ) internal pure returns (bool) { bytes32 computed = leaf; for (uint256 i = 0; i < proof.length; i++) { bytes32 proofElement = proof[i]; computed = _hashPair(computed, proofElement); } return computed == root; } function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) { return a <= b ? keccak256(abi.encodePacked(a, b)) : keccak256(abi.encodePacked(b, a)); } }