Ethereum: How does the bip32 version bytes convert to base58?
Mystery of BIP32 Bytes version
As a Blockchain developer, you are probably familiar with the BIP32 coding scheme used to represent the Ethereum addresses. However, you ever asked how these version bytes are converted (x04 \ x88 \ xad \ xe4) from the base256 to the base58? In this article, we will deepen in the BIP32 world and explore the conversion process.
BIP32 coding scheme
Before we dive into the conversion process, let us review the BIP32 coding scheme. The scheme consists of two components:
- XPRV : represents the private key
- MKEY : represents the public key
Xprv and Mkey are concatenated to form a single string of bytes, which is then coded in Base256.
Converting byte version
Now, let’s convert the bytes x04 \ x88 \ xad \ xe4 from Base256 to Base58. The conversion process involves several steps:
- Decoding
: Take the base of the bases of the version (x04 \ x88 \ xad \ xe4) and decode it in a range of bytes.
- Division : Divide the bytes string decoded into two parts: the prefix (
x) and the rest (04 \ x88 \ xad \ xe4).
- Conversion Base58 : Convert each part of the byte string to the base58 using the following rules:
x: represents the hexadecimal prefix
02 ...: represents a short value in the base58 (for example, 1000 ->irr)
...: represents a long value in the base58 (for example,x->1kz713tzjju)
Conversion process
Let’s apply these rules to examples version bytes:
x04 \ x88 \ xad \ xe4
- Decoding : The decoded byte string is: 0000 02 880a ad e4
- Division : Divide the byte string into two parts:
* Prefix (X): 0000 02
* Rest: 880a ad e4
- Basic conversion58 :
X: it represents the hexadecimal prefix, so we must convert it into the base58 using the above rules.
+ 0x00:1
+ 0x02:irr
- Rest : represents a long value in the base58. We will convert this too.
The rest of the conversion process involves the transformation of each hexadecimal digit into its corresponding basic character, followed by any zero leader.
Conclusion
In conclusion, version bytes (x04 \ x88 \ xad \ xe4) represents XPRV and MKEY in the BIP32 coding scheme. The conversion of these Base256 to Base58 version bytes requires a series of steps that involve decoding, dividing and applying the Base58 conversion rules. By understanding how this process works, you will become more skilled in converting and collaborating with BIP32 addresses on Ethereum.
I hope this explanation will help clarify the process! Do you have any specific questions or examples you want to approach?