NBitcoin and Mnemonic Standards

1.2k views Asked by At

I am very new to Bitcoin development so forgive me...

I'm using NBitcoin in a .Net console app to generate a master key using a mnemonic and then derive hierarchical keys. Here is the code I am using:

Mnemonic mnemo = new Mnemonic(Wordlist.English, WordCount.Twelve);
ExtKey hdroot = mnemo.DeriveExtKey();
var wif = hdroot.GetWif(Network.Main);
var defaultAddress = hdroot.Derive(new KeyPath("m/0/0"));

Here is the Mnemonic I get as a result, as wells as a public address derived from the master key using the "m/0/0" path:

Mnemonic: dry brown drive parade drastic shine embrace hard report loan fold iron

Path: m/0/0/: 1GcchMaHAN1XRQsoi8gPg8TShqzN4sNGvu

I tested recreating my keys using the mnemonic and was always able to derive the same exact keys as expected within my console app.

Being curious I wanted to see if I could import this mnemonic into existing wallet software and get the same keys as well. Since the Exodus wallet uses a standard twelve word mnemonic I fired it up and generated my wallet using the same mnemonic. However none of the keys match up! I exported my public key and made sure it was the same path of "m/0/0" from the master. As you can see it is NOT a match:

Exported public key from Exodus using the same mnemonic:

Mnemonic: dry brown drive parade drastic shine embrace hard report loan fold iron

Address: 1DMDJ266gxMCJiTcWk5MZFbfxxx4Ss3URN

Path: m/0/0

I also tested the mnemonic on Jaxx as well as the the Coinomi wallet on Android and it derived the same keys as Exodus does.

So I am completly confused. The only thing I can think of is that there is a standard entropy that these wallets use that is missing from my implementation?

My question is, how can I use NBitcoin to create the same mnemonic standrad that wallets like Exodus, Coinomi and Jaxx use?

1

There are 1 answers

0
feedthedogs On BEST ANSWER

1DMD is generated by the path m/44'/0'/0'/0/0

try this:

Mnemonic mnemo = new Mnemonic("dry brown drive parade drastic shine embrace hard report loan fold iron",Wordlist.English);
ExtKey hdroot = mnemo.DeriveExtKey();
var firstprivkey = hdroot.Derive(new KeyPath("m/44'/0'/0'/0/0"));
var firstpubKey = firstprivkey.Neuter().PubKey;
return firstpubKey.GetAddress(Network.Main).ToString();