TeachMeBitcoin

Leading Zeroes: The '1' Prefix

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Leading Zeroes: The '1' Prefix

In standard mathematics, leading zeroes don't change the value of a number (e.g., 007 is the same as 7). However, in Bitcoin, every byte matters. To ensure that an address doesn't "Lose" information during conversion, Base58 has a special rule for Leading Zero Bytes.

1. The Value Problem

If your Public Key Hash starts with a byte of 0x00, the numerical value of the whole string doesn't reflect that zero.

2. The Satoshi Solution

To fix this, Satoshi added a "Padding" rule:

"For every leading byte of 0x00 in the raw data, add the first character of the alphabet (1) to the front of the encoded string."

3. Why Bitcoin Addresses start with '1'

This is the reason almost all legacy Bitcoin addresses start with the number 1.

  • Legacy P2PKH: Uses a version byte of 0x00.

  • Because the very first byte is 0x00, the Base58 encoder adds a 1 to the front of every single address.

4. Double Zeroes

If a hash happens to start with two zero bytes (0x00 00), the address will start with two 1s (e.g., 11vBMSEY...).

  • This preserved the 1:1 mapping between the raw bytes and the encoded string.

  • It ensures that no matter how many zeroes are at the front, the address can always be decoded back to the exact same byte sequence.

Raw Prefix Base58 Prefix Meaning
0x00 1 Mainnet P2PKH
0x05 3 Mainnet P2SH
0x80 5 Private Key (WIF)

In the final section, we will build a Python Base58 Auditor.

☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!