Author

Topic: how to get masterkey and consequent wallet keys from root seed? (Read 114 times)

legendary
Activity: 3472
Merit: 10611
seed = d213b3de1949e716b2e5fb96ae62efa0c27843debf4372e8840ebc7f87024f6cb10126e51bbfecd 362ac21105edef4c799b09c973d05a5b566b5173e185e7927

everything goes well until now, i have the seed, i have the entropy, etc, and everytime i generate an new one it can be verified at https://iancoleman.io/bip39/ and it works correctly, but the issue im having is what i do after getting the seed to generate the master private key ? thats what i aint understanding, how can i use the seed above to generate an key? which functions should i use? thanks and sorry if this sounds confusing
That would be the steps explained in BIP32. The seed you get here is the entropy used in BIP32 (it is called seed in test vectors too).
First compute HMACSHA512(data=seed, key="Bitcoin seed") then split the 64-byte result into two 32 byte parts. The first part is the master key and the second part is the chain-code.

From this point to derive a child key you perform a similar operation but change the data and key used in HMACSHA512. The key is always the parent chain-code and...
  If the index is hardened   => data is 0 | parent_private_key | index
  If the index isn't hardened => data is parent_public_key | index
The result is again split into two parts, first 32 byte is the key and second part the new chain-code.
For example for m/44'/0'/0/1 you repeat this 4 times each time with the next index (4' then 0' then 0 and finally 1).
newbie
Activity: 2
Merit: 0
i already did all of that, i dont know the best way to put my question out there without sound confusing, i think im probably missing some minor detail, so i will basically run my program once and put in there the results it return to me in that attempt, i think in that way i can be more clear on what i want to achieve

binary entropy = 1110110011101110100101110000101010111110011000011011100101000111110000101101111 0000001101110000001010001000011001110111100010111
hex entropy = ecee970abe61b947c2de06e0510cef17
hashed entropy (SHA256) = ce8c86f8fffc0e8d668013df98baca523238d4308a6139d0b2950daef3dbc3e9
resulted checksum = 1100
mnemonic in binary represation and in words representation below as well as their position in the world list  = ['11101100111', '01110100101', '11000010101', '01111100110', '00011011100', '10100011111', '00001011011', '11000000110', '11100000010', '10001000011', '00111011110', '00101111100']
undo 1895
input 933
section 1557
lamp 998
breeze 220
physical 1311
arena 91
school 1542
theory 1794
mask 1091
design 478
convince 380
['undo', 'input', 'section', 'lamp', 'breeze', 'physical', 'arena', 'school', 'theory', 'mask', 'design', 'convince']
after generating all that i then use pbkdf2 and hash it with sha512 in which will return me the actual seed(using an blank password as password)

seed = d213b3de1949e716b2e5fb96ae62efa0c27843debf4372e8840ebc7f87024f6cb10126e51bbfecd 362ac21105edef4c799b09c973d05a5b566b5173e185e7927

everything goes well until now, i have the seed, i have the entropy, etc, and everytime i generate an new one it can be verified at https://iancoleman.io/bip39/ and it works correctly, but the issue im having is what i do after getting the seed to generate the master private key ? thats what i aint understanding, how can i use the seed above to generate an key? which functions should i use? thanks and sorry if this sounds confusing


legendary
Activity: 3472
Merit: 10611
This should be converted to words then a 64 byte seed is derived using PBKDF2 which will be fed to the BIP32 function.
For details you should read BIP39[1] and BIP32[2], these two explain the process in details which is going to answer all your questions. You can also go to the bottom of the page to the Implementations sections and look at the source code to figure out any part that is not clear.
There are also test vectors with actual values that you can use for testing and debugging.

[1] https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki
[2] https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
newbie
Activity: 2
Merit: 0
So basically i am trying to create my own crypto wallet application in python, i have generated the random entropy, calculated the checksum, generated the 12 words and then generated the root seed using pbkdf2, but after generating the seed I'm kinda lost, i dont know how i can generate the master key and the chaincode, and then generating the public and private keys, lets put for example i have this root seed 1f8c67bc66355f62f6c63752803599cc6e4a05eac6dd63e05e858329f3656ed3c868bd428a4218b 4eb92e0fe5e774874c4ab270b8d1377ddc0aea6a797682342 what should i do with it to generate the master private key and then the following child public/private keys? thanks, i'm very new to this in general so sorry if there is any issue with my question

also i don't want to use any pre built script that generates wallets to me, thats why i am trying to create one by myself cause i want to understand better how it works by doing it manually
Jump to: