Documentation

VCVio.CryptoFoundations.AsymmEncAlg

Asymmetric Encryption Schemes. #

This file defines a type AsymmEncAlg spec M PK SK C to represent an protocol for asymmetric encryption using oracles in spec, with message space M, public/secret keys PK and SK, and ciphertext space C.

structure AsymmEncAlg (m : TypeType u) (M PK SK C : Type) extends ExecutionMethod m :
Type (max 1 u)

An AsymmEncAlg with message space M, key spaces PK and SK, and ciphertexts in C. spec is the available oracle set and m is the monad used to execute the oracle calls. Extends ExecutionMethod spec m, in most cases will be ExecutionMethod.default.

Instances For
    def PKE_Alg (m : TypeType u) (M PK SK C : Type) :
    Type (max 1 u)

    Alias of AsymmEncAlg.


    An AsymmEncAlg with message space M, key spaces PK and SK, and ciphertexts in C. spec is the available oracle set and m is the monad used to execute the oracle calls. Extends ExecutionMethod spec m, in most cases will be ExecutionMethod.default.

    Equations
    Instances For
      @[reducible, inline]
      def AsymmEncAlg.CorrectExp {m : TypeType v} {M PK SK C : Type} [DecidableEq M] [AlternativeMonad m] (encAlg : AsymmEncAlg m M PK SK C) (msg : M) :

      A SymmEncAlg is complete if decrypting an encrypted message always returns that original message, captured here by a guard statement.

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For
        def AsymmEncAlg.PerfectlyCorrect {m : TypeType v} {M PK SK C : Type} [DecidableEq M] [AlternativeMonad m] (encAlg : AsymmEncAlg m M PK SK C) :
        Equations
        Instances For
          @[simp]
          theorem AsymmEncAlg.PerfectlyCorrect_iff {m : TypeType v} {M PK SK C : Type} [DecidableEq M] [AlternativeMonad m] (encAlg : AsymmEncAlg m M PK SK C) :
          encAlg.PerfectlyCorrect ∀ (msg : M), [⊥|encAlg.CorrectExp msg] = 0
          Equations
          Instances For
            def AsymmEncAlg.IND_CPA_adversary {M PK SK C : Type} (encAlg : AsymmEncAlg ProbComp M PK SK C) :
            Type (max 1 u_1)
            Equations
            Instances For
              def AsymmEncAlg.IND_CPA_queryImpl' {M PK SK C : Type} [DecidableEq M] [DecidableEq C] (encAlg : AsymmEncAlg ProbComp M PK SK C) (pk : PK) (b : Bool) :

              Can be shown this is equivalent to below definition for asymptotic security.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                def AsymmEncAlg.IND_CPA_queryImpl {M PK SK C : Type} (encAlg : AsymmEncAlg ProbComp M PK SK C) (pk : PK) (b : Bool) :
                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  def AsymmEncAlg.IND_CPA_experiment {M PK SK C : Type} [DecidableEq M] [DecidableEq C] {encAlg : AsymmEncAlg ProbComp M PK SK C} (adversary : encAlg.IND_CPA_adversary) :
                  Equations
                  • One or more equations did not get rendered due to their size.
                  Instances For
                    noncomputable def AsymmEncAlg.IND_CPA_advantage {M PK SK C : Type} [DecidableEq M] [DecidableEq C] {encAlg : AsymmEncAlg ProbComp M PK SK C} (adversary : encAlg.IND_CPA_adversary) :
                    Equations
                    Instances For
                      theorem AsymmEncAlg.probOutput_IND_CPA_experiment_eq_add {M PK SK C : Type} [DecidableEq M] [DecidableEq C] {encAlg : AsymmEncAlg ProbComp M PK SK C} (adversary : encAlg.IND_CPA_adversary) :
                      [=()|IND_CPA_experiment adversary] = [=()|do let __discrencAlg.keygen match __discr with | (pk, _sk) => do let b(OracleComp.simulateQ (encAlg.IND_CPA_queryImpl' pk true) (adversary pk)).run' guard (b = true)] / 2 + [=()|do let __discrencAlg.keygen match __discr with | (pk, _sk) => do let b(OracleComp.simulateQ (encAlg.IND_CPA_queryImpl' pk false) (adversary pk)).run' guard ¬b = true] / 2

                      The probability of the IND-CPA experiment is the average of the probability of the experiment with the challenge being true and the probability of the experiment with the challenge being false.

                      def AsymmEncAlg.decryptionOracle {m : TypeType v} {M PK SK C : Type} [AlternativeMonad m] (encAlg : AsymmEncAlg m M PK SK C) (sk : SK) :

                      Oracle that uses a secret key to respond to decryption requests.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        @[simp]
                        theorem AsymmEncAlg.decryptionOracle.apply_eq {m : TypeType v} {M PK SK C α : Type} [AlternativeMonad m] (encAlg : AsymmEncAlg m M PK SK C) (sk : SK) (q : (C →ₒ M).OracleQuery α) :
                        (encAlg.decryptionOracle sk).impl q = match α, q with | .((C →ₒ M).range ()), OracleSpec.query PUnit.unit c => (encAlg.decrypt sk c).getM
                        def AsymmEncAlg.IND_CCA_oracleSpec {m : TypeType v} {M PK SK C : Type} (_encAlg : AsymmEncAlg m M PK SK C) :

                        Two oracles for IND-CCA Experiment, the first for decrypting ciphertexts, and the second for getting a challenge from a pair of messages.

                        Equations
                        Instances For
                          def AsymmEncAlg.IND_CCA_oracleImpl {m : TypeType v} {M PK SK C : Type} [AlternativeMonad m] [DecidableEq C] (encAlg : AsymmEncAlg m M PK SK C) (pk : PK) (sk : SK) (b : Bool) :

                          Implement oracles for IND-CCA security game. A state monad is to track the current challenge, if it exists, and is set by the adversary calling the second oracle. The decryption oracle checks to make sure it doesn't decrypt the challenge.

                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            structure AsymmEncAlg.IND_CCA_Adversary {m : TypeType v} {M PK SK C : Type} (encAlg : AsymmEncAlg m M PK SK C) :
                            Type (max (max 1 u_1) u_2)
                            Instances For
                              def AsymmEncAlg.IND_CCA_Game {m : TypeType v} {M PK SK C : Type} [AlternativeMonad m] [DecidableEq C] (encAlg : AsymmEncAlg m M PK SK C) (adversary : encAlg.IND_CCA_Adversary) :
                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For
                                structure AsymmEncAlg.IND_CPA_Adv {m : TypeType v} {M PK SK C : Type} (encAlg : AsymmEncAlg m M PK SK C) :
                                Type (max 1 v)

                                IND_CPA_adv M PK C is an adversary for IND-CPA security game on an asymmetric encryption with public keys in PK, messages in M, and ciphertexts in C. The adversary consists of two functions:

                                • chooseMessages: given a public key, returns a pair of messages that it thinks it can distinguish the encryption of, and a private state.
                                • distinguish: given a private state and an encryption, returns whether it is an encryption of the first message or the second message
                                Instances For
                                  def AsymmEncAlg.IND_CPA_OneTime_Game {ι : Type} {spec : OracleSpec ι} {M PK SK C : Type} {encAlg : AsymmEncAlg (OracleComp spec) M PK SK C} (adv : encAlg.IND_CPA_Adv) :

                                  Experiment for one-time IND-CPA security of an asymmetric encryption algorithm:

                                  1. Run keygen to get a public key and a private key.
                                  2. Run adv.chooseMessages on pk to get a pair of messages and a private state.
                                  3. The challenger then tosses a coin and encrypts one of the messages, returning the ciphertext c.
                                  4. Run adv.distinguish on the private state and the ciphertext to get a boolean.
                                  5. Return a Boolean indicating whether the adversary's guess is correct.

                                  Note: we do not want to end with a guard statement, as this can be biased by the adversary potentially always failing.

                                  Equations
                                  • One or more equations did not get rendered due to their size.
                                  Instances For
                                    noncomputable def AsymmEncAlg.IND_CPA_OneTime_Advantage {ι : Type} {spec : OracleSpec ι} {M PK SK C : Type} (encAlg : AsymmEncAlg (OracleComp spec) M PK SK C) (adv : encAlg.IND_CPA_Adv) :
                                    Equations
                                    Instances For