Documentation

CslibFrontier.Crypto.Computational.SecondPreimageResistant.Relations

Implications and separations for second-preimage resistance #

This module formalizes the hierarchy $$\text{collision resistance} \implies \text{second-preimage resistance} \implies \text{one-wayness}$$ of [BS23], Section 8.11.1, equation (8.17), p. 337, together with Exercise 8.23(b)–(d), p. 353, and the two strict-separation constructions on bit strings:

Main definitions #

Main results #

References #

Second-preimage resistance implies one-wayness under super-polynomial compression #

Wrap an inverter adversary into a second-preimage finder by feeding it f m ([BS23], Exercise 8.23(b), p. 353).

theorem Cslib.Crypto.succProbability_inversionGameOn_le_secondPreimageGameOn_add {f : List Bool → List Bool} {valid : ℕ → List Bool → Bool} {n d : ℕ} (hlen : ∀ (w : List Bool), w.length = n → (f w).length = d) (adversary : Inverter) :

Reduction from second-preimage search to inversion on a domain: when f maps n-bit inputs to d-bit digests, an inverter adversary at length n succeeds within valid with probability at most SPRadvOn[B, f] + 2 ^ d / 2 ^ n, for the finder B that asks adversary to invert f m. A winning answer x' is either a second preimage of the challenge m, which is a win for B on the same domain, or m itself, which adversary guesses from f m with probability at most 2 ^ d / 2 ^ n. This is the factor-one form of [BS23], Exercise 8.23(b), (8.22), p. 353, whose generic form is succProbability_inversionExperiment_uniform_le_add_card_div.

theorem Cslib.Crypto.SecondPreimageResistantOn.oneWayOn_of_outputLength {f : List Bool → List Bool} {valid : ℕ → List Bool → Bool} {outLen : ℕ → ℕ} (hf : SecondPreimageResistantOn f valid) (hlen : ∀ (n : ℕ) (w : List Bool), w.length = n → (f w).length = outLen n) (hcomp : Negligible fun (n : ℕ) => 2 ^ outLen n / 2 ^ n) :
OneWayOn f valid

Equation (8.17), second implication, and Exercise 8.23(b) ([BS23], pp. 337, 353): a function that is second-preimage resistant on valid (Definition 8.6, p. 336), whose n-bit inputs have outLen n-bit digests with 2 ^ outLen n / 2 ^ n negligible (a super-polynomial compression factor s(n) = 2 ^ n / 2 ^ outLen n), is one-way on valid (Definition 8.6). With valid n w = decide (w.length = n) both are Definition 8.6 on M = {0,1}ⁿ and T = {0,1}^(outLen n).

Collision resistance implies second-preimage resistance (Exercise 8.23(d) and (8.17)) #

Turn a second-preimage finder for CollisionResistantToOneWay.keyDigest H at input length 3 * n + r into a CollisionFinder for H at security parameter n by sampling a random (2 * n + r)-bit message x and pairing x with the message part of the finder's answer.

Sampling a (2 * n + r)-bit message, running adversary (3 * n + r), and slicing the answer is uniformly strict PPT.

theorem Cslib.Crypto.isCollision_of_keyDigest_secondPreimage {H : List Bool → List Bool → List Bool} (hlen : ∀ (key message : List Bool), (H key message).length = key.length) (n : ℕ) {candidate key message : List Bool} {r : ℕ} (hmessage : message.length = 2 * key.length + r) (hr : r < 3) (hne : candidate ≠ key ++ message) (h : CollisionResistantToOneWay.keyDigest H candidate = CollisionResistantToOneWay.keyDigest H (key ++ message)) :
isCollision H (fun (x : ℕ) (x_1 : List Bool) => true) n key message (List.drop (candidate.length / 3) candidate) = true

A second preimage candidate ≠ key ++ message of key ++ message under keyDigest H has the same key key and a colliding message part candidate.drop (candidate.length / 3) ≠ message.

theorem Cslib.Crypto.succProbability_secondPreimageGame_keyDigest_le {H : List Bool → List Bool → List Bool} (hlen : ∀ (key message : List Bool), (H key message).length = key.length) (adversary : SecondPreimageFinder) (n r : ℕ) (hr : r < 3) :

Exercise 8.23(d), concrete bound for keyDigest H: finding a second preimage of keyDigest H at length 3 * n + r with r < 3 succeeds at most as often as secondPreimageToCollisionFinder adversary r finds a collision for H at parameter n, with no guessing loss.

Equation (8.17), first implication, and Exercise 8.23(d) ([BS23], pp. 337, 353): for a keyed collision-resistant hash family H with (H key message).length = key.length, CollisionResistantToOneWay.keyDigest H replaces the book's unkeyed H and is second-preimage resistant (and hence also SecondPreimageResistantOn (keyDigest H) valid for any valid via SecondPreimageResistantOn.mono).

Separations: one-way does not imply second-preimage resistant, and Exercise 8.23(c) #

Drop the first bit before applying f: the bit-string form of h'(m, b) := h(m) from [BS23], Section 8.11.1, p. 337.

Section 8.11.1 separation, negative half ([BS23], p. 337) for SecondPreimageResistantOn: for every f and every validity predicate valid admitting flipHeadBit on sufficiently large n-bit inputs (including fun n w => decide (w.length = n)), ignoreHeadBit f is not second-preimage resistant on valid.

Inverter for f at length n built from an inverter for ignoreHeadBit f at length n + 1: run adversary (n + 1) and take the tail of its candidate preimage.

theorem Cslib.Crypto.succProbability_inversionGameOn_ignoreHeadBit_succ_le (f : List Bool → List Bool) {valid : ℕ → List Bool → Bool} {n : ℕ} (hvalid : ∀ (w : List Bool), valid (n + 1) w = true → valid n w.tail = true) (adversary : Inverter) :

Inverting ignoreHeadBit f within valid at length n + 1 succeeds at most as often as ignoreHeadBitInverter adversary inverts f within valid at length n, when dropping the head of a valid answer at length n + 1 leaves a valid answer at length n.

theorem Cslib.Crypto.OneWayOn.ignoreHeadBit {f : List Bool → List Bool} {valid : ℕ → List Bool → Bool} (hf : OneWayOn f valid) (hvalid : ∀ (n : ℕ) (w : List Bool), valid (n + 1) w = true → valid n w.tail = true) :

Section 8.11.1 separation, positive half ([BS23], p. 337): if f is one-way on valid (Definition 8.6, p. 336), then ignoreHeadBit f, the bit-string form of h'(m, b) := h(m), is one-way on valid, provided that dropping the head of a valid answer at length n + 1 leaves a valid answer at length n. With valid n w = decide (w.length = n), ignoreHeadBit f at length n + 1 is h' on {0,1} × {0,1}ⁿ for h = f on {0,1}ⁿ. It fails second-preimage resistance by not_secondPreimageResistantOn_ignoreHeadBit.

The bit-string form of Exercise 8.23(c) ([BS23], p. 353): when the first k bits of w are all false (probability 1 / 2 ^ k at length n ≥ k, so 1 / (2 * s) with 2 * s = 2 ^ k), output true :: w.drop k; otherwise output false :: H w.

Output length of plantEasyBranch k H w: when the first k bits of w are false, it has length w.length - k + 1; otherwise (H w).length + 1. Thus if H compresses n-bit inputs by k bits for n ≥ k, plantEasyBranch k H compresses n-bit inputs by k - 1 bits.

theorem Cslib.Crypto.eq_of_plantEasyBranch_eq (k : ℕ) (H : List Bool → List Bool) {w w' : List Bool} (hne : w' ≠ w) (heq : plantEasyBranch k H w' = plantEasyBranch k H w) :
H w' = H w

Every second preimage under plantEasyBranch k H is a second preimage under H: any word whose first k bits are false is uniquely determined by plantEasyBranch k H w.

For every second-preimage finder adversary, its valid-domain success probability against plantEasyBranch k H is at most its valid-domain success probability against H.

Exercise 8.23(c) on bit strings, positive half ([BS23], p. 353): if H is second-preimage resistant on valid, then plantEasyBranch k H is also second-preimage resistant on valid (and in particular SecondPreimageResistant when H is).

Inverter for plantEasyBranch k H: prepend k false bits to the tail of the digest.

theorem Cslib.Crypto.not_oneWayOn_plantEasyBranch (k : ℕ) (H : List Bool → List Bool) {valid : ℕ → List Bool → Bool} (hvalid : ∀ (n : ℕ) (x : List Bool), x.length = n → valid n x = true) :

Exercise 8.23(c) on bit strings, negative half ([BS23], p. 353): for every k and H, plantEasyBranch k H is not one-way (Definition 8.6, p. 336) on any domain valid that contains the n-bit words: at length n ≥ k, plantEasyBranchInverter k returns the sampled n-bit input with probability at least (1 / 2) ^ k.