Bitcoin Forum
May 02, 2024, 08:04:18 AM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Question regarding seeds  (Read 124 times)
BlackHatCoiner (OP)
Legendary
*
Offline Offline

Activity: 1512
Merit: 7340


Farewell, Leo


View Profile
November 01, 2020, 12:53:13 PM
 #1

I think I've fully understood the way seeds work. 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 your seed.

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. I remember forum experts talking about derivation paths (like m/44'/0'/0') but I don't get how I'll put them into code.

.
.HUGE.
▄██████████▄▄
▄█████████████████▄
▄█████████████████████▄
▄███████████████████████▄
▄█████████████████████████▄
███████▌██▌▐██▐██▐████▄███
████▐██▐████▌██▌██▌██▌██
█████▀███▀███▀▐██▐██▐█████

▀█████████████████████████▀

▀███████████████████████▀

▀█████████████████████▀

▀█████████████████▀

▀██████████▀▀
█▀▀▀▀











█▄▄▄▄
▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀▀
.
CASINSPORTSBOOK
▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄▄
▀▀▀▀█











▄▄▄▄█
1714637058
Hero Member
*
Offline Offline

Posts: 1714637058

View Profile Personal Message (Offline)

Ignore
1714637058
Reply with quote  #2

1714637058
Report to moderator
1714637058
Hero Member
*
Offline Offline

Posts: 1714637058

View Profile Personal Message (Offline)

Ignore
1714637058
Reply with quote  #2

1714637058
Report to moderator
Bitcoin mining is now a specialized and very risky industry, just like gold mining. Amateur miners are unlikely to make much money, and may even lose money. Bitcoin is much more than just mining, though!
Advertised sites are not endorsed by the Bitcoin Forum. They may be unsafe, untrustworthy, or illegal in your jurisdiction.
1714637058
Hero Member
*
Offline Offline

Posts: 1714637058

View Profile Personal Message (Offline)

Ignore
1714637058
Reply with quote  #2

1714637058
Report to moderator
1714637058
Hero Member
*
Offline Offline

Posts: 1714637058

View Profile Personal Message (Offline)

Ignore
1714637058
Reply with quote  #2

1714637058
Report to moderator
1714637058
Hero Member
*
Offline Offline

Posts: 1714637058

View Profile Personal Message (Offline)

Ignore
1714637058
Reply with quote  #2

1714637058
Report to moderator
A-Bolt
Legendary
*
Offline Offline

Activity: 2311
Merit: 2297


View Profile
November 01, 2020, 01:14:29 PM
 #2

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?

NBitcoin
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
November 02, 2020, 05:21:50 AM
Merited by ABCbits (2), Heisenberg_Hunter (1)
 #3

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)
Code:
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 ElectrumMnemonicTests

I 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.

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!