How a hash chain shows tampering
A hash chain is a list of records where each record carries the hash of the record before it. Edit one record in the middle and every record after it stops matching.
The short version
A hash function turns data into a digest, and if the data changes, the digest changes. That is why digests are used to detect changes (FIPS 180-4). In a chain, each record stores the previous record's hash next to its own data. Change record 2 and its hash changes, but record 3 still holds the old one, so the mismatch shows.
Step by step
- Hash record 1 to get hash 1.
- Store hash 1 inside record 2, then hash record 2 (its data plus hash 1) to get hash 2. Repeat for every record.
- To check the chain, recompute each hash and compare it with the copy stored in the next record.
- An edited record produces a new hash, so the copy in the next record no longer matches.
Why it matters
Git works like this: it names every object by a hash of its content, and a commit stores the hash of its parent. The Bitcoin white paper chains timestamps the same way, and changing one block would mean redoing the proof-of-work for that block and every block after it. My take: checking is one cheap pass of hashing, but a chain only shows tampering and cannot prevent it, and someone who rewrites every later record can make it look consistent unless you keep the latest hash somewhere you trust.
Sources
- FIPS 180-4, Secure Hash Standard (NIST): hash algorithms produce message digests that are used to detect whether a message has changed since the digest was generated
- Git Internals, Git Objects (Pro Git): objects are named by a SHA-1 hash of their content, so changed content gets a new name, and a commit stores its parent commit's hash
- Bitcoin: A Peer-to-Peer Electronic Cash System: each timestamp includes the previous one in its hash (section 3), and changing a block means redoing the proof-of-work for it and all later blocks (section 4)