CAIN-42 CAIN Studio
CAIN-42 Academy

CEFV · Module 1 of 5 · 12 min

Hash chains in practice

Each record's hash covers its content plus the previous hash: H_k = SHA-256(H_(k−1) ‖ record_k). Edit any record and its hash changes, so every later link breaks.

To localise tampering, recompute each record against the recorded previous hash: the first mismatch is the edited record.

Pin the head hash somewhere the attacker cannot reach (a quorum receipt, a transparency log) so the whole chain cannot simply be rewritten.

Key points

  • H_k = SHA-256(H_(k−1) ‖ record_k).
  • First mismatch = edited record.
  • Pin the head outside the attacker's reach.

In the CAIN-42 codebase

  • keystone/family.py — shared append/verify spine

Practice check

Practice 1 · choose one

To find which record was edited you…

Practice 2 · true or false

“A chain whose head is not pinned anywhere can be rewritten entirely by an attacker.”