You generate a random 128-bit number, then add a checksum in the end for every 32 bits of entropy. A 128-bit number contains 4 times 32 bits. This means that you'll add another 4 bits in the end of the entropy. Now we have 132 bits. For every 11 bits (converted to decimal) we get a number between 0 and 2047. Since 132/11=12 it means that we get 12 words.
That's correct but to cover everything the method is to generate 16, 20, 24, 28 or 32 bytes of entropy then compute SHA256 hash of that entropy, from that hash you add enough bits to your initial entropy to make it divisible by 11.
Now I would like to ask, are there any C# libraries that includes a function in which you can convert a BIP39 seed to private keys? I want to build a program that will take a seed and it'll generate me (for example) the 5 first private keys electrum would do.
BIP-39 and Electrum are two different algorithms that are not compatible with each other.
Feel free to check my project (
Bitcoin.Net)
string mn = "wild father tree among universe such mobile favorite target dynamic credit identify";
var elec = new ElectrumMnemonic(mn, BIP0039.WordLists.English, passPhrase: "pass123");
var bip39 = new BIP0039(mn, BIP0039.WordLists.English, passPhrase: "pass123");
var path = new BIP0032Path("m/44'/0'/0'");
PrivateKey[] elecKeys = elec.GetPrivateKeys(path, count: 5, startIndex: 0, step: 1);
PrivateKey[] bip39Keys = bip39.GetPrivateKeys(path, count: 5, startIndex: 0, step: 1);
You can look at the Tests project for examples:
BIP32Tests,
BIP39Tests and
ElectrumMnemonicTestsI remember forum experts talking about derivation paths (like m/44'/0'/0') but I don't get how I'll put them into code.
The derivation path is defined for
BIP-32. Mnemonic (
BIP-39 or what
Electrum does) is a deterministic way of generating the seed (entropy) for BIP-32 using a human readable string.