Fix the error loop.
I added a similar badrs function to python-ecdsa and compared the results. The 1 badrs (aka forcing it to loop once) gave me a different value. It turns out you missed one of the `v = hmac_k(v)` steps during the loop. Adding one extra `v = hmac_k(v)` in each loop makes it match up with python-ecdsa perfectly (I even tried up to badrs = 30 and it was fine.
This commit is contained in:
parent
9a5193d8e9
commit
95bfb18849
@ -100,6 +100,7 @@ ECDSA.prototype.deterministicK = function(badrs) {
|
||||
for (var i = 0; i < badrs || !(T.lt(N) && T.gt(0)); i++) {
|
||||
k = Hash.sha256hmac(Buffer.concat([v, new Buffer([0x00])]), k);
|
||||
v = Hash.sha256hmac(v, k);
|
||||
v = Hash.sha256hmac(v, k);
|
||||
T = BN.fromBuffer(v);
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user