Documentation

CslibFrontier.Crypto.Computational.Encryption.Roulette

Security against guessing Internet roulette outcomes #

Semantic security gives security for single-zero Internet roulette (Fin 37, outcomes 0..36) ([BS23], Section 2.2.4, pp. 22–25). The book defines four even-money bets (high, low, even, odd, p. 22); RouletteBet includes those four and adds red and black, making the universal statements over all players stronger. Each bet wins on 18 nonzero wheel outcomes and loses on 0 and the remaining 18 outcomes, so an adversary betting against an encrypted wheel outcome has concrete Internet roulette advantage nndist Pr[W(r, bet) = 1] (18 / 37) (|Pr[W(r, bet) = 1] - 18 / 37|, p. 22).

In the concrete single-cipher model (Cipher.oneTimeExperiment), the explicit TwoStage reduction rouletteReduction asks to distinguish a uniform r : Fin 37 from 0, equating the roulette advantage with the semantic-security distinguishing advantage whenever valid admits every pair (r, 0) on Fin 37 (rouletteAdvantage_eq_advantage_rouletteReduction, capturing (2.7) and (2.8) on p. 23, and cf. (2.9) on p. 25; without an efficiency claim). The hypothesis ∀ r : Fin 37, valid r 0 = true is required because Cipher.oneTimeExperiment rejects pairs where valid returns false, whereas Attack Game 2.1 admits every fixed-size message pair on Fin 37.

In the uniform asymptotic DEMOneTimeKeyINDCPAOf model (keyLen, encryptSym), rouletteToDEMAdversary uses rouletteReduction with modular residue sampling ProbComp.sampleModNat (width n) 37 in place of exact uniform Fin 37 sampling, saving the residue encoded in unary length in the adversary state (isPPT_rouletteToDEMAdversary). Consequently, rouletteDEMAdvantage_le_demKeyGame_add incurs a (74 : ℝ≥0) / 2 ^ width n statistical-distance overhead (one 37 / 2 ^ width n term on each side of the two-experiment bound) where the book has an equality. Fixing width := id internally, DEMOneTimeKeyINDCPAOf.negligible_rouletteDEMAdvantage proves Theorem 2.9 (p. 23): rouletteDEMAdvantage keyLen encryptSym A is negligible for every uniform strict PPT adversary A : ℕ → List Bool → ProbComp RouletteBet.

Main definitions #

Main results #

References #

Even-money bets on a 37-pocket single-zero roulette wheel Fin 37 ([BS23], Section 2.2.4, p. 22). Includes the book's four bets (even, odd, low, high) together with the additional bets red and black; each wins on 18 nonzero outcomes and loses on 0 and the remaining 18 outcomes.

Instances For

    Winning predicate W(r, bet) for European roulette outcome r : Fin 37 and bet bet : RouletteBet ([BS23], Section 2.2.4, p. 22). Outcome 0 always loses.

    Under a uniform wheel spin r : Fin 37, every RouletteBet wins with probability 18 / 37.

    noncomputable def Cslib.Crypto.Encryption.rouletteExperiment {K C : Type} (E : Cipher K (Fin 37) C) (sampleKey : ProbComp K) (A : C → ProbComp RouletteBet) :

    Real Internet roulette experiment: spin a uniform wheel outcome r : Fin 37, sample a fresh key k ← sampleKey, encrypt r, and test rouletteWin r bet on the adversary's bet ([BS23], Section 2.2.4, p. 22).

    noncomputable def Cslib.Crypto.Encryption.idealRouletteExperiment {K C : Type} (E : Cipher K (Fin 37) C) (sampleKey : ProbComp K) (A : C → ProbComp RouletteBet) :

    Ideal Internet roulette experiment: spin r : Fin 37, pass an encryption of the fixed outcome 0 to the adversary, and test rouletteWin r bet ([BS23], Section 2.2.4, p. 23).

    In idealRouletteExperiment, the ciphertext reveals nothing about r, so any adversary wins with probability 18 / 37.

    noncomputable def Cslib.Crypto.Encryption.rouletteAdvantage {K C : Type} (E : Cipher K (Fin 37) C) (sampleKey : ProbComp K) (A : C → ProbComp RouletteBet) :

    Internet roulette advantage IRadv[A] := |Pr[W(r, bet) = 1] - 18 / 37| ([BS23], Section 2.2.4, p. 22), packaged as a nonnegative real via nndist.

    noncomputable def Cslib.Crypto.Encryption.rouletteReduction {C : Type} (sampleIndex : ProbComp (Fin 37)) (A : C → ProbComp RouletteBet) :

    Explicit TwoStage semantic-security reduction for Internet roulette, parameterized by the challenge index sampler sampleIndex ([BS23], Section 2.2.4, p. 23): choose (r, 0) with r ← sampleIndex and save r, then on challenge ciphertext ct run A ct and return rouletteWin r bet.

    theorem Cslib.Crypto.Encryption.rouletteAdvantage_eq_advantage_rouletteReduction {K C : Type} (E : Cipher K (Fin 37) C) (sampleKey : ProbComp K) {valid : Fin 37 → Fin 37 → Bool} (hvalid : ∀ (r : Fin 37), valid r 0 = true) (A : C → ProbComp RouletteBet) :

    Display (2.7) ([BS23], Section 2.2.4, p. 23, and cf. (2.8)): whenever valid admits every pair (r, 0) on Fin 37, rouletteAdvantage equals the semantic-security distinguishing advantage of rouletteReduction (ProbComp.uniform (Fin 37)) A.

    Uniform asymptotic DEM reduction #

    noncomputable def Cslib.Crypto.Encryption.rouletteDEMExperiment (keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → Fin 37 → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp RouletteBet) (n : ℕ) :

    Parameterized symmetric-cipher Internet roulette experiment using a keyLen n-bit key and encryptSym n via wordCipher.

    noncomputable def Cslib.Crypto.Encryption.rouletteDEMAdvantage (keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → Fin 37 → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp RouletteBet) (n : ℕ) :

    Parameterized symmetric-cipher Internet roulette advantage |Pr[W(r, bet) = 1] - 18 / 37|, defined directly through rouletteDEMExperiment.

    Word-level AdversaryOf (Fin 37) wrapper around rouletteReduction: phase 1 invokes rouletteReduction with sampleModNat (width n) 37 and stores r.val in the unary state length; phase 2 recovers r from state.length % 37, runs A n ct, and evaluates rouletteWin.

    Whenever width is polynomial-time computable in unary and A is uniform strict PPT, rouletteToDEMAdversary width A is a uniform strict PPT AdversaryOf (Fin 37).

    theorem Cslib.Crypto.Encryption.rouletteDEMAdvantage_le_demKeyGame_add (width keyLen : ℕ → ℕ) (encryptSym : ℕ → List Bool → Fin 37 → ProbComp (List Bool)) (A : ℕ → List Bool → ProbComp RouletteBet) (n : ℕ) :
    rouletteDEMAdvantage keyLen encryptSym A n ≤ Experiment.advantage (demKeyGame keyLen encryptSym (rouletteToDEMAdversary width A) false n) (demKeyGame keyLen encryptSym (rouletteToDEMAdversary width A) true n) + 74 / 2 ^ width n

    Concrete DEM semantic-security reduction for Internet roulette: rouletteDEMAdvantage is bounded by the distinguishing advantage of rouletteToDEMAdversary width A plus (74 : ℝ≥0) / 2 ^ width n from approximating two Fin 37 uniform wheel spins with ProbComp.sampleModNat (width n) 37.

    theorem Cslib.Crypto.Encryption.DEMOneTimeKeyINDCPAOf.negligible_rouletteDEMAdvantage {encIndex : Fin 37 ↪ List Bool} {encBet : RouletteBet ↪ List Bool} {keyLen : ℕ → ℕ} {encryptSym : ℕ → List Bool → Fin 37 → ProbComp (List Bool)} (hdem : DEMOneTimeKeyINDCPAOf encIndex keyLen encryptSym) {A : ℕ → List Bool → ProbComp RouletteBet} (hA : Probability.IsPPT encBet A) :
    Negligible (rouletteDEMAdvantage keyLen encryptSym A)

    Asymptotic Theorem 2.9 ([BS23], Section 2.2.4, p. 23): under DEMOneTimeKeyINDCPAOf encIndex keyLen encryptSym, every uniform strict PPT adversary A : ℕ → List Bool → ProbComp RouletteBet has negligible Internet roulette advantage.