diff --git a/lib/crypto/ecdsa.js b/lib/crypto/ecdsa.js index 9ab220d0e..42fa7749e 100644 --- a/lib/crypto/ecdsa.js +++ b/lib/crypto/ecdsa.js @@ -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); } diff --git a/test/crypto/ecdsa.js b/test/crypto/ecdsa.js index 79cd53bb4..bce76cd1d 100644 --- a/test/crypto/ecdsa.js +++ b/test/crypto/ecdsa.js @@ -103,7 +103,7 @@ describe('ECDSA', function() { ecdsa.k.toBuffer().toString('hex') .should.not.equal('fcce1de7a9bcd6b2d3defade6afa1913fb9229e3b7ddf4749b55c4848b2a196e'); ecdsa.k.toBuffer().toString('hex') - .should.equal('6f4dcca6fa7a137ae9d110311905013b3c053c732ad18611ec2752bb3dcef9d8'); + .should.equal('727fbcb59eb48b1d7d46f95a04991fc512eb9dbf9105628e3aec87428df28fd8'); }); it('should compute this test vector correctly', function() { // test fixture from bitcoinjs