merkle: minor.

This commit is contained in:
Christopher Jeffrey 2017-07-19 19:55:14 -07:00
parent 6a73f61a91
commit f50416eaf9
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD

View File

@ -95,14 +95,16 @@ exports.createBranch = function createBranch(index, leaves) {
*/
exports.verifyBranch = function verifyBranch(hash, branch, index) {
let root = hash;
for (let otherside of branch) {
if (index & 1)
hash = digest.root256(otherside, hash);
root = digest.root256(otherside, root);
else
hash = digest.root256(hash, otherside);
root = digest.root256(root, otherside);
index >>>= 1;
}
return hash;
return root;
};