Documentation

CslibFrontier.Crypto.Computational.HardCore

Hard-core predicates and one-bit expansion #

A hard-core predicate is efficiently computable from a seed but unpredictable from its image. Security quantifies over uniform PPT predictors and measures absolute bias from one half, so it also rules out reliable anticorrelation. This property alone does not require the image function to be one-way or injective.

The reduction appends a fixed trial bit to the image, runs a distinguisher, and predicts the trial on acceptance or its complement on rejection. The distinguishing gap is the average of the signed biases of the two fixed predictors. Both are single uniform programs, with no choice depending on the security parameter. Pr[p] is the probability, in the reals, that the program p returns true (the scoped notation of Cslib.Probability).

Appending a hard-core predicate to an efficient length-preserving permutation gives a one-bit PRG in the existing finite-family security API. This is conditional on the hard-core predicate; the Goldreich–Levin construction is a separate step in the OWP-to-PRG reduction.

Main definitions #

Main results #

References #

Adapted from Crypto/Computational/HardCore.lean on the cslib crypto branch at 5ff69ca93402e7c947208dc56396d6d86203ccd8, using the shared nonnegative game API and tidy machines.

noncomputable def Cslib.Crypto.predictionGame (f : List Bool → List Bool) (predicate : List Bool → Bool) (adversary : Distinguisher) (n : ℕ) :

The prediction game at length n: Cslib.Crypto.predictionExperiment for predicate on a uniform n-bit seed, with the predictor told n and the image f seed.

@[reducible, inline]
noncomputable abbrev Cslib.Crypto.predictionAdvantage (f : List Bool → List Bool) (predicate : List Bool → Bool) (adversary : Distinguisher) (n : ℕ) :

Absolute bias above or below the correctness probability of a fair guess.

structure Cslib.Crypto.HardCore (f : List Bool → List Bool) (predicate : List Bool → Bool) :

A plain polynomial-time predicate whose value is computationally hidden by the image function.

This notion is novel to this library. It strengthens [Gol98], Definition 2.5.1, p. 54, whose predictor receives only f x: here the predictor also receives the seed length n in unary, as the inverter of OneWay does, and runs in time polynomial in n + |f x|. When n cannot be computed from f x in polynomial time, that gives the predictor more information and more time than the source does. Security bounds the absolute bias |Pr[correct] - 1/2|; since the admitted predictors are closed under negating their output, this is equivalent to the source's one-sided bound Pr[correct] < 1/2 + 1/p(n).

Relation to standard assumptions. The extra input can only help the predictor, so this notion implies Definition 2.5.1. The two agree when n in unary can be computed from f x in time polynomial in |f x|, for example for length-preserving f, which HardCore.pseudorandomGenerator and OneWayPermutation.pseudorandomGenerator_of_hardCore assume.

Why it is plausible. GoldreichLevin.padded_hardCore derives it from OneWay, for the inner-product predicate of the padded function.

theorem Cslib.Crypto.HardCore.unpredictable {f : List Bool → List Bool} {predicate : List Bool → Bool} (h : HardCore f predicate) (adversary : Distinguisher) (ha : Probability.IsPPT Turing.MultiTapeTM.encBool adversary) :
Negligible (predictionAdvantage f predicate adversary)

The shared security property gives negligible absolute prediction bias.

Establish a hard-core predicate from efficient evaluation and negligible prediction bias.

Use acceptance of an appended trial bit to predict the hidden predicate.

The reduction charges for constructing the extended input and executing the distinguisher.

noncomputable def Cslib.Crypto.hardCoreIdeal (f : List Bool → List Bool) (n : ℕ) :

The ideal hybrid replaces the hidden predicate by an independent fair bit.

theorem Cslib.Crypto.hardCore_gap (f : List Bool → List Bool) (predicate : List Bool → Bool) (adversary : Distinguisher) (n : ℕ) :
((prgRealGame (fun (seed : List Bool) => f seed ++ [predicate seed]) adversary n).eval true).toReal - ↑(distinguishingGame (hardCoreIdeal f n) (adversary n)).succProbability = (((predictionGame f predicate (hardCorePredictor adversary false) n).eval true).toReal + ((predictionGame f predicate (hardCorePredictor adversary true) n).eval true).toReal - 1) / 2

The distinguishing gap is the average signed bias of two fixed uniform predictors.

theorem Cslib.Crypto.hardCore_advantage_le (f : List Bool → List Bool) (predicate : List Bool → Bool) (adversary : Distinguisher) (n : ℕ) :
Game.advantage (prgRealGame (fun (seed : List Bool) => f seed ++ [predicate seed]) adversary n).eval (distinguishingGame (hardCoreIdeal f n) (adversary n)) ≤ (predictionAdvantage f predicate (hardCorePredictor adversary false) n + predictionAdvantage f predicate (hardCorePredictor adversary true) n) / 2

Distinguishing the predicate from a fair bit costs at most the average prediction bias.

theorem Cslib.Crypto.HardCore.indistinguishable {f : List Bool → List Bool} {predicate : List Bool → Bool} (h : HardCore f predicate) :

A hard-core predicate can be replaced by an independent fair bit in every uniform PPT test.

theorem Cslib.Crypto.HardCore.indistinguishable_of_uniform {f : List Bool → List Bool} {predicate : List Bool → Bool} (h : HardCore f predicate) (huniform : ∀ (n : ℕ), PMF.map f (BitString.uniformList n) = BitString.uniformList n) :
ComputationallyIndistinguishable (generatorEnsemble fun (seed : List Bool) => f seed ++ [predicate seed]) fun (n : ℕ) => BitString.uniformList (n + 1)

If the image function preserves uniform seeds, the ideal hybrid is uniform at length n+1.

theorem Cslib.Crypto.HardCore.pseudorandomGenerator {f : List Bool → List Bool} {predicate : List Bool → Bool} (h : HardCore f predicate) (hf : Turing.MultiTapeTM.ComputableInPolyTime f Turing.MultiTapeTM.encBits Turing.MultiTapeTM.encBits) (hlen : ∀ (word : List Bool), (f word).length = word.length) (huniform : ∀ (n : ℕ), PMF.map f (BitString.uniformList n) = BitString.uniformList n) :
PseudorandomGenerator (fun (seed : List Bool) => f seed ++ [predicate seed]) fun (n : ℕ) => n + 1

An efficient length-preserving function that preserves uniform seeds gives a one-bit PRG when extended by a hard-core predicate. The later predicate construction uses one-wayness.

theorem Cslib.Crypto.OneWayPermutation.pseudorandomGenerator_of_hardCore {f : List Bool → List Bool} {predicate : List Bool → Bool} (hf : OneWayPermutation f) (h : HardCore f predicate) :
PseudorandomGenerator (fun (seed : List Bool) => f seed ++ [predicate seed]) fun (n : ℕ) => n + 1

Step of the construction of a generator from a one-way permutation: a one-way permutation with a hard-core predicate gives a uniform polynomial-time one-bit PRG.

In statement this is [Gol98], Theorem 3.4.1, p. 91, and [Gol07c], Proposition 8.9, printed p. 330: if f is a length-preserving one-to-one one-way function and b a hard-core predicate for f, then G(s) = f(s) b(s) is a pseudorandom generator, here PseudorandomGenerator (Definition 3.3.2, p. 85). The hypothesis HardCore is novel to this library: its predictors also receive the seed length in unary. For a length-preserving f it agrees with the source's Definition 2.5.1, p. 54, as HardCore explains, but the library does not prove that, so this is a step and not the cited theorem. As in the source's proof, one-wayness itself is not used: only that f is computable in polynomial time, preserves lengths and permutes the words of each length.