Merge pull request #366 from gabegattis/bug/BIP32SeedLength
Bug/bip32 seed length
This commit is contained in:
commit
e71cdb3bb2
|
@ -10,7 +10,7 @@ var run = function() {
|
||||||
console.log('https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\n');
|
console.log('https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki\n');
|
||||||
console.log('1) Make new hkey from randomly generated new seed');
|
console.log('1) Make new hkey from randomly generated new seed');
|
||||||
|
|
||||||
var randomBytes = crypto.randomBytes(256);
|
var randomBytes = crypto.randomBytes(32);
|
||||||
var hkey = HierarchicalKey.seed(randomBytes);
|
var hkey = HierarchicalKey.seed(randomBytes);
|
||||||
console.log('master extended private key: ' + hkey.extendedPrivateKeyString());
|
console.log('master extended private key: ' + hkey.extendedPrivateKeyString());
|
||||||
console.log('master extended public key: ' + hkey.extendedPublicKeyString());
|
console.log('master extended public key: ' + hkey.extendedPublicKeyString());
|
||||||
|
|
|
@ -63,6 +63,8 @@ HierarchicalKey.seed = function(bytes, network) {
|
||||||
bytes = new Buffer(bytes, 'hex'); //if not buffer, assume hex
|
bytes = new Buffer(bytes, 'hex'); //if not buffer, assume hex
|
||||||
if (bytes.length < 128/8)
|
if (bytes.length < 128/8)
|
||||||
return false; //need more entropy
|
return false; //need more entropy
|
||||||
|
if (bytes.length > 512/8)
|
||||||
|
return false;
|
||||||
var hash = coinUtil.sha512hmac(bytes, new Buffer('Bitcoin seed'));
|
var hash = coinUtil.sha512hmac(bytes, new Buffer('Bitcoin seed'));
|
||||||
|
|
||||||
var hkey = new HierarchicalKey(null);
|
var hkey = new HierarchicalKey(null);
|
||||||
|
|
Loading…
Reference in New Issue