Last active
November 22, 2017 13:30
-
-
Save plutoegg/0e19e410ff923bd9fa625b1d2fc438df to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function validProof(bytes proof, bytes32 root, bytes32 hash) constant returns (bool) { | |
bytes32 el; | |
for (uint256 i = 32; i <= proof.length; i += 32) { | |
assembly { | |
el := mload(add(proof, i)) | |
} | |
if (hash < el) { | |
hash = sha3(hash, el); | |
} else { | |
hash = sha3(el, hash); | |
} | |
} | |
return hash == root; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment