Documentation

CslibFrontier.Crypto.Computational.OneWay

One-way functions and permutations #

A polynomial-time function on binary words is one-way when, given its value on a uniform n-bit input and the unary parameter n, every uniform PPT inverter has negligible probability of finding any preimage. Recovering the sampled input is not required, and the inverter's answer is not restricted to the sampled input's length.

OneWayPermutation additionally requires a length-preserving bijection. Its inverse exists as a mathematical function; no efficiency of that inverse is assumed. Such a permutation preserves the uniform distribution at every input length. These are definitions, not assertions that one-way functions or permutations exist.

OneWayOn f valid is one-wayness on a declared domain, as in [BS23], Definition 8.6, where the inverter must output a preimage in the message space: an answer x' wins only when valid n x'. With valid n w = decide (w.length = n) it is Definition 8.6 on M = {0,1}ⁿ. OneWay is the case valid := fun _ _ => true (oneWayOn_true_iff), so it implies OneWayOn on every domain (OneWay.oneWayOn); for an injective function the two agree (OneWayOn.oneWay_of_injective).

Main definitions #

Main results #

References #

Adapted from Crypto/Computational/OneWay.lean on the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8, using finite fair-bit programs, tidy deterministic certificates and the upstream nonnegative game API.

@[reducible, inline]

An inverter receives the unary parameter and the image of the sampled input.

noncomputable def Cslib.Crypto.inversionGame (f : List Bool → List Bool) (adversary : Inverter) (n : ℕ) :

The inversion game at length n: Cslib.Crypto.inversionExperiment for f on a uniform n-bit input, with the inverter told n. Any preimage of the challenge is accepted.

The inversion experiment is uniformly PPT, independently of the unused auxiliary input.

structure Cslib.Crypto.OneWay (f : List Bool → List Bool) :

One plain polynomial-time algorithm evaluates the function. Every uniform strict PPT inverter has negligible success over the uniform input and its own independent random coins.

This is strong one-wayness, [Gol98], Definition 2.2.1, p. 29: the inverter receives f x for a uniform n-bit x together with n in unary, and succeeds when it outputs any preimage of f x, of any length.

The shared game definition gives the usual negligible inversion probability.

Establish one-wayness by bounding every efficient inverter's success probability.

A length-preserving permutation that is one-way against every uniform PPT inverter: a length-preserving one-to-one function that is OneWay, which is how [Gol98], Section 3.4.1, p. 91, describes one-way permutations. Being one-to-one and length-preserving, such a function permutes the words of each length, so bijective adds nothing to injectivity.

  • oneWay : OneWay f

    Evaluation is polynomial time, and inversion has negligible success.

  • length_eq (word : List Bool) : (f word).length = word.length

    The permutation acts separately on words of each length.

  • bijective : Function.Bijective f

    Every word has exactly one preimage; finding it need not be efficient.

A one-way permutation preserves the uniform distribution at each input length.

A permuted uniform seed followed by an independent fair bit is exactly uniform at the expanded length. Security is needed when replacing the independent bit by a hard-core predicate.

theorem Cslib.Crypto.inversionGame_eq_of_injective (f : List Bool → List Bool) (hf : Function.Injective f) (adversary : Inverter) (n : ℕ) :
inversionGame f adversary n = do let input ← BitString.sampleList n let candidate ← adversary n (f input) pure (candidate == input)

For an injective function, accepting any preimage is equivalent to recovering the sampled input. The general inversion experiment does not make this assumption.

theorem Cslib.Crypto.eval_inversionGame_of_rightInverse (f : List Bool → List Bool) (inverse : ℕ → List Bool → List Bool) (h : ∀ (x : List Bool), f (inverse x.length (f x)) = f x) (n : ℕ) :
(inversionGame f (fun (n : ℕ) (y : List Bool) => pure (inverse n y)) n).eval = PMF.pure true

An inverter that, told the input length, always returns a preimage makes the experiment always succeed.

theorem Cslib.Crypto.not_oneWay_of_le_succProbability {f : List Bool → List Bool} {c : NNReal} (hc : c ≠ 0) (inverter : Inverter) (hPPT : Probability.IsPPT Turing.MultiTapeTM.encBits inverter) (h : ∀ (n : ℕ), c ≤ Game.succProbability (inversionGame f inverter n).eval) :

Inverting with probability bounded away from zero refutes one-wayness: an efficient inverter whose success probability is at least a fixed c > 0 at every length.

theorem Cslib.Crypto.not_oneWay_of_inverse (f : List Bool → List Bool) (inverse : ℕ → List Bool → List Bool) (hPPT : Probability.IsPPT Turing.MultiTapeTM.encBits fun (n : ℕ) (y : List Bool) => pure (inverse n y)) (hinv : ∀ (x : List Bool), f (inverse x.length (f x)) = f x) :

Efficiently finding any preimage, told the input length, contradicts one-wayness.

theorem Cslib.Crypto.not_oneWay_const (word : List Bool) :
¬OneWay fun (x : List Bool) => word

Constant functions are not one-way: the empty word is always a preimage.

One-wayness on a declared domain #

noncomputable def Cslib.Crypto.inversionGameOn (f : List Bool → List Bool) (valid : ℕ → List Bool → Bool) (adversary : Inverter) (n : ℕ) :

The inversion game on a declared domain at length n ([BS23], Section 8.11.1, Definition 8.6, p. 336): draw x ← BitString.sampleList n, give the inverter n and f x, and accept its answer x' when valid n x' and f x' = f x. With valid n w = decide (w.length = n) this is the one-wayness game of Definition 8.6 on M = {0,1}ⁿ.

structure Cslib.Crypto.OneWayOn (f : List Bool → List Bool) (valid : ℕ → List Bool → Bool) :

One plain polynomial-time algorithm evaluates the function, and every uniform strict PPT inverter has negligible success in inversionGameOn f valid over the uniform n-bit input and its own independent random coins.

This is one-wayness as [BS23], Section 8.11.1, Definition 8.6, p. 336, defines it: the challenger sends t := H(m) for a random m ∈ M, and the adversary wins by outputting m' ∈ M with H(m') = t. The inverter also receives n in unary. With valid n w = decide (w.length = n) this is Definition 8.6 on M = {0,1}ⁿ; a wider valid accepts more answers and gives a stronger assumption. OneWay, after Goldreich, accepts a preimage of any length: it is OneWayOn f (fun _ _ => true) (oneWayOn_true_iff).

theorem Cslib.Crypto.OneWayOn.negligible {f : List Bool → List Bool} {valid : ℕ → List Bool → Bool} (h : OneWayOn f valid) (adversary : Inverter) (hPPT : Probability.IsPPT Turing.MultiTapeTM.encBits adversary) :
Negligible fun (n : ℕ) => Game.succProbability (inversionGameOn f valid adversary n).eval

One-wayness on valid gives every uniform strict PPT inverter negligible success in inversionGameOn f valid.

Establish one-wayness on valid by bounding every efficient inverter's success probability.

theorem Cslib.Crypto.oneWayOn_true_iff {f : List Bool → List Bool} :
(OneWayOn f fun (x : ℕ) (x_1 : List Bool) => true) ↔ OneWay f

OneWay is one-wayness on the domain that accepts every answer.

theorem Cslib.Crypto.succProbability_inversionGameOn_le_of_imp {f : List Bool → List Bool} {valid₁ valid₂ : ℕ → List Bool → Bool} {n : ℕ} (h : ∀ (x x' : List Bool), x.length = n → valid₁ n x' = true → f x' = f x → valid₂ n x' = true) (adversary : Inverter) :
Game.succProbability (inversionGameOn f valid₁ adversary n).eval ≤ Game.succProbability (inversionGameOn f valid₂ adversary n).eval

Compare two domain games for the same inverter when every answer that wins the first, a preimage of an n-bit input, is also accepted by the second domain.

theorem Cslib.Crypto.OneWayOn.mono {f : List Bool → List Bool} {valid₁ valid₂ : ℕ → List Bool → Bool} (h : OneWayOn f valid₁) (hle : ∀ (n : ℕ) (w : List Bool), valid₂ n w = true → valid₁ n w = true) :
OneWayOn f valid₂

Shrinking the domain preserves one-wayness.

theorem Cslib.Crypto.OneWay.oneWayOn {f : List Bool → List Bool} (h : OneWay f) {valid : ℕ → List Bool → Bool} :
OneWayOn f valid

A OneWay function is one-way on every domain.

theorem Cslib.Crypto.OneWayOn.oneWay_of_injective {f : List Bool → List Bool} {valid : ℕ → List Bool → Bool} (h : OneWayOn f valid) (hinj : Function.Injective f) (hvalid : ∀ (n : ℕ) (x : List Bool), x.length = n → valid n x = true) :

For an injective function the only preimage of f x is x, so one-wayness on a domain that contains every n-bit word is OneWay.