Bitcoin Forum

Bitcoin => Development & Technical Discussion => Topic started by: Sanka555 on November 20, 2021, 02:24:14 PM



Title: Get master key from 128bit
Post by: Sanka555 on November 20, 2021, 02:24:14 PM
i write in Java

when i get master key from bip-39 string i do this

Quote
byte [] seed = PBKDF2SHA512.derive (seedCode, "mnemonic", 2048, 64);
DeterministicKey deterministicKey = HDKeyDerivation.createMasterPrivateKey (seed);
...
...
this works fine.

please tell me
what I need to fix in these two lines, to get the master key (deterministicKey) if I do not have string bip-39 at the entrance
 i have only 128 bit number like this
10101010101010101011000 ...... (128 characters)


Title: Re: Get master key from 128bit
Post by: BlackHatCoiner on November 20, 2021, 02:30:11 PM
What's the library? If the seedCode requires a seed phrase, then you should convert your 128-bit binary represented number to twelve words. If the seedCode requires an entropy then you should probably convert your binary represented number to hexadecimal or decimal.

It depends on what's seedCode and which type of parameter is the first one from PBKDF2SHA512.derive().


Title: Re: Get master key from 128bit
Post by: Sanka555 on November 20, 2021, 02:34:01 PM
library bitcoinj

I don't need to receive Seed. I need to get a master key (deterministicKey) from a 128-bit number


Title: Re: Get master key from 128bit
Post by: BlackHatCoiner on November 20, 2021, 02:53:31 PM
Alright, so I just checked it (https://www.tabnine.com/code/java/classes/org.bitcoinj.crypto.PBKDF2SHA512). seedCode is supposed to be a string.

I don't need to receive Seed. I need to get a master key (deterministicKey) from a 128-bit number
So what you're asking is how to get the master private key from the 128-bit number (which is the string by the name seedCode)? Is that correct?

Because, here you say without the BIP-39 string at the entrance and I'm wondering on what you are referring:
what I need to fix in these two lines, to get the master key (deterministicKey) if I do not have string bip-39 at the entrance


Title: Re: Get master key from 128bit
Post by: Sanka555 on November 20, 2021, 03:09:12 PM
Quote
So what you're asking is how to get the master private key from the 128-bit number (which is the string by the name seedCode)? Is that correct?
yes  :)


Title: Re: Get master key from 128bit
Post by: BlackHatCoiner on November 20, 2021, 03:17:34 PM
yes

And what's the BIP-39 entrance string?


Title: Re: Get master key from 128bit
Post by: Sanka555 on November 20, 2021, 03:23:12 PM
yes

And what's the BIP-39 entrance string?
for example
"dumb merry course mouse salmon first six charge shoot slogan shiver rule"



Title: Re: Get master key from 128bit
Post by: BlackHatCoiner on November 20, 2021, 03:39:44 PM
for example
"dumb merry course mouse salmon first six charge shoot slogan shiver rule"
So BIP-39 entrance is the seed phrase and seedCode is the variable that should contain the phrase, correct? So what you need is to convert your 128 bits to twelve words, right?

You should use MnemonicCode() (https://bitcoinj.org/javadoc/0.15/index.html?org/bitcoinj/crypto/MnemonicCode.html). I haven't tried it, but it should be fairly easy. And that's true if I've understood properly what you want to achieve. If any of the above questions' conclusion is incorrect, let me know.


Title: Re: Get master key from 128bit
Post by: nc50lc on November 21, 2021, 02:10:26 AM
what I need to fix in these two lines, to get the master key (deterministicKey) if I do not have string bip-39 at the entrance
 i have only 128 bit number -snip-
I don't need to receive Seed. I need to get a master key (deterministicKey) from a 128-bit number
There's no shortcut to this since the entropy (128 bit number) needs to be a 'UTF-8 normalized' mnemonic before you can get the 'binary seed'.
You'll need to do the above to convert it into a mnemonic, then use the result to your code.