TeachMeBitcoin

Base58Check Math (Double SHA256)

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

Base58Check Math: Double SHA256

The original checksum method used in Bitcoin is Base58Check. It relies on the cryptographic strength of the SHA256 hashing algorithm to create a unique fingerprint for the address data.

1. The "Double Hash" Tradition

Bitcoin almost never uses a single hash. For checksums, it uses SHA256(SHA256(Data)).

2. The Truncation Logic

A SHA256 hash is 32 bytes (256 bits). However, we only use the first 4 bytes as the checksum.

  1. Input: [Version Byte] + [20-byte Hash]

  2. Step 1: Hash the input (SHA256).

  3. Step 2: Hash the result of Step 1 (SHA256).

  4. Step 3: Take the first 4 bytes of that second hash.

  5. Result: These 4 bytes are appended to the input before encoding into Base58.

3. Why only 4 bytes?

If 32 bytes is more secure, why throw 28 bytes away?

4. Verification Flow

When a wallet "Validates" a legacy address:

  1. It decodes the Base58 string into raw bytes.

  2. It separates the last 4 bytes (the "Stored Checksum").

  3. It performs the Double SHA256 on the remaining data.

  4. It compares its "Calculated Checksum" to the "Stored Checksum."

  5. Match: The address is valid. Mismatch: The address is rejected.

Component Bytes Description
Payload 21 Version + Public Key Hash
Checksum 4 The "CheckDigit"
Encoded ~34 Final Base58 String

In the next section, we will look at the more advanced Bech32 Polynomial Math.

☕ 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!