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.
This commit is contained in:
bip32JP 2014-12-28 20:32:40 +09:00
parent 1416793c1c
commit a209aac217

View file

@ -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;
}