Skip to content
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.
This repository has been archived by the owner on Apr 3, 2019. It is now read-only.

Generated private key is 31 bytes instead of 32. #47

Open
@coder5876

Description

The derived() function sometimes returns 31 byte keys. In the derive() function here:

https://github.com/bitpay/bitcore-lib/blob/master/lib/hdprivatekey.js#L194

there is clearly the intention of having the Buffer padded to 32 bytes. But when testing the resulting private key is not padded. To replicate:

var Mnemonic = require('bitcore-mnemonic')
var seed = "erupt consider beyond twist bike enroll you salute weasel emerge divert hundred";
var hdprivkey = (new Mnemonic(seed)).toHDPrivateKey().derive("m/44'/60'/0'/0")
console.log(hdprivkey.privateKey.toBuffer().length) // prints 31

Related: Consensys/eth-lightwallet#60

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions