Support more efficient merkle proofs through calldata (#3200)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
Co-authored-by: Francisco Giordano <frangio.1@gmail.com>
This commit is contained in:
Troy Salem
2022-06-01 16:36:42 -04:00
committed by GitHub
parent 6d00281593
commit 4fc9fd3efe
4 changed files with 67 additions and 25 deletions

View File

@ -13,23 +13,35 @@ contract MerkleProofWrapper {
return MerkleProof.verify(proof, root, leaf);
}
function verifyCalldata(
bytes32[] calldata proof,
bytes32 root,
bytes32 leaf
) public pure returns (bool) {
return MerkleProof.verifyCalldata(proof, root, leaf);
}
function processProof(bytes32[] memory proof, bytes32 leaf) public pure returns (bytes32) {
return MerkleProof.processProof(proof, leaf);
}
function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) public pure returns (bytes32) {
return MerkleProof.processProofCalldata(proof, leaf);
}
function multiProofVerify(
bytes32 root,
bytes32[] memory leafs,
bytes32[] memory proofs,
bool[] memory proofFlag
bytes32[] calldata leafs,
bytes32[] calldata proofs,
bool[] calldata proofFlag
) public pure returns (bool) {
return MerkleProof.multiProofVerify(root, leafs, proofs, proofFlag);
}
function processMultiProof(
bytes32[] memory leafs,
bytes32[] memory proofs,
bool[] memory proofFlag
bytes32[] calldata leafs,
bytes32[] calldata proofs,
bool[] calldata proofFlag
) public pure returns (bytes32) {
return MerkleProof.processMultiProof(leafs, proofs, proofFlag);
}