ElGamal and Hashed ElGamal encryption and IND-CPA security under DDH #
Over a PrimeOrderGroupFamily, multiplicative ElGamal encryption ([BS23],
Exercise 11.5, p. 459) uses a group description d, a secret exponent α : ZMod (F.order d),
and the public key u = α • g.
To encrypt a group element m : F.Carrier d with randomness β : ZMod (F.order d), the sender
forms the ciphertext (v, e) = (β • g, β • u + m) = (β • g, (α * β) • g + m). Decryption recovers
e - α • v = m, and the word-level operations encodeElGamalPublicKey, encodeElGamalEncrypt,
and decodeElGamal compute public-key generation, encryption, and decryption in polynomial time
from natural-number exponents and encoded group elements using F.generator, F.order, F.smul,
and F.add.
We prove IND-CPA security under DDH in the following settings:
- Shared typed-message ElGamal reduction (
elGamalMsgCPAGameOn,elGamalMsgToDDHDistinguisher,advantage_elGamalMsgCPAGameOn_le,isPPTOn_elGamalMsgToDDHDistinguisher,DDH.negligible_elGamalMsgCPAGameOn). As inEncryption.gameOn, a challenge-pair admissibility predicatevalid : ℕ → List Bool → Msg → Msg → Boolsees the security parameter and the public key, and an inadmissible pair makes the game outputfalsein both experiments. The reduction needsvalidto be computable in polynomial time and to admit only messages whose encodings are group elements (AdmitsGroupElements). It is instantiated for:- Bit ElGamal (
elGamalCPAGame,elGamalINDCPA,DDH.elGamalINDCPA):falseandtrueare embedded as0andg(bitElement,encodeBit), every pair is admissible, andEncryption.Adversarychooses two challenge bits. - Group-element ElGamal (
Encryption.WordAdversary,elGamalGroupCPAGameOn,DDH.negligible_elGamalGroupCPAGameOn, [BS23], Exercise 11.5(a), p. 459): a two-stage word-message adversary chooses two words, andvalidadmits only encoded group elements, inSet.range (F.encode d). Replacing the Diffie–Hellman mask(α * β) • gwith an independent uniformγ • gmasks any admissible pair perfectly (uniform_smul_generator_add). APrimeOrderGroupFamilyhas no membership test, sovalidis a parameter; the tests instantiate it on Schnorr groups.
- Bit ElGamal (
- Hashed ElGamal (
hashedElGamalEncrypt,hashedElGamalDecrypt,hashedElGamalCPAGame,DDH.negligible_hashedElGamalCPAGame, [BS23], Section 11.5, pp. 445–446, Remark 11.1, and Section 11.5.2, Attack Game 11.3, Definition 11.5, and Theorem 11.5, pp. 448–451): given a deterministic polynomial-time key-derivation hash functionH : F.Desc × List Bool → List Bool, the sender masks a message wordmwithpad = H (d, encode (β • u))viaCslib.BitString.listXor pad.length [pad, m](the one-time pad specialization of theE'_EGvariant of Remark 11.1). Security reduces toDDHtogether with key-derivation security (SecureKDF, Attack Game 11.3, p. 448, and Definition 11.5, p. 449: indistinguishability ofH (d, encode (γ • g))from a uniformmsgLen n-bit key). The ciphertext length does not depend on the message, andhashedElGamalCPAGameadmits every challenge pair, which is stronger than Attack Game 11.1's equal-length rule.
Limitations #
In this module, key generation and challenge encryption in the security games sample exact uniform
exponents in ZMod (F.order d) at the PMF level (PMF.uniformOfFintype (ZMod (F.order d))),
because an odd prime order F.order d cannot be sampled with exact uniformity by a bounded-time
fair-coin ProbComp machine; deterministic public-key computation (encodeElGamalPublicKey),
encryption given randomness (encodeElGamalEncrypt, encodeHashedElGamalEncrypt), and decryption
(decodeElGamal, decodeHashedElGamal) are certified polynomial time on words. Strict-PPT
(IsPPTOn) key generation, KEM encapsulation/decapsulation, and encryption via
ProbComp.sampleModNat (connecting to Encryption.KEMINDCPA, Encryption.INDCPAOn,
Encryption.WordINDCPA, and Encryption.INDCPA) are provided in
Complexity/Crypto/Computational/ElGamal/ProbComp.lean; non-degenerate SecureKDF instantiation
(msgLen n > 0) via BitString.LinearHash and the leftover hash lemma is provided in
Complexity/Crypto/Computational/ElGamal/KDF.lean.
Main definitions #
Cslib.Crypto.PrimeOrderGroupFamily.elGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecrypt: algebraic ElGamal encryption and decryption.Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalPublicKey,Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal: polynomial-time public-key generation, encryption, and decryption on encoded group elements.Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgCPAGameOn,Cslib.Crypto.PrimeOrderGroupFamily.elGamalMsgToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.AdmitsGroupElements: shared typed-message ElGamal IND-CPA experiment with an admissibility predicate, DDH reduction, and the condition that the predicate admits only group elements ([BS23], Exercise 11.5(a), p. 459).Cslib.Crypto.PrimeOrderGroupFamily.bitElement,Cslib.Crypto.PrimeOrderGroupFamily.encodeBit: embedding and polynomial-time encoding of message bits as group elements.Cslib.Crypto.PrimeOrderGroupFamily.elGamalCPAGame,Cslib.Crypto.PrimeOrderGroupFamily.elGamalINDCPA,Cslib.Crypto.PrimeOrderGroupFamily.elGamalToDDHDistinguisher: bit ElGamal IND-CPA experiment, security property, and DDH distinguisher.Cslib.Crypto.PrimeOrderGroupFamily.elGamalGroupCPAGameOn,Cslib.Crypto.PrimeOrderGroupFamily.elGamalGroupToDDHDistinguisher: group-element ElGamal IND-CPA experiment and DDH reduction ([BS23], Exercise 11.5(a), p. 459).Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalDecrypt,Cslib.Crypto.PrimeOrderGroupFamily.encodeHashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.decodeHashedElGamal: algebraic and word-level Hashed ElGamal encryption and decryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1).Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalCPAGame,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalIdealDDHGame,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalUniformPadGame,Cslib.Crypto.PrimeOrderGroupFamily.kdfRealGame,Cslib.Crypto.PrimeOrderGroupFamily.kdfIdealGame,Cslib.Crypto.PrimeOrderGroupFamily.SecureKDF,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalToKDFDistinguisher: Hashed ElGamal IND-CPA experiments, hybrids, and reductions ([BS23], Section 11.5.2, Attack Game 11.3, Definition 11.5, and Theorem 11.5, pp. 448–451).
Main results #
Cslib.Crypto.PrimeOrderGroupFamily.elGamalDecrypt_elGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalPublicKey_eq_encode,Cslib.Crypto.PrimeOrderGroupFamily.encodeElGamalEncrypt_encode,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_encode,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_elGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.decodeElGamal_encodeElGamalEncrypt: ElGamal correctness.Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_encodeElGamalPublicKey,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_encodeElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_decodeElGamal: polynomial-time certificates for honest ElGamal operations.Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalMsgCPAGameOn_le,Cslib.Crypto.PrimeOrderGroupFamily.isPPTOn_elGamalMsgToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalMsgCPAGameOn: shared typed-message ElGamal IND-CPA reduction to DDH.Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalCPAGame_le,Cslib.Crypto.PrimeOrderGroupFamily.isPPTOn_elGamalToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.DDH.elGamalINDCPA: ElGamal IND-CPA security for bit messages under DDH ([BS23], Exercise 11.5(a), p. 459).Cslib.Crypto.PrimeOrderGroupFamily.advantage_elGamalGroupCPAGameOn_le,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_elGamalGroupCPAGameOn: ElGamal IND-CPA security for group-element messages under DDH ([BS23], Exercise 11.5(a), p. 459).Cslib.Crypto.PrimeOrderGroupFamily.hashedElGamalDecrypt_hashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_encodeHashedElGamalEncrypt,Cslib.Crypto.PrimeOrderGroupFamily.computableInPolyTime_decodeHashedElGamal,Cslib.Crypto.PrimeOrderGroupFamily.advantage_hashedElGamalCPAGame_le,Cslib.Crypto.PrimeOrderGroupFamily.isPPTOn_hashedElGamalToDDHDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.isPPTOn_hashedElGamalToKDFDistinguisher,Cslib.Crypto.PrimeOrderGroupFamily.DDH.negligible_hashedElGamalCPAGame: Hashed ElGamal correctness, polynomial-time certificates, and IND-CPA security under DDH andSecureKDF([BS23], Section 11.5.2, Theorem 11.5, pp. 449–451).
References #
- D. Boneh, V. Shoup, A Graduate Course in Applied Cryptography, Version 0.6, Section 11.5 (pp. 445–446, Remark 11.1), Section 11.5.2 (pp. 448–451, Attack Game 11.3, Definition 11.5, Theorem 11.5), and Exercise 11.5(a) (p. 459).
Group-element ElGamal encryption and decryption #
Algebraic ElGamal encryption of a group element m : F.Carrier d under public key
u : F.Carrier d with randomness β : ZMod (F.order d).
Instances For
Under a genuine public key u = α • g, the second ciphertext component is
(α * β) • g + m.
ElGamal decryption correctness: decrypting an encryption under u = α • g with secret key
α recovers the message m.
Word-level ElGamal public-key computation: given (d, a), compute encode ((a : ZMod q) • g)
as F.smul (d, a, F.encode d (F.generator d)).
Instances For
encodeElGamalPublicKey computes the group encoding of (a : ZMod (F.order d)) • g.
Word-level ElGamal public-key computation is computable in polynomial time.
encodeElGamalEncrypt evaluates elGamalEncrypt on encoded group elements.
Word-level ElGamal encryption is computable in polynomial time.
Decryption on encoded group elements: given (d, a, encode v, encode e), compute
encode (e - a • v) as F.add (d, encode e, F.smul (d, F.order d - a % F.order d, encode v)).
Instances For
decodeElGamal computes encode (elGamalDecrypt d a (v, e)) on encoded group elements.
Encoded ElGamal decryption of an honest encryption recovers the encoded message.
Word-level ElGamal decryption of encodeElGamalEncrypt under encodeElGamalPublicKey recovers
the encoded message.
Encoded ElGamal decryption is computable in polynomial time.
The IND-CPA experiment for multiplicative ElGamal encryption over message type Msg via a
word-level message encoder encodeMsg : F.Desc → Msg → List Bool, with challenge-pair
admissibility predicate valid ([BS23], Exercise 11.5(a), p. 459, played in Attack
Game 11.1, p. 436): draw d ← setup n and a uniform secret key α : ZMod (F.order d), and pass
the encoded public key pk = (d, encode (α • g)) to adversary.choose. If
valid n pk m₀ m₁ holds, encrypt the selected message m under a fresh uniform exponent
β : ZMod (F.order d) via F.add (d, encode ((α * β) • g), encodeMsg d m) and pass the saved
state and encoded ciphertext to adversary.guess; otherwise output false, in both experiments,
as Encryption.gameOn does.
Instances For
The DDH distinguisher constructed from a typed-message ElGamal IND-CPA adversary
([BS23], Exercise 11.5(a), p. 459): given (d, u, v, w), pass pk = (d, u) as the
public key; if valid n pk m₀ m₁ holds, mask the selected encoded message encodeMsg d m with w
using F.add and return the adversary's guess, and otherwise return false.
Instances For
In the real DDH game, elGamalMsgToDDHDistinguisher simulates elGamalMsgCPAGameOn
exactly.
The admissibility predicate valid admits only group elements under encodeMsg: at every
public key (d, u), an admissible pair (m₀, m₁) has both encodeMsg d m₀ and encodeMsg d m₁
in Set.range (F.encode d).
Instances For
When valid admits only group elements under encodeMsg, the uniform element γ • g of the
ideal DDH game perfectly masks both admissible candidate messages, so the experiments for
bit = false and bit = true are identical.
Quantitative reduction of typed-message ElGamal IND-CPA to DDH ([BS23],
Exercise 11.5(a), p. 459): when valid admits only group elements under encodeMsg, the IND-CPA
distinguishing advantage of adversary is bounded by the sum of the DDH advantages of
elGamalMsgToDDHDistinguisher valid encodeMsg adversary false and
elGamalMsgToDDHDistinguisher valid encodeMsg adversary true.
elGamalMsgToDDHDistinguisher is uniform strict PPT whenever valid and encodeMsg are
computable in polynomial time and adversary is uniform strict PPT.
Typed-message ElGamal encryption is IND-CPA secure under the DDH assumption
([BS23], Exercise 11.5(a), p. 459): for a polynomial-time admissibility predicate valid
that admits only group elements under encodeMsg, every uniform strict PPT adversary has
negligible advantage in elGamalMsgCPAGameOn valid encodeMsg.
Bit encryption and IND-CPA security under DDH #
Embed a message bit b : Bool into F.Carrier d as 0 (for false) or g (for true).
Instances For
Distinct message bits map to distinct group elements.
Encode a message bit b : Bool as an encoded element of F.Carrier d using F.smul.
Instances For
encodeBit computes the group encoding of bitElement.
Every pair of bit messages encodes group elements, so the always-true predicate admits only
group elements under encodeBit.
encodeBit is computable in polynomial time from the group description and the bit.
The IND-CPA experiment for ElGamal bit encryption ([BS23], Exercise 11.5, p. 459):
draw d from setup n and a uniform secret key α : ZMod (F.order d), pass the encoded public
key (d, encode (α • g)) to adversary.choose, encrypt the selected challenge bit under a fresh
uniform exponent β : ZMod (F.order d), and pass the saved state and encoded ciphertext to
adversary.guess.
Instances For
elGamalCPAGame is the unrestricted encodeBit specialization of elGamalMsgCPAGameOn.
IND-CPA security of ElGamal bit encryption over F for a setup law setup: every uniform
strict PPT Encryption.Adversary has negligible distinguishing advantage between challenge bit
false and challenge bit true.
Instances For
The DDH distinguisher constructed from an IND-CPA adversary ([BS23], proof of
Exercise 11.5(a), p. 459): given (d, u, v, w), pass (d, u) as the public key, encrypt the
selected challenge bit by masking with w, and return the adversary's guess.
Instances For
In the real DDH game, elGamalToDDHDistinguisher simulates elGamalCPAGame exactly.
In the ideal DDH game, the uniform element γ • g perfectly masks the challenge bit, so the
experiments for bit = false and bit = true are identical.
Quantitative reduction of ElGamal IND-CPA to DDH ([BS23], Exercise 11.5(a),
p. 459): the IND-CPA distinguishing advantage of adversary is bounded by the sum of the DDH
advantages of elGamalToDDHDistinguisher adversary false and
elGamalToDDHDistinguisher adversary true.
elGamalToDDHDistinguisher is uniform strict PPT whenever adversary is.
ElGamal bit encryption is IND-CPA secure under the DDH assumption ([BS23], Exercise 11.5(a), p. 459).
Group-element ElGamal IND-CPA security under DDH #
The IND-CPA experiment for group-element ElGamal encryption with challenge-pair admissibility
predicate valid ([BS23], Exercise 11.5(a), p. 459): specialization of
elGamalMsgCPAGameOn to word messages (Encryption.WordAdversary) with identity message
encoding. The message space of Exercise 11.5 is the group, so valid is meant to admit only
encoded group elements (AdmitsGroupElements (fun _ m => m) valid).
Instances For
The DDH distinguisher constructed from a group-element ElGamal IND-CPA adversary
([BS23], Exercise 11.5(a), p. 459): specialization of elGamalMsgToDDHDistinguisher to
identity message encoding.
Instances For
Quantitative reduction of group-element ElGamal IND-CPA to DDH ([BS23],
Exercise 11.5(a), p. 459): when valid admits only encoded group elements, the IND-CPA
distinguishing advantage of adversary is bounded by the sum of the DDH advantages of
elGamalGroupToDDHDistinguisher valid adversary false and
elGamalGroupToDDHDistinguisher valid adversary true.
Group-element ElGamal encryption is IND-CPA secure under the DDH assumption
([BS23], Exercise 11.5(a), p. 459): for a polynomial-time admissibility predicate valid
that admits only encoded group elements, every uniform strict PPT Encryption.WordAdversary has
negligible advantage in elGamalGroupCPAGameOn valid.
Algebraic Hashed ElGamal encryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1):
given key-derivation hash function H : F.Desc × List Bool → List Bool, public key
u : F.Carrier d, message word m : List Bool, and randomness β : ZMod (F.order d), derive
pad = H (d, encode (β • u)) and output
(β • g, Cslib.BitString.listXor pad.length [pad, m]).
Instances For
Under a genuine public key u = α • g, Hashed ElGamal masks m with
pad = H (d, encode ((α * β) • g)) via Cslib.BitString.listXor pad.length [pad, m].
Algebraic Hashed ElGamal decryption ([BS23], Section 11.5, pp. 445–446, Remark 11.1):
given secret key α : ZMod (F.order d) and ciphertext (v, c), derive
pad = H (d, encode (α • v)) and recover Cslib.BitString.listXor pad.length [pad, c].
Instances For
Hashed ElGamal decryption correctness: when the message word m has the same length as the
derived pad H (d, encode ((α * β) • g)), decrypting an encryption under u = α • g with secret
key α recovers m.
Word-level Hashed ElGamal encryption: given (d, encode u, m, b), derive
pad = H (d, encode (b • u)) and compute
(encode (b • g), Cslib.BitString.listXor pad.length [pad, m]).
Instances For
encodeHashedElGamalEncrypt evaluates hashedElGamalEncrypt on encoded group elements.
Word-level Hashed ElGamal encryption is computable in polynomial time whenever H is.
Word-level Hashed ElGamal decryption: given (d, a, encode v, c), derive
pad = H (d, encode (a • v)) and compute Cslib.BitString.listXor pad.length [pad, c].
Instances For
decodeHashedElGamal computes hashedElGamalDecrypt on encoded group elements.
Word-level Hashed ElGamal decryption of an honest encryption recovers m whenever m has the
same length as the derived pad.
Word-level Hashed ElGamal decryption is computable in polynomial time whenever H is.
The IND-CPA experiment for Hashed ElGamal encryption ([BS23], Section 11.5,
pp. 445–446, Remark 11.1, and Section 11.5.2, Theorem 11.5, pp. 449–451): draw d ← setup n and a
uniform secret key α : ZMod (F.order d), pass the encoded public key (d, encode (α • g)) to
adversary.choose, encrypt the selected message word m under a fresh uniform exponent
β : ZMod (F.order d) by masking with pad = H (d, encode ((α * β) • g)) via
Cslib.BitString.listXor pad.length [pad, m], and pass the saved state and encoded ciphertext to
adversary.guess.
Instances For
Hybrid 1 for Hashed ElGamal ([BS23], Section 11.5.2, proof of Theorem 11.5,
pp. 449–451): replace the Diffie–Hellman shared element (α * β) • g with an independent uniform
group element γ • g.
Instances For
Hybrid 2 for Hashed ElGamal ([BS23], Section 11.5.2, proof of Theorem 11.5,
pp. 449–451): replace the derived key H (d, encode (γ • g)) with an independent uniform
msgLen n-bit key pad ← Cslib.BitString.uniformList (msgLen n).
Instances For
The real key-derivation security experiment ([BS23], Section 11.5.2, Attack Game 11.3,
Experiment 0, p. 448): draw d ← setup n and independent uniform α, β, γ : ZMod (F.order d),
and give the distinguisher (d, encode (α • g), encode (β • g), H (d, encode (γ • g))).
Instances For
The ideal key-derivation security experiment ([BS23], Section 11.5.2,
Attack Game 11.3, Experiment 1, p. 448): draw d ← setup n, independent uniform
α, β : ZMod (F.order d), and an independent uniform msgLen n-bit key
pad ← Cslib.BitString.uniformList (msgLen n), and give the distinguisher
(d, encode (α • g), encode (β • g), pad).
Instances For
Secure key derivation for H over F ([BS23], Section 11.5.2, Attack Game 11.3,
p. 448, and Definition 11.5, p. 449): every uniform strict PPT distinguisher has negligible
advantage between kdfRealGame and kdfIdealGame. No nondegenerate SecureKDF instance
(msgLen n > 0, e.g., via the leftover hash lemma) is constructed in this module.
Instances For
The DDH distinguisher constructed from a Hashed ElGamal IND-CPA adversary ([BS23],
Section 11.5.2, proof of Theorem 11.5, pp. 449–451): given (d, u, v, w), pass (d, u) as the
public key, mask the selected message word with pad = H (d, w) via
Cslib.BitString.listXor pad.length [pad, m], and return the adversary's guess.
Instances For
In the real DDH game, hashedElGamalToDDHDistinguisher simulates hashedElGamalCPAGame
exactly.
In the ideal DDH game, hashedElGamalToDDHDistinguisher simulates hashedElGamalIdealDDHGame
exactly.
hashedElGamalToDDHDistinguisher is uniform strict PPT whenever H is polynomial time and
adversary is uniform strict PPT.
The KDF distinguisher constructed from a Hashed ElGamal IND-CPA adversary ([BS23],
Section 11.5.2, proof of Theorem 11.5, pp. 449–451): given (d, u, v, pad), pass (d, u) as the
public key, mask the selected message word with pad via
Cslib.BitString.listXor pad.length [pad, m], and return the adversary's guess.
Instances For
In the real KDF game, hashedElGamalToKDFDistinguisher simulates hashedElGamalIdealDDHGame
exactly.
In the ideal KDF game, hashedElGamalToKDFDistinguisher simulates
hashedElGamalUniformPadGame exactly.
hashedElGamalToKDFDistinguisher is uniform strict PPT whenever adversary is.
In hashedElGamalUniformPadGame, the uniform msgLen n-bit pad masks any challenge message
word perfectly via Cslib.BitString.listXor pad.length [pad, m], so the experiments for
bit = false and bit = true are identical.
Quantitative reduction of Hashed ElGamal IND-CPA to DDH and SecureKDF
([BS23], Section 11.5.2, Theorem 11.5, pp. 449–451): the IND-CPA distinguishing
advantage of adversary is bounded by the sum of the two DDH advantages of
hashedElGamalToDDHDistinguisher and the two KDF advantages of
hashedElGamalToKDFDistinguisher.
Hashed ElGamal encryption is IND-CPA secure under DDH and SecureKDF
([BS23], Section 11.5.2, Theorem 11.5, pp. 449–451): when H is computable in
polynomial time, every uniform strict PPT Encryption.WordAdversary has negligible IND-CPA
distinguishing advantage. Note that SecureKDF is assumed as a hypothesis; no nondegenerate
SecureKDF instance (msgLen n > 0) is constructed in this module.