Proofs: Meet-in-the-middle attack
These are the human proofs of Meet-in-the-middle attack, at full length.
The meet-in-the-middle attack returns exactly the consistent key pairs full
This proof shows: correctness, termination.
We use the pseudocode of the page. The keys are and the blocks are . For each key , is a bijection and is its inverse. There are known pairs . The target set is
Claim. MEET-IN-THE-MIDDLE stops after cipher calls, where is the number of pairs with . The list that it returns holds each element of exactly once and holds nothing else.
Step 1 (the table). We show this invariant of the loop of line L2:
(T) Before the iteration with , for each block , the list holds the keys with , each one exactly once, in increasing order.
Initialization. For the set of keys is empty, and line L1 makes each list empty.
Maintenance. The iteration with appends to the list and changes no other list. So the list of the block gains the key , which is larger than each key in it, and the other lists still hold the right keys. This is (T) for .
Termination. The loop stops after . Then (T) with says: for each block , , each key once.
Step 2 (the candidates). Fix and let (line L6). For a key , Step 1 gives: if and only if . Apply the bijection to both sides. Since , and since is one-to-one, this holds if and only if . So the loop of line L7 visits exactly the keys such that is consistent with the first pair, each one once.
Step 3 (the filter). For such a candidate, line L8 appends to if and only if it is also consistent with the pairs . With Step 2, the iteration of line L5 for appends exactly the elements of whose second key is , each one once.
Step 4 (the result). The loop of line L5 takes each once. Different values of append different pairs. So at line L10, holds each element of exactly once and nothing else.
Termination and cost. The loops of lines L2 and L5 have iterations each, with one cipher call each. By Step 2, the loop of line L7 runs times in total. Each run of line L8 makes at most two cipher calls for each of the pairs . Each loop runs over a finite range or a finite list, so the procedure stops, after at most cipher calls.
Order. Line L5 takes in increasing order, and by Step 1 each list is in increasing order. So is sorted by , and by for equal .