Decoding phrase BIP39: Why pbkdf2_hmac
and bip39 vs. Tool BIP39 IAN Coleman **
When you are trying to convert the BIP39 phrase to the private key of Seed, XPRP and XPRV, you may face discrepancies between the PBKDF2_HMAC output and BIP39 IAN Coleman. In this article, we dive into differences and examine why these discrepancies occur.
phrases understanding BIP39
The BIP39 (offer to improve Bitcoins 39) is a standardized way to portray Bitcoin addresses in the format of the person read. The BIP39 phrase consists of words that create a private key when the chain and hassing using the SHA-256 (with salt). The resulting circuit is divided into four parts: prefix, seed, Xprir root and other Xprir root.
Function pbkdf2_hmac
The PBKDF2_HMAC, which is installed at the Python Bitcoins Library (Bcrypt, which is part of the Bitcoins software), uses key -based key derivative (PBKDF) at the bag preliminary salt table. This feature can be used as a pre -processing step for the BIP39 phrase.
However, pbkdf2_hmac 'output is not the same as BIP39 Ian Coleman. There are several reasons:
* HASHEM Schematic :pbkdf2_hmacuses Sha-256 salt value from the sentence itself, while BIP39 IAN Coleman creates its salt-based salt values.
* Salt generation : Although both tools generate salt, they can create slightly different values. This can lead to differences in the incoming bag.
ian Coleman BIP39
BIP39 Ian Colemana is an easier way to convert phrases to private keyboards, generating salt values directly from the input phrase and bag-256. The exit is then divided into seed, Xprir root and other roots Xpr.
Why the difference?
Differences are due to two main factors:
1
2.
Conclusion
Although both measures can be used to convert the BIP39 phrases into private keys, their implementation varies. If you are working on several implementations or you need to control the bag more accurately, consider using the IAN Coleman method. However, in most cases, the PBKDF2_HMAC can still produce acceptable results.
CODE EXAMPLE
Here is an example of how you can use both tools:
Python
Imported Bitcoin
Bip39 phrase
phrase = “prefer puppy suggestions that mimic the pink banana for a loud work of whale art”
BIP39 Iana Coleman tool
Salt = bitcoin.crypto.Generation_salt (phrase)
Private_Key = bitcoin.crypto.pbkdf2_hmac (salt, ‘0000’, 65536, sha_256)
The output of both tools may vary
Print (private_key.hex ())
should print bag with right salt and output
Using the Ian Coleman method to get the seed
Seed = int.from_bytes (bitcoin.crypto.pbkdf2_hmac (b’0000 ‘, phrase.encode (), 65536, sha_256) .Hex (),’ Big ‘))))
`
Remember that real products may vary due to differences in salt formation and bag schemes.