How EIP-55 Checksum Works Under the Hood
EIP-55 checksum encoding is elegant in its simplicity. It uses the Keccak-256 hash of the lowercase address to determine which hexadecimal letters should be capitalized. This creates a self-validating pattern that can detect errors without adding any extra data to the address itself.
The process begins by taking the 40-character hexadecimal portion of the address (excluding the 0x prefix) and converting it entirely to lowercase. This normalized form is then hashed using Keccak-256, the same hash function used throughout Ethereum. The resulting 32-byte hash is interpreted as a series of bits that dictate capitalization.
The Algorithm Step by Step
For each character in the original address, the corresponding nibble (4 bits) from the hash is examined. If the nibble value is 8 or greater, the character is capitalized; otherwise, it remains lowercase. This rule applies only to letters a through f; digits remain unchanged.
Verification Process
- Normalize the input address to lowercase
- Compute the Keccak-256 hash of the normalized address
- Use hash nibbles to determine expected capitalization
- Compare expected pattern with the input casing
Why Keccak-256?
Keccak-256 provides strong distribution properties, ensuring that small changes in the address produce dramatically different capitalization patterns. This makes it highly effective at catching random typos.
The beauty of EIP-55 lies in its compatibility. Any valid checksummed address, when lowercased, remains a perfectly valid Ethereum address. Tools can choose to display the checksummed version for safety while still using the canonical lowercase form internally.
FAQ
Is the checksum deterministic?
Yes, the same address always produces the same capitalization pattern.
Does capitalization affect the actual address?
No, Ethereum treats all casing as identical; the pattern is purely for error detection.
Can I implement this myself?
Absolutely—libraries like ethers.js provide built-in functions for checksum encoding and validation.
The elegance of EIP-55 demonstrates how a small cryptographic touch can greatly improve usability and safety.