How do HD wallets use mnemonic to recover all private keys?

2

As I understand, a wallet like BRD wallet can have many private keys and receiving addresses.

When I give them the mnemonic, how do they re-generate all of the relevant private keys from that mnemonic alone?

I saw a video on a master private key, and I cannot figure out how it all ties into it because I could generate multiple private keys from the master private keys, or I could generate multiple private keys from any of the children private keys of the master. How does the wallet know from just the mnemonic, which path I took?

Kyle Graham

Posted 2018-04-19T10:35:25.203

Reputation: 472

Can you add the video link please !Alireza Fattahi 2018-07-21T04:08:38.170

Answers

3

mnemonics are the seed. you use that to get your private key.

the rest of the story as you have pointed out, is about deriving child key pairs. The process is deterministic (as the letter D in HD), meaning that you can get the same tree of child keys from the root seed whenever you do that. This could go "indefinitely", so how would you know when to stop? The answer is that you need additional information about the depths.

In the case without branches, you simply need to know how many keys have been generated (whether they received payment or not) to get the full balance. Most implementations of default look-ahead and will stop checking after a certain number of addresses don't have any UTXO.

With branches, it gets a bit more complicated. But in theory, if you know where things branch and how deep it go, you can restore the full tree.

[EDIT] in response to your comment, there are standard ways though. For example, this picture here shows the hierarchy.

enter image description here

Will Gu

Posted 2018-04-19T10:35:25.203

Reputation: 318

So mnemonics are used to generate the private key, and mnemonics are derived from some random number.

I was hoping that there was a standard for branching out indefinitely. I was looking up derivation paths, but I was not able to infer any standard.

Thanks for the answer – Kyle Graham 2018-04-19T17:25:58.833

@KyleGraham I updated my answer with a picture showing standard HD wallet structure, if that's the standard you are looking forWill Gu 2018-04-19T17:31:30.117

Thanks a lot, the diagram helps clear things up a bit. I will get my feet wet and use it as a guide. It definitely helped!Kyle Graham 2018-04-19T17:34:06.493