Documentation

CslibFrontier.Crypto.Game.Retry

Repeated attempts that succeed through an independent coin #

A simulator that guesses a verifier's challenge succeeds in each attempt only when its guess is right. Its output is that of the honest interaction, μ, on success and nothing otherwise, and whether an attempt succeeds is an independent coin ch : PMF Bool. After k independent attempts, firstSuccess d returns the first successful output, or the fallback d when every attempt failed. Every distinguisher then separates this from μ with advantage at most (ch false) ^ k: the selected output has the law of μ except on the event that all k attempts fail.

The independence is stated by ProbComp.eval attempt = μ.bind (tagWith ch): the attempt's output is drawn from μ and its success coin from ch, independently. For the zero-knowledge simulator of Goldreich–Micali–Wigderson the coin is a uniform 3-bit guess hitting the verifier's challenge, so that ch false = 7 / 8.

This is the rejection-sampling argument of a black-box simulator. The bounded retry loop Cslib.OracleComp.retry runs a program lazily until a result passes a predicate and states the law of the result; here every attempt is run and the bound is on the advantage against μ.

Main definitions #

Main results #

References #

noncomputable def Cslib.Crypto.mixWith {α : Type u_1} (ch : PMF Bool) (p q : PMF α) :
PMF α

Run p when the coin ch shows true, and q when it shows false.

theorem Cslib.Crypto.bind_mixWith {α : Type u_1} {β : Type u_2} (ch : PMF Bool) (p q : PMF α) (f : α → PMF β) :
(mixWith ch p q).bind f = mixWith ch (p.bind f) (q.bind f)
noncomputable def Cslib.Crypto.tagWith {β : Type u_1} (ch : PMF Bool) (out : β) :
PMF (Option β)

Keep the output out when an independent coin ch shows true, and fail otherwise.

def Cslib.Crypto.firstSuccess {β : Type u_1} (d : β) (attempts : List (Option β)) :
β

The first successful attempt in attempts, or d when every attempt failed.

@[simp]
theorem Cslib.Crypto.firstSuccess_nil {β : Type u_1} (d : β) :
@[simp]
theorem Cslib.Crypto.firstSuccess_cons {β : Type u_1} (d : β) (o : Option β) (xs : List (Option β)) :
firstSuccess d (o :: xs) = o.getD (firstSuccess d xs)
theorem Cslib.Crypto.firstSuccess_eq_or_mem {β : Type u_1} (d : β) (xs : List (Option β)) :

The first success is the fallback or one of the successful attempts.

theorem Cslib.Crypto.eval_firstSuccess_replicate_succ {β : Type} (d : β) {attempt : ProbComp (Option β)} {ch : PMF Bool} {μ : PMF β} (hattempt : attempt.eval = μ.bind (tagWith ch)) (k : ℕ) :

One more attempt succeeds with the law of μ when its coin shows true, and otherwise falls back to the first success among the remaining attempts.

theorem Cslib.Crypto.Game.advantage_mixWith (ch : PMF Bool) (g1 g2 : Game) :
advantage (mixWith ch g1 g2) g1 = (ch false).toNNReal * g2.advantage g1

Mixing in g2 with probability ch false scales the advantage against g1 by ch false.

theorem Cslib.Crypto.Game.advantage_bind_firstSuccess_replicate_le {β : Type} (d : β) {attempt : ProbComp (Option β)} {ch : PMF Bool} {μ : PMF β} (hattempt : attempt.eval = μ.bind (tagWith ch)) (f : β → Game) (k : ℕ) :

Repeated attempts. If each attempt has the law of μ on success and succeeds through an independent coin ch, then after k attempts every continuation f separates the first success from μ with advantage at most (ch false) ^ k, the probability that all attempts fail.