{
    "Function": "processMultiProof",
    "File": "contracts/lib/openzeppelin-contracts/contracts/utils/cryptography/MerkleProof.sol",
    "Parent Contracts": [],
    "High-Level Calls": [],
    "Internal Calls": [
        "require(bool,string)",
        "_hashPair"
    ],
    "Library Calls": [],
    "Low-Level Calls": [],
    "Code": "function processMultiProof(\n        bytes32[] memory leafs,\n        bytes32[] memory proofs,\n        bool[] memory proofFlag\n    ) internal pure returns (bytes32 merkleRoot) {\n        // This function rebuild the root hash by traversing the tree up from the leaves. The root is rebuilt by\n        // consuming and producing values on a queue. The queue starts with the `leafs` array, then goes onto the\n        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n        // the merkle tree.\n        uint256 leafsLen = leafs.length;\n        uint256 proofsLen = proofs.length;\n        uint256 totalHashes = proofFlag.length;\n\n        // Check proof validity.\n        require(leafsLen + proofsLen - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n        // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n        bytes32[] memory hashes = new bytes32[](totalHashes);\n        uint256 leafPos = 0;\n        uint256 hashPos = 0;\n        uint256 proofPos = 0;\n        // At each step, we compute the next hash using two values:\n        // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n        //   get the next hash.\n        // - depending on the flag, either another value for the \"main queue\" (merging branches) or an element from the\n        //   `proofs` array.\n        for (uint256 i = 0; i < totalHashes; i++) {\n            bytes32 a = leafPos < leafsLen ? leafs[leafPos++] : hashes[hashPos++];\n            bytes32 b = proofFlag[i] ? leafPos < leafsLen ? leafs[leafPos++] : hashes[hashPos++] : proofs[proofPos++];\n            hashes[i] = _hashPair(a, b);\n        }\n\n        return hashes[totalHashes - 1];\n    }"
}