merkle: minor.
This commit is contained in:
parent
6a73f61a91
commit
f50416eaf9
@ -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;
|
||||
};
|
||||
|
||||
Loading…
Reference in New Issue
Block a user