Let’s take if offline: BIP38 vs BIP39
Ballet
2022-09-20 16:57
订阅此专栏
收藏此文章

The differences and similarities.

The differences and similarities.

Despite the usage of the “vs” in the title denoting the word “versus”, this piece is in no way trying to shed more light on one over the other. But rather this piece is to provide more clarity and education into two private key encryption standards that are utilized in today’s crypto wallets.

Just to be clear, both standards are absolutely secure and nearly impossible to crack on a brute-force attempt. Although BIP39 is today’s most commonly used standard amongst many wallets, BIP38 doesn’t deserve the credit it deserves despite its nearly identical sound security it provides: and it’s the technological cryptographic cornerstone instilled in every Ballet wallet. And interestingly enough, both BIPs had multiple authors where one author, Aaron Voisine, contributed code to both BIP38 and BIP39.

The major difference between the two is the way encrypted private keys are generated, encoded, and stored.

And whether you are holding the BIP38 encrypted private key (along with a passphrase) or the BIP39 encrypted private key (in the form of human readable words), both come down to the responsibility of the user/holder of those private keys to keep them in a safe location and preferably backed up. So in either case, the proverbial “not your keys, not your crypto” are equally weighted in importance of private key security for both BIP38 and BIP39.

Let’s get started.

How does the BIP38 private key generation process work?

For a detailed breakdown of the BIP38 process, please refer to this other blog explaining the nuts and bolts.

The BIP38 standard (under the Encryption when EC multiply mode is used) allows two parties (Party A and Party B) to partake in the creation of the encrypted private keys. One party would hold the first part called the ‘passphrase’ and the other party would hold the second part known as the encrypted private keys in the format of 58 characters base58, starting with ‘6P’.

Party A starts by creating a randomly generated passphrase and some ‘salt’ to add more entropy to the process; an intermediate_passphrase_string is then derived and handed over to Party B to generate a public address and an encrypted private key. And to stress a key point here is that the intermediate_passphrase_string DOES NOT reveal the original passphrase, which is kept by Party A and is needed to decrypt the end resulting encrypted private key.

And in no part of the process reveals the unencrypted private key which is needed in signing transactions, until the user does so themselves.

Repeat: No part of the BIP38 encrypted private key generation reveals the decrypted (unencrypted) private key until the user uses both the passphrase and the encrypted private key in the signing of a transaction, which under the hood, then subsequently reveals the decrypted (unencrypted) private key. Just as a side note, the unencrypted private key usually takes the form of the Wallet Import Format (WIF).

The BIP38 standard was particularly chosen for the Ballet wallets due to this two party key generation functionality which is pivotal to our Two Factor Key Generation (2FKG) process. More on our 2FKG process can be found here.

To reiterate, having the encrypted private key in no way reveals the passphrase and vice versa. So in a way the BIP38 standard allows for the creation of a 2 of 2 multi-sig wallet. An analogy that Ballet Founder and CEO, Bobby Lee, described is to think of it as a safe deposit box that requires two keys. Just having access to one set of the keys is pointless.

How does the BIP39 mnemonic word seed phrase creation process work?

The BIP39 standard, which was proposed in 2013, is a standard that allows for private keys to be formatted as a mnemonic code seed phrase for generating deterministic keys. Amongst the popular wallets, many of them require you to write down a 12 or 24 word mnemonic code (also commonly referred to as a seed phrase) as a backup before proceeding to the next step of the wallet setup. Whether or not you think having to write down a bunch of words is a bit of hassle is subjective, but essentially those 24 words (we’ll just stick with the 24 word instead of saying ’12 or 24’) are masking your unencrypted private key in a human readable way.

After the generation of the 24 mnemonic words, those words then get passed through a password based key derivation function to create a binary seed, which is used for hierarchical deterministic wallet purposes. But we won’t get into that as that is where the slight differences between BIP38 and BIP39 start to diverge.

The way one’s 24 mnemonic words gets created starts with a random number of 256 bits which can also be formatted into hexadecimals. A checksum is then concatenated onto the end of the 256 bit entropy sequence. Then the whole entropy sequence is split into groups of 11 bits, with each group of 11 bits converted into its decimal form.

The decimal representation can vary from a range of 1–2048, which works out as an index of a mnemonic word list consisting of 2048 words. This official word list can be found here.

And in actuality, you only need the first 4 letters of the mnemonic word.

Example:

Start with 256 bit of entropy:

1011110100111010000100111111011010101001001100100111000110111101010000101010100111000110100101001001001010010100101001010101010100101001010101001011100101001001110001011010010100010101101011010101010101010100101001010100101010101010101010101101010010110101

Concatenate a checksum at the end:

Checksum = 01000100 = first 8 bits of SHA256 of entropy (44d41bf5f46ecc1bcef7c41ddfc8dcdc09175bf91a62b378d3df502910ca0dea)

101111010011101000010011111101101010100100110010011100011011110101000010101010011100011010010100100100101001010010100101010101010010100101010100101110010100100111000101101001010001010110101101010101010101010010100101010010101010101010101010110101001011010101000100

Split bit entropy into 24 groups of 11 bits, which will look like this:

And just like that you have 24 words that are formatted to conceal your private keys. To pronounce the equal security of both the BIP38 encrypted private key + passphrase and BIP39’s 24 mnemonic word seed, the WIF unencrypted private key, that belongs to the 24 word seed, can also be encrypted using BIP38 (non-EC multiply).

So if we take a look at the image above: Figure A represents a BIP39 mnemonic word phrase and Figure B represents a BIP38 encrypted private key used in tandem with a passphrase. Both are just different formats of the same exact WIF unencrypted private key, which subsequently has access to the same exact UTXOs.

Different formats, same security, same UTXOs, same bitcoins.

Differences and similarities

As shown above, both the BIP38 and BIP39 can convert a WIF unencrypted private key into different formats but essentially both cryptographically mask the private key. We’ll point out some of the nuanced differences and similarities between the two below.

Year Proposed

The BIP38 standard was the first to have been proposed back in 2012, authored by Mike Caldwell and Aaron Voisine. The BIP39 standard was introduced a year later in 2013 with 4 different authors including Aaron Voisine.

Security

Considering that both utilize the SHA256 deterministic one way hashing function (along with other crypto native functions), which is nearly impossible to crack, you can be assured that both are just as secure as SHA256.

Methodology

BIP38 actually has two methodologies in generating an encrypted private key. Besides the one mentioned earlier above, one could also just take a pre-generated unencrypted private key and run it through the BIP38 algorithm, with a passphrase of your choice, to generate the encrypted private key. BIP39 starts out with a randomized entropy of a certain number of bits to be converted into a mnemonic word seed. These words are actually then further used to create a binary seed for HD wallet purposes (we won’t be covering this part).

Private Key Format

BIP38 encrypted private keys are formatted as 58 characters base58 format (starting with ‘6P’) and a random secret passphrase. BIP39 uses 24 mnemonic words (based on a 256 bit key size).

Passphrase

In the BIP38 standard, a passphrase is necessary to be used in conjunction with the encrypted private key. In BIP39, a passphrase is not necessary but the BIP39 standard actually allows for a way of passphrase-protecting a mnemonic word seed phrase. Then both the seed phrase and extra word are required to recover the wallet. Some wallets call the passphrase a “seed extension”, “extension word” or “13th/25th word”.

Possible formatted combinations

For the BIP39 standard, the mnemonic word seed phrase is limited to 2048 words. Let’s say for example we use the longest length of 24 words, that gives us about 2048²⁴ combinations, which is more than one can pathom. But with BIP38, the passphrase factor can essentially be of anything, which then makes the possible formatted combinations theoretically limitless!

Conclusion

So there you have it. Two BIPs. Two methodologies in keeping your raw private keys obfuscated to the less informed. Two different standards in today’s myriad number of bitcoin wallets. One goal of keeping your bitcoins more secure in a world of heightened cybersecurity.

We hope after reading this you are now more well informed of both standards and its processes. Furthermore, the goal is not to merely praise one’s security over the other but rather to fairly showcase both are fairly secured and both can actually be used together as evident in the image above. And in general, both are merely just taking an arbitrary number of bits and reshuffling its format for wallet capability purposes. At the end of the day, what you do with either the BIP38 encrypted private key or the BIP39 24 mnemonic word seed phrase is dependent on how well you keep them secure. We just prefer having you keep them offline on a physical, air-gapped, robust metal material for added protection.

About us

Ballet is a U.S. company that provides simple and secure cryptocurrency storage solutions for the global mainstream market. Ballet is the team behind the world’s first multi-currency, non-electronic, physical crypto wallet. The company was founded in 2019 by Bobby Lee and an international team of cryptocurrency industry veterans. Ballet is headquartered in Las Vegas, Nevada in the United States, and has an office in Shanghai, China.

For more on our products please check us out at: https://www.ballet.com/

Interact with us on our other social media platforms:

Twitter: https://twitter.com/BalletCrypto/

Facebook: https://www.facebook.com/balletcrypto.global/

Instagram: https://www.instagram.com/balletcrypto/

Telegram: https://t.me/BalletCrypto/

Reddit: https://www.reddit.com/r/BalletCrypto/

LinkedIn: https://www.linkedin.com/company/balletcrypto/

Youtube: https://www.youtube.com/channel/UCi2y_uFMqgdst7xe7FolG3w/

Weibo: https://www.weibo.com/BalletCrypto?from=myfollow_all/

Discord: https://discord.gg/e58FqyDA

Anchor: https://anchor.fm/ballet-crypto


Let’s take if offline: BIP38 vs BIP39 was originally published in BalletCrypto on Medium, where people are continuing the conversation by highlighting and responding to this story.

【免责声明】市场有风险,投资需谨慎。本文不构成投资建议,用户应考虑本文中的任何意见、观点或结论是否符合其特定状况。据此投资,责任自负。

相关Wiki
Ballet
数据请求中
查看更多

推荐专栏

数据请求中
在 App 打开