From a209aac21700ddaff495f4e0914a52d7b4a00f61 Mon Sep 17 00:00:00 2001 From: bip32JP Date: Sun, 28 Dec 2014 20:32:40 +0900 Subject: [PATCH] Preserve entropy of x iterative hashing without attempting to preserve entropy is not best practice. I lowered iteration count to keep the same amount of time for the function. with (x).length, it was almost 16 times slower, and if divided by 16 the whole process took the same amount of time. Considering the length is usually around 1600 for me, that means somewhere around 100 iterations including the entirety of x in each hash concatenated with the current iteration of r. --- js/coin.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/js/coin.js b/js/coin.js index 95e36e0..a1a2c1a 100644 --- a/js/coin.js +++ b/js/coin.js @@ -56,8 +56,8 @@ x += coinjs.random(64); x += x+''+x; var r = x; - for(i=0;i<(x).length;i++){ - r = Crypto.SHA256(r); + for(i=0;i<(x).length/16;i++){ + r = Crypto.SHA256(r.concat(x)); } return r; }