Documentation

VCVio.CryptoFoundations.SymmEncAlg

Symmetric Encryption Schemes. #

This file defines a type SymmEncAlg spec M K C to represent a protocol for symmetric encryption using oracles in spec, with message space M, secret keys of type K, and ciphertext space C.

structure SymmEncAlg (M K C : Type) (Q : Type v) extends OracleContext Q ProbComp :
Type (v + 1)
Instances For
    def SymmEncAlg.CompleteExp {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) {sp : } (m : M sp) :
    OptionT (OracleComp encAlg.spec) (M sp)
    Equations
      Instances For
        def SymmEncAlg.Complete {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) :
        Equations
          Instances For

            Definitions and Equivalences #

            perfectSecrecyAt is the canonical notion (independence form). We also provide equivalent formulations:

            The _iff_ lemmas below record equivalence between these forms.

            def SymmEncAlg.PerfectSecrecyExp {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) :
            ProbComp (M sp × C sp)

            Joint message/ciphertext experiment used to express perfect secrecy.

            Equations
              Instances For
                def SymmEncAlg.PerfectSecrecyCipherExp {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) :
                ProbComp (C sp)

                Ciphertext marginal induced by the perfect-secrecy experiment.

                Equations
                  Instances For
                    def SymmEncAlg.PerfectSecrecyPriorExp {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) :
                    ProbComp (M sp)

                    Message prior induced by the message generator.

                    Equations
                      Instances For
                        def SymmEncAlg.PerfectSecrecyCipherGivenMsgExp {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (msg : M sp) :
                        ProbComp (C sp)

                        Ciphertext experiment conditioned on a fixed message.

                        Equations
                          Instances For
                            theorem SymmEncAlg.PerfectSecrecyExp_eq_bind {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) :
                            encAlg.PerfectSecrecyExp sp mgen = do let msgencAlg.PerfectSecrecyPriorExp sp mgen (fun (x : C sp) => (msg, x)) <$> encAlg.PerfectSecrecyCipherGivenMsgExp sp msg
                            theorem SymmEncAlg.PerfectSecrecyCipherExp_eq_bind {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) :
                            encAlg.PerfectSecrecyCipherExp sp mgen = do let msgencAlg.PerfectSecrecyPriorExp sp mgen encAlg.PerfectSecrecyCipherGivenMsgExp sp msg
                            theorem SymmEncAlg.probOutput_PerfectSecrecyExp_eq_mul_cipherGivenMsg {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) (msg : M sp) (σ : C sp) :
                            Pr[=(msg, σ) | encAlg.PerfectSecrecyExp sp mgen] = Pr[=msg | encAlg.PerfectSecrecyPriorExp sp mgen] * Pr[=σ | encAlg.PerfectSecrecyCipherGivenMsgExp sp msg]
                            theorem SymmEncAlg.probOutput_PerfectSecrecyCipherExp_eq_tsum {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) (mgen : OracleComp encAlg.spec (M sp)) (σ : C sp) :
                            Pr[=σ | encAlg.PerfectSecrecyCipherExp sp mgen] = ∑' (msg : M sp), Pr[=msg | encAlg.PerfectSecrecyPriorExp sp mgen] * Pr[=σ | encAlg.PerfectSecrecyCipherGivenMsgExp sp msg]
                            def SymmEncAlg.perfectSecrecyAtAllPriors {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) :

                            Strong perfect secrecy at a fixed security parameter: ciphertexts are independent of messages for every prior distribution on messages (PMF-level quantification).

                            Equations
                              Instances For
                                def SymmEncAlg.ciphertextRowsEqualAt {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) :

                                Equivalent channel-style formulation: every message induces the same ciphertext distribution.

                                Equations
                                  Instances For
                                    def SymmEncAlg.perfectSecrecyAt {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) :

                                    Standard perfect secrecy at one security parameter, expressed as independence: Pr[(M, C)] = Pr[M] * Pr[C]. This is the canonical code-level definition.

                                    Equations
                                      Instances For
                                        def SymmEncAlg.perfectSecrecy {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) :

                                        Canonical asymptotic perfect secrecy notion.

                                        Equations
                                          Instances For
                                            def SymmEncAlg.perfectSecrecyPosteriorEqPriorAt {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) :

                                            Posterior-equals-prior form, written in cross-multiplied form to avoid division. This is equivalent to perfectSecrecyAt.

                                            Equations
                                              Instances For
                                                def SymmEncAlg.perfectSecrecyJointFactorizationAt {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) :

                                                Joint-factorization form (same mathematical statement as independence, with explicit named priors/marginals). This is equivalent to perfectSecrecyAt.

                                                Equations
                                                  Instances For
                                                    def SymmEncAlg.perfectSecrecyPosteriorEqPrior {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) :
                                                    Equations
                                                      Instances For
                                                        def SymmEncAlg.perfectSecrecyJointFactorization {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) :
                                                        Equations
                                                          Instances For
                                                            theorem SymmEncAlg.cipherGivenMsg_uniform_of_uniformKey_of_uniqueKey {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) [Fintype (K sp)] (deterministicEnc : ∀ (k : K sp) (msg : M sp), ∃ (c : C sp), support (simulateQ encAlg.impl (encAlg.encrypt k msg)) = {c}) (hKeyUniform : ∀ (k : K sp), Pr[=k | simulateQ encAlg.impl (encAlg.keygen sp)] = (↑(Fintype.card (K sp)))⁻¹) (hUniqueKey : ∀ (msg : M sp) (c : C sp), ∃! k : K sp, k support (simulateQ encAlg.impl (encAlg.keygen sp)) c support (simulateQ encAlg.impl (encAlg.encrypt k msg))) (msg : M sp) (σ : C sp) :

                                                            Core uniformity lemma: uniform keygen plus unique key per (message, ciphertext) pair implies every (message, ciphertext) conditional has probability (card K)⁻¹. Both Shannon theorems follow from this.

                                                            theorem SymmEncAlg.ciphertextRowsEqualAt_of_uniformKey_of_uniqueKey {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) [Fintype (K sp)] (deterministicEnc : ∀ (k : K sp) (msg : M sp), ∃ (c : C sp), support (simulateQ encAlg.impl (encAlg.encrypt k msg)) = {c}) (hKeyUniform : ∀ (k : K sp), Pr[=k | simulateQ encAlg.impl (encAlg.keygen sp)] = (↑(Fintype.card (K sp)))⁻¹) (hUniqueKey : ∀ (msg : M sp) (c : C sp), ∃! k : K sp, k support (simulateQ encAlg.impl (encAlg.keygen sp)) c support (simulateQ encAlg.impl (encAlg.encrypt k msg))) :
                                                            theorem SymmEncAlg.perfectSecrecyAt_of_uniformKey_of_uniqueKey {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) [Fintype (M sp)] [Fintype (K sp)] [Fintype (C sp)] (deterministicEnc : ∀ (k : K sp) (msg : M sp), ∃ (c : C sp), support (simulateQ encAlg.impl (encAlg.encrypt k msg)) = {c}) :
                                                            ((∀ (k : K sp), Pr[=k | simulateQ encAlg.impl (encAlg.keygen sp)] = (↑(Fintype.card (K sp)))⁻¹) ∀ (msg : M sp) (c : C sp), ∃! k : K sp, k support (simulateQ encAlg.impl (encAlg.keygen sp)) c support (simulateQ encAlg.impl (encAlg.encrypt k msg))) → encAlg.perfectSecrecyAt sp

                                                            Constructive Shannon direction at fixed security parameter: if keygen is uniform and each (message, ciphertext) pair is realized by a unique key in support, then perfect secrecy holds (perfectSecrecyAt).

                                                            deterministicEnc asserts encryption is deterministic in distribution (singleton support for each fixed (key, message)).

                                                            Note: the converse direction requires stronger prior expressivity assumptions than perfectSecrecyAt currently encodes; see perfectSecrecyAtAllPriors.

                                                            theorem SymmEncAlg.perfectSecrecyAtAllPriors_of_card_eq_of_uniform_unique {M K C : Type} {Q : Type v} (encAlg : SymmEncAlg M K C Q) (sp : ) [Fintype (M sp)] [Fintype (K sp)] [Fintype (C sp)] (_hComplete : encAlg.Complete) (_h1 : Fintype.card (M sp) = Fintype.card (K sp)) (_h2 : Fintype.card (K sp) = Fintype.card (C sp)) (deterministicEnc : ∀ (k : K sp) (msg : M sp), ∃ (c : C sp), support (simulateQ encAlg.impl (encAlg.encrypt k msg)) = {c}) :
                                                            ((∀ (k : K sp), Pr[=k | simulateQ encAlg.impl (encAlg.keygen sp)] = (↑(Fintype.card (K sp)))⁻¹) ∀ (msg : M sp) (c : C sp), ∃! k : K sp, k support (simulateQ encAlg.impl (encAlg.keygen sp)) c support (simulateQ encAlg.impl (encAlg.encrypt k msg))) → encAlg.perfectSecrecyAtAllPriors sp

                                                            Strong constructive Shannon direction with cardinality/completeness context: uniform keys plus uniqueness imply perfect secrecy for all priors.