Using HD Keys to derive PrivateKey?


#1

Hi,

I have setup my HD Keys but am having trouble deriving the address Private Key.

Going here: https://iancoleman.io/bip39/ and using this Mnemonic:

error domain own confirm carry fever child device pool north vacuum list

Here is my code to derive addresses:

const mnemonic = 'error domain own confirm carry fever child device pool north vacuum list';

const seed = bip39.mnemonicToSeedHex(mnemonic);

// Create HD object
const hdKey = HDKey.fromMasterSeed(new Buffer.from(seed, 'hex'));

// bitcoin
const childKey = hdKey.derive("m/44'/0'/0'/0/0");

Now here my code to get the Public Key and Address:

const privateKey = new bitcore.PrivateKey(childKey._privateKey); // not working

const publicKey = new bitcore.PublicKey(childKey._publicKey);

const address = publicKey.toAddress();

privateKey output is 1b5240e4937ccc2b218c508500f85cf387edde82c82357a7fafa0a727550349f where it should be:
Kx8pWUa7eb6XkrgL2Rgdk2sTayn9MgAvTv7oXgtfjZtCCHxnnGdk as per the bip39 site.

Any ideas? the API docs aren’t the best.