Documentation

OTP.Basic

OTP.Basic.lean #

This is the first file in a collection of Lean programs about the one-time pad (OTP) cryptographic scheme. It defines the basic types and operations needed for OTP, including:

Other files in the collection prove properties like key uniqueness and perfect secrecy.

Files in this series:

Types for the one-time pad (OTP) and properties of xor #

Types for the OTP #

def Plaintext (n : ) :
Equations
Instances For
    def Key (n : ) :
    Equations
    Instances For
      def Ciphertext (n : ) :
      Equations
      Instances For

        Definition of Boolean xor #

        This is actually a build-in function in Lean, called Bool.xor, but we define it here for clarity.

        xor is associative #

        Definition of vec_xor operation: point-wise xor for boolean vectors #

        def vec_xor {n : } (v₁ v₂ : List.Vector Bool n) :
        Equations
        Instances For

          Definitions of encrypt and decrypt operations #

          def encrypt {n : } (m : Plaintext n) (k : Key n) :
          Equations
          Instances For
            def decrypt {n : } (c : Ciphertext n) (k : Key n) :
            Equations
            Instances For

              Demo 1: Basic OTP Operations #

              Demo 2: xor properties #

              theorem xor_aab_eq_b (a b : Bool) :
              (a ^^ (a ^^ b)) = b
              theorem xor_abb_eq_a (a b : Bool) :
              (a ^^ b ^^ b) = a
              theorem xor_ab_eq_c_iff_b_eq_ac (a b c : Bool) :
              (a ^^ b) = c b = (a ^^ c)