Why is a hash hard to reverse? The preimage problem

Given a digest, finding an input that produces it is a different task from checking an input someone already suggests.

The worked example below shows which of three proposed words matches the target.

Start with the digest

In Lesson 4.1, you started with a message and computed its SHA-256 digest. Here you start with a digest. A preimage is any input that produces that target digest. In the next lesson you’ll look for any matching pair, with no target chosen in advance.

This board is a toy model of guessing and checking. Leaf has the circle mark, Moss has the diamond, and Fern has the square. For a diamond target, Moss is a preimage. You can check Moss in one step if someone proposes it, even if finding a match by turning cards took several checks.

Why the list of candidates matters

Preimage resistance means a strong hash makes it impractical in general to find an input for a given digest. A digest is a fixed-size summary. Different inputs can share it, and it gives no built-in route back to a suitable input. Each proposed input is still easy to check by hashing it and comparing the result. If the true input is known to come from a short list, the small list can make finding a match practical. The hash has not become easier to compute or to reverse. There are simply fewer plausible candidates to consider. See NIST’s overview of hash functions and the Secure Hash Standard.

Check your understanding

You learn that an input is one of three words. Which task got easier, finding a matching word or checking one word you were already given? Why?

Show the answer

Finding gets easier because you can check each of the three plausible candidates. Checking one supplied word still takes one hash and a comparison.