~/notes / reading on-chain data
Hash Functions and Why They Matter
One operation underlies addresses, block linking, proofs and mining. Four properties explain what it is used for.
A hash function takes input of any length and produces output of fixed length. Almost everything in a blockchain rests on four properties of that operation.
The properties
Deterministic. The same input always produces the same output. Without this nothing could be verified.
Fast to compute. Hashing is cheap, which is why it can be used everywhere.
Preimage resistant. Given an output, finding an input that produces it is infeasible. This is what makes a hash usable as a commitment.
Collision resistant. Finding two inputs with the same output is infeasible.
Avalanche effect. Changing one bit of input changes roughly half the output bits, unpredictably. This is why a hash works as a fingerprint.
Where each property is used
Block linking. Each block contains a hash of the previous one. Changing an old block changes its hash, which breaks the reference in the next block, and so on. Relies on collision resistance and the avalanche effect.
Merkle trees. Proving an item belongs to a set without the whole set. Relies on collision resistance.
Addresses. Derived from public keys by hashing. Relies on preimage resistance, and it also shortens the representation.
Proof of work. Finding an input whose hash meets a target. Relies on there being no shortcut, which follows from preimage resistance.
Transaction identifiers. A hash of the transaction data, used as its unique identifier.
Commitments. Publishing a hash now and revealing the input later proves you knew it without revealing it at the time.
What breaks if a hash function is broken
Everything above, in different ways.
A collision attack would allow substituting one block for another with the same hash, undermining the chain structure.
A preimage attack would undermine addresses and commitments.
Historically, hash functions have been broken gradually rather than suddenly, with theoretical weaknesses appearing long before practical attacks. That gives time to migrate, and migrating a live chain is a substantial coordination problem.
The functions in use
Bitcoin uses SHA-256. Ethereum uses Keccak. Both are considered sound and both have been analysed extensively.
Quantum computing is frequently raised in this context. The more urgent quantum concern is for signature schemes rather than hash functions, since hashes are affected less severely by known quantum algorithms.
The practical relevance
For a user, none directly. The reason to understand it is interpretive: when you read that a chain is tamper-evident, this is the mechanism, and it is a property of arithmetic rather than of a promise.
That distinction is the whole reason these systems are interesting, and it is worth understanding well enough to know what it does and does not guarantee.
# Corrections and technical nitpicks are welcome. Send them over. They get published with the fix.