Documentation

CslibFrontier.Crypto.Computational.OneWay.LengthPreserving

Length-preserving one-way functions #

If one-way functions exist, then length-preserving one-way functions exist Goldreich, Exercise 7.1: some one-way function f' has |f'(x)| = |x| for every x (Cslib.Crypto.OneWay.exists_lengthPreserving).

The construction follows the guideline of the exercise. Normalize the output length of a one-way function g to L(|x|) (Cslib.Crypto.OneWay.exists_fixedOutputLength), and choose the input-length schedule m(n) = 4 n + 2 L(n) + 3. On an input z, let n be the greatest parameter with m(n) ≤ |z| and evaluate g on the n-bit prefix of z, pairing the image with n (Cslib.Crypto.OneWayReindex.reindex). The result has 2 n + 1 + L(n) bits, so its self-delimiting padding fits into |z| bits (Cslib.Crypto.OneWayLengthPreserving.fit). The guideline pads f(x) by 0 1 ^ (|z| - |f(x)| - 1) and inverts the schedule n ↦ p(n); here the padding is the library's self-delimiting padWord, and the image also records n, so that images of different parameters are disjoint and the reindexing reduction of Cslib.Crypto.OneWayReindex.oneWay applies to any polynomial-time schedule.

Main definitions #

Main results #

References #

Fitting a word into a fixed number of bits #

The first k bits of the self-delimiting padding of word (Cslib.BitString.padWord). A word with 2 |word| + 1 ≤ k can be read back from the result (word_eq_of_fit_eq).

@[simp]

Fitting always produces exactly k bits.

theorem Cslib.Crypto.OneWayLengthPreserving.word_eq_of_fit_eq {k : ℕ} {word word' : List Bool} (hword : 2 * word.length + 1 ≤ k) (hword' : 2 * word'.length + 1 ≤ k) (h : fit k word = fit k word') :
word = word'

Words with 2 |word| + 1 ≤ k are determined by their fitted form.

The construction #

The input-length schedule m(n) = 4 n + 2 L(n) + 3: parameter n reads this many input bits, enough room for the padded image of n and g on n bits.

The parameter-indexed family: g on the n-bit prefix.

The length-preserving function: reindex g along schedule L and fit the result into |x| bits.

From length m(0) on, the reindexed image fits: twice its length plus one is at most the input length.

theorem Cslib.Crypto.OneWayLengthPreserving.inversion_le {g : List Bool → List Bool} {L : ℕ → ℕ} (hg : ∀ (x : List Bool), (g x).length = L x.length) (adversary : Inverter) {M : ℕ} (hM : schedule L 0 ≤ M) :
Game.succProbability (inversionGame (lengthPreserving g L) adversary M).eval ≤ Game.succProbability (inversionGame (OneWayReindex.reindex (schedule L) (core g)) (fun (n : ℕ) (image : List Bool) => adversary n (fit n image)) M).eval

Inversion reduction. At every length M ≥ m(0), an inverter for the length-preserving function inverts the reindexed function at least as well once its challenge is fitted into M bits: a successful candidate has length M, and fitting is injective on the images that occur.

theorem Cslib.Crypto.OneWayLengthPreserving.eval_familyInversionGame_core (g : List Bool → List Bool) (L : ℕ → ℕ) (adversary : Inverter) (n : ℕ) :
(OneWayReindex.familyInversionGame (schedule L) (core g) adversary n).eval = (inversionGame g (fun (n : ℕ) (image : List Bool) => List.take n <$> adversary n image) n).eval

The parameter-indexed game for core g is the inversion game for g against the inverter that truncates its candidate to n bits.

The length-preserving construction is one-way. If g is one-way with output length L(|x|), computable in unary polynomial time, then lengthPreserving g L is one-way.

theorem Cslib.Crypto.OneWay.exists_lengthPreserving {f : List Bool → List Bool} (hf : OneWay f) :
∃ (f' : List Bool → List Bool), OneWay f' ∧ ∀ (x : List Bool), (f' x).length = x.length

Goldreich, Exercise 7.1: if one-way functions exist, then length-preserving one-way functions exist. From any one-way function f we obtain a one-way function f' with |f'(x)| = |x| for every x. One-wayness is Cslib.Crypto.OneWay: polynomial time evaluation, and negligible inversion probability against uniform strict PPT inverters.