Skip to content

Instantly share code, notes, and snippets.

@plutoegg
Last active November 22, 2017 13:30
Show Gist options
  • Save plutoegg/0e19e410ff923bd9fa625b1d2fc438df to your computer and use it in GitHub Desktop.
Save plutoegg/0e19e410ff923bd9fa625b1d2fc438df to your computer and use it in GitHub Desktop.
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