Skip to content

Commit 9f9e2f1

Browse files
author
Ryan X. Charles
committed
k should be 32 bytes, not 8 bytes
This is a bug with security implications. It is much easier to guess the value of k within a 64 byte range. This would lead to compromised private keys. The cryptography interface of bitcore is extremely poor. I recommend: * Get rid of the C++ code, since it makes everything more difficult with little benefit * Refactor all crypto, and have easily auditable bignum, point, ecdsa, and key classes * Then actually audit the crypto
1 parent d9ffe75 commit 9f9e2f1

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/common/Key.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ Key.calcPubKeyRecoveryParam = function(e, r, s, Q) {
159159

160160
Key.genk = function() {
161161
//TODO: account for when >= n
162-
return new bignum(SecureRandom.getRandomBuffer(8));
162+
var k = new bignum(SecureRandom.getRandomBuffer(32))
163+
return k;
163164
};
164165

165166
module.exports = Key;

0 commit comments

Comments
 (0)