I have implemented address generation using HDWallet as shown in the snippet below:
let Seed = generateMnemonic();
const wallet = EthHdWallet.fromMnemonic(Seed);
console.log("Wallet" + JSON.stringify(wallet));
console.log(typeof wallet);
let address = wallet.generateAddresses(3);
console.log("Wallet after address generation: " + JSON.stringify(wallet));
console.log("Address generated: " + address);
Wallet gives one object which contains:
_hdKey
(Has parameter_hdKey
which further have two parameterxpriv
&xpub
)_root
(Also Has parameter_hdKey
which further have two parameterxpriv
&xpub
different from hd key's parameter value)_children
(Generated addresses with its own private and public key pairs)
Difficulty about:
- What does that two key pairs indicates? which we get it under the
_hdKey
and_root
? - How to recover my address only using privateKey?