Documentation

CslibFrontier.Crypto.Computational.Encryption.KEM

Key encapsulation mechanisms #

A key encapsulation mechanism (KEM) KEM PK SK CT K has typed public keys, secret keys, ciphertexts and keys. Key generation draws a key pair, encapsulation under a public key draws a ciphertext together with the key it encapsulates, and decapsulation recovers the key from a ciphertext with the secret key, returning none on a ciphertext it rejects ([HHK17], Section 2.2). Correctness is a separate property (KEM.Correct), so a scheme with decapsulation errors is still a KEM. A KEM with implicit rejection, whose decapsulation always returns a key, is the instance with decaps sk c = some _.

In the indistinguishability game for a KEM, the challenger generates a key pair, encapsulates a key under the public key, and gives the adversary the public key, the challenge ciphertext and a challenge key: the encapsulated key or an independent random key, depending on the hidden bit. This is the attack game of [CS03], Section 7.1.2, restricted to adversaries that make no decryption queries. KEM.Challenge PK CT K is that input, with named fields in place of a triple PK × CT × K. KEM.cpaExperiment is the game of one fixed scheme against a distinguisher on the challenge; the random key is drawn from a sampler sampleKey, uniform on bit strings of the key length in the paper. Asymptotic security over a family of schemes and the efficiency of the distinguisher are stated on top of this experiment.

Main definitions #

References #

structure Cslib.Crypto.KEM.Challenge (PK CT K : Type) :

The input of a KEM indistinguishability adversary: the public key, the challenge ciphertext and the challenge key, which the attack game of [CS03], Section 7.1.2, gives the adversary in Stages 1 and 3.

  • pk : PK

    The public key.

  • ct : CT

    The challenge ciphertext, an encapsulation under pk.

  • key : K

    The challenge key: the key encapsulated in ct, or an independent random key, depending on the challenge bit.

structure Cslib.Crypto.KEM (PK SK CT K : Type) :

A key encapsulation mechanism ([HHK17], Section 2.2) with public keys PK, secret keys SK, ciphertexts CT and keys K.

  • keyGen : ProbComp (PK × SK)

    Key generation: draw a public key and its secret key.

  • encaps : PK → ProbComp (CT × K)

    Encapsulation under a public key: draw a ciphertext and the key it encapsulates.

  • decaps : SK → CT → Option K

    Decapsulation of a ciphertext with a secret key; none rejects the ciphertext.

def Cslib.Crypto.KEM.Correct {PK SK CT K : Type} (E : KEM PK SK CT K) :

A KEM is correct when decapsulation recovers every honestly encapsulated key: for every key pair that key generation can output and every ciphertext and key that encapsulation under the public key can output, decapsulation of the ciphertext with the secret key returns the key.

def Cslib.Crypto.KEM.cpaExperiment {PK SK CT K : Type} (E : KEM PK SK CT K) (sampleKey : ProbComp K) (D : Challenge PK CT K → ProbComp Bool) (b : Bool) :

The chosen-plaintext indistinguishability experiment of the KEM E with random keys drawn from sampleKey: the attack game of [CS03], Section 7.1.2, restricted to adversaries that make no decryption queries, in its two-experiment form. Draw a key pair and encapsulate a key under the public key. On b = false the challenge key is the encapsulated key; on b = true it is an independent key drawn from sampleKey. The distinguisher receives the public key, the ciphertext and the challenge key, and its guess is the output.