From f50416eaf9f742d5201c3ddcb5c5e6467816cb33 Mon Sep 17 00:00:00 2001 From: Christopher Jeffrey Date: Wed, 19 Jul 2017 19:55:14 -0700 Subject: [PATCH] merkle: minor. --- lib/crypto/merkle.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/crypto/merkle.js b/lib/crypto/merkle.js index 8e05dd73..c54245a3 100644 --- a/lib/crypto/merkle.js +++ b/lib/crypto/merkle.js @@ -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; };