Web3 Learning

What Is Base58Check Encoding?

By Safeheron Team

Base58Check is the encoding Bitcoin uses to turn binary data into strings that people can read and write. It is used for addresses starting with 1 and 3, WIF private keys and xpub extended public keys. It has three parts: a version byte that indicates the data type, the data itself, and a 4-byte checksum, all encoded with a 58-character alphabet. The checksum makes it almost impossible for a mistyped string to be accepted as a valid address.

Why Does It Use Only 58 Characters?

Base58 takes the digits and upper- and lowercase letters and removes 0, uppercase O, uppercase I and lowercase l, because they are hard to tell apart in many fonts. Unlike Base64, it also avoids symbols such as + and /, so an address can be selected in full with a double-click and won’t be cut off in URLs or emails.

How Is the Checksum Calculated?

The version byte and the data are joined together and hashed twice with SHA-256. The first 4 bytes of the result are appended to the end, and the whole byte string is treated as one large integer and converted to base 58. For each leading byte with a value of 0, a 1 character is added to the front of the result.

When a wallet receives an address, it reverses the process to decode it, recalculates the checksum and compares the two. A randomly mistyped string has only about a 1 in 4.3 billion chance of passing the check, so an address with a typo is rejected outright. However, the checksum can only detect an error; it cannot point to which character is wrong.

How Does the Version Byte Determine the First Character?

Because the version byte comes first, it determines how the encoded result begins. Mainnet legacy addresses use 0x00 and start with 1; P2SH addresses use 0x05 and start with 3; WIF private keys use 0x80 and start with 5, K or L. Testnet uses a different set of version bytes: legacy addresses start with m or n, and P2SH addresses start with 2. Extended public keys use a 4-byte version number, so the encoded result starts with xpub.

This lets both people and systems identify the data type at a glance. When an enterprise withdrawal system validates an address, it should check the version byte after decoding rather than looking only at the first character.

What Is the Difference Between Base58Check and Bech32?

SegWit and Taproot addresses use Bech32 and its improved version, Bech32m, instead. Bech32 uses only lowercase letters and digits, which makes it easier to read, write and turn into QR codes. Its checksum is designed specifically for error correction: it is guaranteed to detect a small number of character errors and can also show where they are. Decoding needs no big-integer arithmetic either, so it is simpler to implement.

Base58Check has not been phased out. Addresses starting with 1 and 3 are still valid, and WIF private keys and xpubs continue to use it.

Conclusion

Base58Check marks the data type with a version byte, stops input errors with a checksum, and makes manual reading and writing easier with an alphabet that leaves out easily confused characters. It can ensure an address has no typos, but not that the address belongs to the right party. Safeheron’s MPC Wallet-as-a-Service provides businesses with MPC key management and a policy engine.

Want every withdrawal to pass address and policy checks before it is signed?

Contact Safeheron’s Sales Team to Book a 1:1 Demo

Share

Looking for a secure way to manage digital assets?

Talk to our experts and find the right solution for your business.

Request a Demo