Documentation

CslibFrontier.Crypto.Computational.Encryption.CCA.AssociatedData

Chosen-ciphertext security with associated data (1CCA-AD) #

This module defines the single-challenge adaptive chosen-ciphertext security experiment with associated data (1CCA with associated data, Boneh and Shoup, Section 12.7, Definition 12.7, printed pp. 501–502) over an arbitrary message space Msg, associated-data space AD, and decryption output space Out, extending Cslib.Crypto.Encryption.CCA2AdversaryOf, cca2GameOn, and INDCCA2On from CslibFrontier.Crypto.Computational.Encryption.CCA.

In Phase 1 (choose), the adversary makes adaptive decryption queries (ct, ad) (encoded as encPair encBits encBits (ct, ad)) and outputs an ADChoiceOut Msg AD record holding the two challenge messages msg₀ and msg₁, challenge associated data ad, and saved state word state. If valid n pk msg₀ msg₁ holds, the challenger encrypts if bit then msg₁ else msg₀ under ad to obtain ct, and runs Phase 2 (guess) against cca2ADPhase2Oracle, which rejects the exact challenge pair (ct, encAD ad) with [] (encOption encOut none) and decrypts every other query (ct', ad').

Main definitions #

Main results #

References #

Phase 1 choice output of an ADCCA2AdversaryOf Msg AD: the two challenge messages msg₀ and msg₁, challenge associated data ad, and saved state word state.

  • msg₀ : Msg

    First challenge message (bit = false).

  • msg₁ : Msg

    Second challenge message (bit = true).

  • ad : AD

    Associated data bound to the challenge ciphertext.

  • state : List Bool

    State word passed from Phase 1 (choose) to Phase 2 (guess).

Instances For
    def Cslib.Crypto.Encryption.instDecidableEqADChoiceOut.decEq {Msg✝ AD✝ : Type} [DecidableEq Msg✝] [DecidableEq AD✝] (x✝ x✝¹ : ADChoiceOut Msg✝ AD✝) :
    Decidable (x✝ = x✝¹)
    @[instance_reducible]
    def Cslib.Crypto.Encryption.instReprADChoiceOut.repr {Msg✝ AD✝ : Type} [Repr Msg✝] [Repr AD✝] :
    ADChoiceOut Msg✝ AD✝ → ℕ → Std.Format
    @[instance_reducible]
    instance Cslib.Crypto.Encryption.instReprADChoiceOut {Msg✝ AD✝ : Type} [Repr Msg✝] [Repr AD✝] :
    Repr (ADChoiceOut Msg✝ AD✝)
    def Cslib.Crypto.Encryption.encADChoiceOut {Msg AD : Type} (encMsg : Msg ↪ List Bool) (encAD : AD ↪ List Bool) :

    Bit-string encoding of ADChoiceOut Msg AD as the left-grouped tuple (((msg₀, msg₁), ad), state): the message pair (msg₀, msg₁) (msg₀ framed), framed and paired with ad, then framed and followed by state.

    theorem Cslib.Crypto.Encryption.encADChoiceOut_msg₀_polyTime {Msg AD γ : Type} {encMsg : Msg ↪ List Bool} {encAD : AD ↪ List Bool} {encIn : γ ↪ List Bool} {g : γ → ADChoiceOut Msg AD} (h : Turing.MultiTapeTM.ComputableInPolyTime g encIn (encADChoiceOut encMsg encAD)) :
    Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ) => (g a).msg₀) encIn encMsg
    theorem Cslib.Crypto.Encryption.encADChoiceOut_msg₁_polyTime {Msg AD γ : Type} {encMsg : Msg ↪ List Bool} {encAD : AD ↪ List Bool} {encIn : γ ↪ List Bool} {g : γ → ADChoiceOut Msg AD} (h : Turing.MultiTapeTM.ComputableInPolyTime g encIn (encADChoiceOut encMsg encAD)) :
    Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ) => (g a).msg₁) encIn encMsg
    theorem Cslib.Crypto.Encryption.encADChoiceOut_ad_polyTime {Msg AD γ : Type} {encMsg : Msg ↪ List Bool} {encAD : AD ↪ List Bool} {encIn : γ ↪ List Bool} {g : γ → ADChoiceOut Msg AD} (h : Turing.MultiTapeTM.ComputableInPolyTime g encIn (encADChoiceOut encMsg encAD)) :
    Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ) => (g a).ad) encIn encAD
    theorem Cslib.Crypto.Encryption.encADChoiceOut_state_polyTime {Msg AD γ : Type} {encMsg : Msg ↪ List Bool} {encAD : AD ↪ List Bool} {encIn : γ ↪ List Bool} {g : γ → ADChoiceOut Msg AD} (h : Turing.MultiTapeTM.ComputableInPolyTime g encIn (encADChoiceOut encMsg encAD)) :
    theorem Cslib.Crypto.Encryption.encADChoiceOut_mk_polyTime {Msg AD γ : Type} {encMsg : Msg ↪ List Bool} {encAD : AD ↪ List Bool} {encIn : γ ↪ List Bool} {m₀ m₁ : γ → Msg} {ad : γ → AD} {st : γ → List Bool} (hm₀ : Turing.MultiTapeTM.ComputableInPolyTime m₀ encIn encMsg) (hm₁ : Turing.MultiTapeTM.ComputableInPolyTime m₁ encIn encMsg) (had : Turing.MultiTapeTM.ComputableInPolyTime ad encIn encAD) (hst : Turing.MultiTapeTM.ComputableInPolyTime st encIn Turing.MultiTapeTM.encBits) :
    Turing.MultiTapeTM.ComputableInPolyTime (fun (a : γ) => { msg₀ := m₀ a, msg₁ := m₁ a, ad := ad a, state := st a }) encIn (encADChoiceOut encMsg encAD)

    A single-challenge adaptive chosen-ciphertext adversary with associated data (1CCA with associated data, [BS23], Section 12.7, Definition 12.7, printed pp. 501–502) over message space Msg and associated-data space AD. Both stages have access to the single-channel decryption oracle (Operation = Unit), where each decryption query is a framed pair encPair encBits encBits (ct, ad).

    structure Cslib.Crypto.Encryption.ADCCA2AdversaryOf.IsPPT {Msg AD : Type} (encMsg : Msg ↪ List Bool) (encAD : AD ↪ List Bool) (adversary : ADCCA2AdversaryOf Msg AD) :

    Uniform strict oracle PPT admissibility of both stages of an ADCCA2AdversaryOf Msg AD with respect to message encoding encMsg and associated-data encoding encAD.

    def Cslib.Crypto.Encryption.ADCCA2AdversaryOf.IsQueryBounded {Msg AD : Type} (adversary : ADCCA2AdversaryOf Msg AD) (Q₁ Q₂ : ℕ → ℕ) :

    Per-stage decryption-query bound (Q₁ n, Q₂ n) for an ADCCA2AdversaryOf Msg AD.

    theorem Cslib.Crypto.Encryption.ADCCA2AdversaryOf.IsPPT.query_bounds {Msg AD : Type} {encMsg : Msg ↪ List Bool} {encAD : AD ↪ List Bool} {adversary : ADCCA2AdversaryOf Msg AD} (hA : IsPPT encMsg encAD adversary) :
    ∃ (c₁ : ℕ) (d₁ : ℕ) (c₂ : ℕ) (d₂ : ℕ) (cs : ℕ) (ds : ℕ), (∀ (n : ℕ) (pk : List Bool), ProbOracleComp.IsQueryBounded (adversary.choose n pk) (c₁ * (n + pk.length + 2) ^ d₁)) ∧ (∀ (n : ℕ) (state ct : List Bool), ProbOracleComp.IsQueryBounded (adversary.guess n state ct) (c₂ * (n + state.length + ct.length + 2) ^ d₂)) ∧ ∀ (n : ℕ) (pk : List Bool) (State : Type) (oracle : Unit × List Bool → StateT State PMF (List Bool)) (s s' : State) (choice : ADChoiceOut Msg AD), (choice, s') ∈ (ProbOracleComp.runWith oracle (adversary.choose n pk) s).support → choice.state.length ≤ cs * (n + pk.length + 2) ^ ds

    Every strict oracle PPT ADCCA2AdversaryOf Msg AD has polynomial bounds on its Phase 1 queries and saved-state length in terms of (n, pk.length), and on its Phase 2 queries in terms of (n, state.length, ct.length) for every state word state.

    @[reducible, inline]

    Single-bit 1CCA adversary with associated data AD (Msg = Bool).

    @[reducible, inline]

    Native uniform strict oracle PPT admissibility for a bit 1CCA adversary with associated data.

    @[reducible, inline]

    Bit-string 1CCA adversary with associated data AD (Msg = List Bool).

    @[reducible, inline]

    Native uniform strict oracle PPT admissibility for a bit-string 1CCA adversary with associated data.

    Embed an associated-data-free CCA2AdversaryOf Msg as an ADCCA2AdversaryOf Msg Unit with trivial associated data () : Unit.

    theorem Cslib.Crypto.Encryption.CCA2AdversaryOf.IsPPT.toADUnit {Msg : Type} {encMsg : Msg ↪ List Bool} {adversary : CCA2AdversaryOf Msg} (hA : IsPPT encMsg adversary) :

    CCA2AdversaryOf.toADUnit preserves uniform strict oracle PPT admissibility.

    theorem Cslib.Crypto.Encryption.CCA2AdversaryOf.IsQueryBounded.toADUnit {Msg : Type} {adversary : CCA2AdversaryOf Msg} {Q₁ Q₂ : ℕ → ℕ} (hQ : adversary.IsQueryBounded Q₁ Q₂) :
    adversary.toADUnit.IsQueryBounded Q₁ Q₂

    CCA2AdversaryOf.toADUnit preserves per-stage decryption-query bounds.

    def Cslib.Crypto.Encryption.cca2ADPhase1Oracle {Out : Type} (encOut : Out ↪ List Bool) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Out) (n : ℕ) (sk : List Bool) (request : Unit × List Bool) :

    Phase 1 decryption oracle with associated data ([BS23], Section 12.7, Definition 12.7, printed pp. 501–502): unpack request.2 into ciphertext unframe request.2 and associated data dropFrame request.2, and reply with encOption encOut (decrypt n sk (unframe request.2) (dropFrame request.2)).

    def Cslib.Crypto.Encryption.cca2ADPhase2Oracle {Out : Type} (encOut : Out ↪ List Bool) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Out) (n : ℕ) (sk ct ad : List Bool) (request : Unit × List Bool) :

    Phase 2 decryption oracle with associated data ([BS23], Section 12.7, Definition 12.7, printed pp. 501–502): unpack request.2 into (unframe request.2, dropFrame request.2), reject the challenge pair (ct, ad) with [] (encOption encOut none), and answer all other queries with encOption encOut (decrypt n sk (unframe request.2) (dropFrame request.2)).

    noncomputable def Cslib.Crypto.Encryption.cca2ADGameOn {Msg AD Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encAD : AD ↪ List Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → AD → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Out) (adversary : ADCCA2AdversaryOf Msg AD) (bit : Bool) (n : ℕ) :

    Single-challenge 1CCA experiment with associated data ([BS23], Section 12.7, Definition 12.7, printed pp. 501–502) and challenge-pair admissibility predicate valid : ℕ → List Bool → Msg → Msg → Bool: sample (pk, sk) ← keyGen n, run Phase 1 (choose) against cca2ADPhase1Oracle, check valid n pk choice.msg₀ choice.msg₁, encrypt if bit then choice.msg₁ else choice.msg₀ with associated data choice.ad to obtain ct, and run Phase 2 (guess) against cca2ADPhase2Oracle rejecting (ct, encAD choice.ad).

    @[reducible, inline]
    noncomputable abbrev Cslib.Crypto.Encryption.cca2ADGame {Msg AD Out : Type} (encAD : AD ↪ List Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → AD → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Out) (adversary : ADCCA2AdversaryOf Msg AD) (bit : Bool) (n : ℕ) :

    Unconditional single-challenge 1CCA experiment with associated data (valid := fun _ _ _ _ => true).

    def Cslib.Crypto.Encryption.INDCCA2ADOn {Msg AD Out : Type} (valid : ℕ → List Bool → Msg → Msg → Bool) (encMsg : Msg ↪ List Bool) (encAD : AD ↪ List Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → AD → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Out) :

    Single-challenge 1CCA security with associated data ([BS23], Section 12.7, Definition 12.7, printed pp. 501–502) with respect to challenge-pair admissibility predicate valid, message encoding encMsg, associated-data encoding encAD, and decryption output encoding encOut.

    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.INDCCA2ADOf {Msg AD Out : Type} (encMsg : Msg ↪ List Bool) (encAD : AD ↪ List Bool) (encOut : Out ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Msg → AD → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Out) :

    Single-challenge 1CCA security with associated data over a fixed-length message space Msg (valid := fun _ _ _ _ => true).

    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.INDCCA2AD {AD : Type} (encAD : AD ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → Bool → AD → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → List Bool → Option Bool) :

    Single-challenge 1CCA security with associated data for bit encryption (Msg = Bool, Out = Bool).

    @[reducible, inline]
    abbrev Cslib.Crypto.Encryption.WordINDCCA2AD {AD : Type} (encAD : AD ↪ List Bool) (keyGen : ℕ → ProbComp (List Bool × List Bool)) (encrypt : ℕ → List Bool → List Bool → AD → ProbComp (List Bool)) (decrypt : ℕ → List Bool → List Bool → List Bool → Option (List Bool)) :

    Single-challenge 1CCA security with associated data for bit-string encryption (Msg = List Bool, Out = List Bool) under Attack Game 12.1's equal-length challenge rule m₀.length == m₁.length.