liveBook · Manning

Hash chain

As explained in Hacking Cryptography

A hash chain is a sequence formed by alternately applying a hash function and a deterministic reduction function to messages and digests.

A hash chain is a space–time trade-off for precomputed dictionary attacks. Starting with a candidate password, it alternates a hash function with a deterministic reduction function: password → digest → possible password → digest. Rather than storing every password–digest pair, a table can retain a chain’s start and endpoint. section 6.4.2 section 6.5

Figure 6.10 Hash chains alternatively apply a hash function and a reduction Function.
figure

The alternating steps matter: hashing produces a digest, while reduction maps that digest back into the allowed password space so another step can follow. section 6.4.2

A reduction function is not a hash-function inverse. It deterministically selects a valid candidate from a digest—for example, by using digest bytes to choose characters from a fixed six-character alphabet. Many digests can map to the same candidate, so reduction preserves neither the original password nor all digest information. section 6.4.2

To build and use a chain table:

  • Choose the password length and character set, then define a deterministic reduction function compatible with that candidate space. section 6.4.2
  • Generate a starting password and repeatedly hash it and reduce the resulting digest for a fixed chain length. section 6.4.2
  • Store the starting password keyed by the final digest, instead of storing every intermediate guess and digest. section 6.4.2
  • For a target digest, simulate possible remaining chain positions to find an endpoint; if an endpoint matches, rerun that chain from its start and verify whether it reaches the target. section 6.4.2

Six-character SHA-256 chain

Beginning with abcdef, hash it with SHA-256, reduce the digest to ilWrlG, hash again, and reduce again to kdhkjA. Repeating the same deterministic operations makes the chain reproducible from its start, while the endpoint table uses far less space than a full password–digest dictionary. section 6.4.2

Ordinary hash chains can merge when different paths reach the same reduced password; afterward, their remaining steps are identical, reducing coverage. Rainbow tables address this by changing the reduction function by column, which helps prevent chains from merging. Salts invalidate precomputed tables that were generated without the relevant salt. section 6.4.2 section 6.5

How Hacking Cryptography covers it

How deep it goes
Works through reduction, chain generation, endpoint lookup, verification, merging, and rainbow-table improvements in Go.
Examples
Traces a six-character SHA-256 chain and implements a 1,000-column rainbow-table cracker.
What it assumes
Assumes familiarity with hash digests and candidate passwords while explaining reduction functions directly.
What you can do after
Build it from scratch by generating chains, storing endpoints, and verifying candidate password matches.
How it connects
Connects hash functions, dictionary attacks, reduction functions, rainbow tables, and salts.

Also explained in

Compare how 2 books explain hash chain →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Hacking Cryptography. The section links point to the parts of the book it draws on.