Documentation

Cryptlib.Primitives.KEM.Adapter

NIKE to KEM adapter: hashed ElGamal #

ENCAPSULATE(pk_static):
    eph_sk, eph_pk := GEN_KEYPAIR(RNG)
    ss             := DH(eph_sk, pk_static)
    ct             := ENCODE_PUBKEY(eph_pk)
    shared_key     := KEYED(deriveKey(ss), ENCODE(pk_static) || ENCODE(eph_pk))
    return ct, shared_key

DECAPSULATE(sk_static, ct):
    eph_pk     := DECODE_PUBKEY(ct)
    ss         := DH(sk_static, eph_pk)
    shared_key := KEYED(deriveKey(ss), ENCODE(pub(sk_static)) || ENCODE(eph_pk))
    return shared_key

The key is a PRF keyed by ss over the static key then the ephemeral key. Encapsulation and decapsulation reject public keys that are not NIKE.Safe.

Shared-key derivation: derive ss pkStatic pkEph outLen returns outLen bytes.

Instances For
    @[reducible, inline]

    Counter plus an inexhaustible seed stream.

    Equations
    Instances For

      Initial state over a caller-supplied seed stream, which must be unpredictable.

      Equations
      Instances For

        The shared key: the PRF over the static then ephemeral public key, at the NIKE's shared-secret width.

        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

              nextSeed advances the counter by exactly one and leaves the stream alone.

              theorem Cryptlib.Primitives.KEM.Adapter.encap_seeds_distinct (i : Nat) (str : Nat → Bytes32) (hinj : ∀ (m n : Nat), m ≠ n → str m ≠ str n) :
              str i ≠ str (i + 1)

              Consecutive encapsulations use different seeds if the stream is injective.

              theorem Cryptlib.Primitives.KEM.Adapter.roundTrip (F : PRF) (nike : NIKE.NIKE.NIKE) (sk : nike.PrivateKey) (s : St) :
              True → ∀ (c : nike.PublicKey) (k : Vector UInt8 nike.sharedSecretSize) (s' : St), encapM F nike (nike.derivePublicKey sk) s = EStateM.Result.ok (c, k) s' → ∀ (t : St), ∃ (t' : St), decapM F nike sk c t = EStateM.Result.ok k t'

              Decapsulation recovers the encapsulated key for derivePublicKey sk. The True hypothesis is kemOfNike's Reliable.

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