I am confused about getting the private key corresponding to the address for derivation path m/44'/60'/0'/0'/0'
Question 1: Is the following code correct in getting the address and private key? Why is the private key obtained a Buffer
object?
<Buffer fd 5f 63 c0 6b 5a 99 c4 c6 9a 05 07 01 c7 fd 04 cd b5 39 b6 2e 58 4e 63 98 c4 7c 28 5e b8 31 fa>
If I understand correctly the various depth of the path:
44'
means BIP4460'
means Ethereum0'
means wallet #00
means public,1
means private?? What does public and private means?0
means index 0
Question 2: Why is there a '
behind some of the numbers?
Code:
var bitcore = require('bitcore-lib');
var EthereumBip44 = require('ethereum-bip44');
var seed = 'xprv9s21ZrQH143K2uRcdeb2VJAEwhJQCtAjTCgx9JQt5NGhSkG4xGiuXvea8yN3tz3Q4LwPoP8j2cwERYNyw959ed9yqCrHGT1oDxJhNWoobqf'
var hdKey = new bitcore.HDPrivateKey(seed);
console.log('HD Key: ', hdKey.toString())
console.log('---')
var derivationPath = "m/44'/60'/0'/0'";
var derivedPrivKey = hdKey.derive(derivationPath)
var derivedPubKey = hdKey.derive(derivationPath).hdPublicKey
console.log('Derivation Path: ', derivationPath)
console.log('Extended Private Key: ', derivedPrivKey.toString())
console.log('Extended Public Key: ', derivedPubKey.toString())
console.log('---')
var wallet = new EthereumBip44.fromPrivateSeed(derivedPrivKey)
console.log('Wallet (0) Address: ', wallet.getAddress(0))
// 0x10ea551752f7ba9fd73d19baa16b234585e2c45d
console.log('Wallet (0) Private Key: ', wallet.getPrivateKey(0))
// <Buffer fd 5f 63 c0 6b 5a 99 c4 c6 9a 05 07 01 c7 fd 04 cd b5 39 b6 2e 58 4e 63 98 c4 7c 28 5e b8 31 fa>
Output
HD Key: xprv9s21ZrQH143K2uRcdeb2VJAEwhJQCtAjTCgx9JQt5NGhSkG4xGiuXvea8yN3tz3Q4LwPoP8j2cwERYNyw959ed9yqCrHGT1oDxJhNWoobqf
---
Derivation Path: m/44'/60'/0'/0'
Extended Private Key: xprvA1Q3FUbfXYKGzLiE9FgpgiBC4yrBkZm2eEQvBCtF95gvF6RQ1c1tWqeeemMDXczBwEi76wKrRR7oJPBQCsn9ghBSdigGdo5ZXE8WpX68t57
Extended Public Key: xpub6EPPez8ZMusaCpnhFHDq3r7vd1ggA2Ut1TLWybHrhRDu7tkYZ9L94dy8VzvGNYjxiCFjpK4xbaBzaXkmWiU4Bj3q3SgwYrqJLKJP9SiQ2t1
---
Wallet (0) Address: 0x10ea551752f7ba9fd73d19baa16b234585e2c45d
Wallet (0) Private Key: <Buffer fd 5f 63 c0 6b 5a 99 c4 c6 9a 05 07 01 c7 fd 04 cd b5 39 b6 2e 58 4e 63 98 c4 7c 28 5e b8 31 fa>