[Simon asks] "Hi Andreas, I'm worried about derivation paths,
what it is and what I should know in case I have to use it.
Could you give us a brief example, please?
Thanks."
[aantonop Answers] This is something that we run into all the time, Simon,
and it causes a lot of problems and confusion,
especially for new users.
If you just write down your mnemonic phrase,
you may run into difficulty.
And the reason you may run into difficulty
is because different wallets implement their key derivation,
in different ways.
Let me explain what it [key derivation] is.
Let me explain how it works.
And then we'll talk about some strategies
to protect yourself against any problems
with regards to derivation paths.
So your mnemonic phrase is 12 to 24 words.
It includes a checksum so you can't get it wrong.
And it is mixed with an optional passphrase.
If you have no passphrase,
it's mixed with the word mnemonic.
But if you do have a passphrase,
it's mixed with a passphrase instead.
Those 12 to 24 words plus the passphrase
mix together through a key derivation function
that mixes them a few thousand times,
and then produces a 512 bit master key and chain code,
which you never see.
But if you did see it, it would be encoded
as base58 encoding called xpriv.
It starts with xpriv, x p-r-i-v.
That is your master private key.
And the corresponding master public key,
the xpub.
And those are long, they're 512 bits
and they contain both a key and a chain code.
Now think of this as the root of a tree.
And this tree is the so-called
hierarchical deterministic wallet.
Which simply means a wallet where keys can be derived
in a sequence, in a predictable manner, deterministic.
And they're all derived from the same master.
So the mnemonic phrase is the ingredient that goes
into the cauldron and gets mixed together with a passphrase.
And then it produces a root key.
And that root key is the root key from which the tree grows.
Now this is a weird tree.
And the reason it's a weird tree is because
at every level of the tree,
it branches off into 4 billion branches.
That means that under the roots or above the roots,
you have 4 billion possible branches.
And then those branches each break
into 4 billion possible branches.
And then those branches each
into 4 billion possible branches.
And then those branches break
into 4 billion possible branches.
Which means that you can't really just shake the tree
and see if some keys fall out.
Searching that tree is not really possible.
So if your wallet just randomly picks a branch
and throws your keys on that branch,
even if you have the seed necessary to plant the tree
and create the roots, et cetera, you don't know
where on the tree to look for the keys
that produce the addresses
that you can find your money on.
So, that's really the derivation path,
[it is] a map for the tree.
It usually it's represented by a, a string that starts
with a letter m, and m simply means master.
[...] starts from the master key.
Perhaps you will have seen this written down
as something like m44 and the little
prime mark, slash zero prime, slash zero prime, slash zero. [m44'/0'/0'/0]
You may see that as the path of your first address.
That would be in a wallet that's behaving well
and has followed, what's known as the BIP 43 / BIP 44 standard.
The standard is a basically
a map of where you should hang keys
on this tree.
Which branches specifically you should use.
And the 44th branch is a particular standard.
It means that wallets that the follow
this standard BIP 44,
hang all of their keys on the 44th branch.
And that's how you identify
that they're following the standard.
And below that they create one branch
for each of your sub-accounts.
With a hierarchal deterministic wallet
you're gonna have account zero, account one,
account two to separate your affairs.
And then below that they have one branch
for all of the receive addresses,
and one branch for all of the change addresses.
And then below that are the actual keys
for the receive and change addresses.
A wallet that follows the BIP44 standard
will put those keys in that particular location.
Which means that if you then import that seed
in another wallet that also follows that standard,
it's going to plant the seed.
It's gonna create the master key which is the root.
It's then going to look on the 44th branch.
It's going to look on the 0th sub branch
for your first account.
It's gonna look on the zero sub branch
of that for receive addresses.
And it's going to look at the first address
or 0th address hanging off that branch,
derive the key and the address.
And it's going to look on the blockchain to see
if there is some money stored,
or has ever been a transaction stored.
And if it does find money, it will then start importing
all of the addresses off that branch,
until it finds an empty gap called the gap limit.
Which tells it that you haven't gotten that far
in your wallet, and you haven't used the last 20 addresses.
20 is the common gap limit.
So that's what the derivation path is.
It's a map that allows you to traverse the tree
to find which branch or keys are on now.
Unfortunately, that derivation path
is not stored in the seed.
This is one of the design weaknesses
of the BIP39 mnemonic phrase standard.
And so then the mnemonic phrase itself,
the 12 to 24 words, doesn't contain a map
of where on the tree, these keys will be.
And that is under the assumption
that everybody will use the 44 standard branch.
And then put sub-accounts there for different currencies
different accounts, et cetera, et cetera.
the BIP44 standard also allows
for multiple different currencies.
So there's a different branch for Bitcoin
and a different branch for Ethereum,
and a different branch for Litecoin.
And basically any type of cryptocurrency
or blockchain that can support mnemonic phrases,
derived under this standard, has a branch that it uses.
So you can have a single mnemonic phrase that has branches
for all of your cryptocurrencies,
and can generate billions of keys for you
with billions of addresses that you can store your funds.
Now, if you don't know what derivation path your wallet
is using, one of the ways that you can find it
is from a website that collects that information.
Which is really great.
It's called http://www.walletsrecovery.org.
Wallets, plural recovery, all one word.
http://www.walletsrecovery.org
I'll put the link in the description.
And http://www.walletsrecovery.org has a list
of all of the derivation paths,
used by the most common wallets.
And a guide to help you find them.
In fact I'm working on a mechanism
to help us search those branches.
And so that may be a way
for us to make it easier for newbies.
If you do not know the derivation path
of your wallet, then the next best thing you can do
is write down what wallet, model, brand, make if you like
and what version.
So you could write, for example, Electrum 3.38.
And if that's the wallet that you were using
when you put the funds on that mnemonic phrase,
then we can then later, perhaps help you by finding,
Oh what derivation path did Electrum use in version 3.38?
What derivation path did Coinomi or Blockstream Green
or BRD or whatever, use on that specific version?
So write down the wallets
and version in order to be able to then find that.
And you will discover from time to time
that when you move your mnemonic phrase
or copy of mnemonic phrase and initialize it
in another wallet, or another software system
for your hardware wallets, that it will appear to be empty.
And don't fret your money's still there.
It's just on a different branch
than the one your wallet is looking for.
And that causes a lot of confusion to newbies,
but it's, it's easily fixable.
As long as we find where that mnemonic phrase was last used.
("Unbounded")
If you enjoyed this video please subscribe, like and share.
All my work is shared for free.
So if you wanna support it, join me on patreon.com/aantonop
Thank you! ("Unbounded")