Documentation

Cryptlib.Primitives.MultiRecipientHybrid.Adapter

MultiRecipientHybrid from a KEM, an AEAD and a hash #

ENCAPSULATE(keys, payload):
    for pk in keys: ct_i, ss_i := KEM_ENCAP(pk)        -- independent per recipient
    secret_i       := HASH(ss_i)
    msgKey         := RANDOM(32)
    envelope       := nonce ‖ AEAD_seal(msgKey, payload)
    dek_i          := nonce_i ‖ AEAD_seal(secret_i, msgKey)
    return [secret_i], ([ct_i], [dek_i], envelope)

DECAPSULATE(sk, ct):                                    -- ct already filtered to one recipient
    ss             := KEM_DECAP(sk, ct.kemCiphertexts[0])
    secret         := HASH(ss)
    msgKey         := AEAD_open(secret, ct.deks[0])
    return secret, AEAD_open(msgKey, ct.envelope)

The pure functions take explicit randomness (Rand); the instance draws it from a KEM.Adapter.St seed stream, which must be unpredictable. Reliable requires KEM.Reliable for every KEM seed the stream can yield.

The three primitives, and the fact that lets a hash output be an AEAD key.

Instances For

    The sender's randomness, with one KEM seed per recipient.

    Instances For

      A raw byte string as an AEAD key, if it is the right length.

      Equations
      Instances For

        Sealing under a key: nonce, then AEAD ciphertext #

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For

          One KEM encapsulation, wrapped as Option #

          kem.encap from a seed-derived state, none on error.

          Equations
          Instances For

            Every KEM seed a Rand draws lands on a Reliable state.

            Equations
            Instances For

              The construction, with explicit randomness #

              Encrypt payload to every recipient. none if any recipient's KEM.encap fails.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For

                Open a single-recipient ciphertext: decapsulate, open the DEK, then the envelope.

                Equations
                • One or more equations did not get rendered due to their size.
                Instances For
                  theorem Cryptlib.Primitives.MultiRecipientHybrid.Adapter.Base.encapsulateP_spec (S : Base) (rand : Rand S) (keys : List S.kem.PublicKey) (payload : ByteArray) (derivedKeys : List ByteArray) (ct : MultiRecipientHybrid.Ciphertext S.kem.Ciphertext) (h : S.encapsulateP rand keys payload = some (derivedKeys, ct)) :
                  ∃ (pairs : List (S.kem.Ciphertext × S.kem.Plaintext)), List.mapM (fun (p : S.kem.PublicKey × Vector UInt8 32) => S.encapPair p.fst p.snd) (keys.zip rand.kemSeeds) = some pairs ∧ derivedKeys = List.map (fun (p : S.kem.Ciphertext × S.kem.Plaintext) => S.deriveKeyBytes p.snd) pairs ∧ ct = { kemCiphertexts := List.map Prod.fst pairs, deks := List.map (fun (p : S.aead.Key × Vector UInt8 S.aead.nonceSize) => S.sealUnder p.fst p.snd (Util.Bytes.ofVector rand.msgKey)) ((List.map (fun (p : S.kem.Ciphertext × S.kem.Plaintext) => S.deriveKeyAead p.snd) pairs).zip rand.dekNonces), envelope := S.sealUnder (S.aead.keyFromBytes rand.msgKey) rand.envNonce payload }

                  Unpack a successful encapsulation.

                  theorem Cryptlib.Primitives.MultiRecipientHybrid.Adapter.Base.encapsulateP_shape (S : Base) (rand : Rand S) (keys : List S.kem.PublicKey) (payload : ByteArray) (hlen : rand.kemSeeds.length = keys.length) (hlen' : rand.dekNonces.length = keys.length) (derivedKeys : List ByteArray) (ct : MultiRecipientHybrid.Ciphertext S.kem.Ciphertext) (h : S.encapsulateP rand keys payload = some (derivedKeys, ct)) :
                  ct.kemCiphertexts.length = keys.length ∧ ct.deks.length = keys.length ∧ derivedKeys.length = keys.length ∧ (∀ (d : ByteArray), d ∈ ct.deks → d.size = S.aead.nonceSize + S.aead.keySize + S.aead.tagSize) ∧ ct.envelope.size = payload.size + (S.aead.nonceSize + S.aead.tagSize)

                  One KEM ciphertext, one nonce + key + tag-byte DEK and one derived key per recipient, and an envelope nonce + tag longer than the payload.

                  theorem Cryptlib.Primitives.MultiRecipientHybrid.Adapter.Base.decapsulateP_forRecipient (S : Base) (rand : Rand S) (hrel : S.RandReliable rand) (keys : List S.kem.PublicKey) (payload : ByteArray) (hlen : rand.kemSeeds.length = keys.length) (hlen' : rand.dekNonces.length = keys.length) (derivedKeys : List ByteArray) (ct : MultiRecipientHybrid.Ciphertext S.kem.Ciphertext) (henc : S.encapsulateP rand keys payload = some (derivedKeys, ct)) (i : Nat) (hi : i < keys.length) (sk : S.kem.PrivateKey) (hsk : keys[i] = S.kem.derivePublicKey sk) (k : ByteArray) (hk : derivedKeys[i]? = some k) :
                  S.decapsulateP sk (ct.forRecipient i) = some (k, payload)

                  If its KEM seed is Reliable, recipient i recovers the payload and its derived key from the ciphertext carrying only its KEM ciphertext and DEK.

                  Replies #

                  Equations
                  Instances For
                    Equations
                    Instances For

                      The MultiRecipientHybrid instance #

                      Randomness for encapsulating to n recipients, from stream position i: message key, envelope nonce, then one DEK nonce and one KEM seed per recipient.

                      Equations
                      • One or more equations did not get rendered due to their size.
                      Instances For
                        Equations
                        • One or more equations did not get rendered due to their size.
                        Instances For
                          Equations
                          • One or more equations did not get rendered due to their size.
                          Instances For
                            Equations
                            • One or more equations did not get rendered due to their size.
                            Instances For

                              MultiRecipientHybrid over the given KEM, AEAD and hash.

                              Equations
                              • One or more equations did not get rendered due to their size.
                              Instances For

                                MultiRecipientHybrid over a KEM, an AEAD, and a hash whose digest is an AEAD key.

                                Equations
                                Instances For