Leading Zeroes: The '1' Prefix
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.
-
Example:
00 01has a numerical value of1. -
If we just perform the division math, we would only get the character for
1. -
The Result: We would lose the information that the address was supposed to have a leading zero byte.
2. The Satoshi Solution
To fix this, Satoshi added a "Padding" rule:
"For every leading byte of
0x00in 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 a1to 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 two1s (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 0x001Mainnet P2PKH 0x053Mainnet P2SH 0x805Private Key (WIF) In the final section, we will build a Python Base58 Auditor.
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: