Skip to content

feat(crypto): efficient DDH random self-reduction, group-element ElGamal, and hashed ElGamal (#640 Track C) #1047

Open

Description

@SamuelSchlesinger

Part of #640 (Track C)

Scope

Complete the remaining non-CCA items in the Diffie–Hellman and ElGamal bullet of ROADMAP.md (#640 Track C) in Complexity/Crypto/Computational/DiffieHellman.lean and Complexity/Crypto/Computational/ElGamal.lean:

  1. Efficient DDH random self-reduction ([BonehShoup2023], Exercise 10.10) in DiffieHellman.lean:
    • Word-level polynomial-time evaluation encodeDDHRerandomize on encoded triples (d, (u, v, w), r, s₁, s₂), correctness encodeDDHRerandomize_encode, and plain polynomial-time certificate computableInPolyTime_encodeDDHRerandomize.
    • ddhRerandomizeGame and worst-case-to-average-case reductions ddhRerandomizeGame_real and ddhRerandomizeGame_ideal connecting encodeDDHRerandomize to ddhRealGame and ddhIdealGame, together with isPPTOn admissibility of the re-randomizing distinguisher.
  2. Efficient ElGamal key generation and encryption, and group-element ElGamal IND-CPA ([BonehShoup2023], Exercise 11.5(a)) in ElGamal.lean:
    • Word-level public-key generation encodeElGamalPublicKey and encryption encodeElGamalEncrypt, round-trip correctness decodeElGamal_encodeElGamalEncrypt, and plain polynomial-time certificates computableInPolyTime_encodeElGamalPublicKey and computableInPolyTime_encodeElGamalEncrypt.
    • Group-element IND-CPA experiment (ElGamalGroupAdversary, elGamalGroupCPAGame, elGamalGroupINDCPA), DDH reduction elGamalGroupToDDHDistinguisher, quantitative bound advantage_elGamalGroupCPAGame_le, isPPTOn_elGamalGroupToDDHDistinguisher, and asymptotic theorem DDH.elGamalGroupINDCPA.
  3. Hashed ElGamal ([BonehShoup2023], Section 11.4, Theorem 11.1) in ElGamal.lean:
    • Algebraic and word-level Hashed ElGamal encryption and decryption over BitString (ℓ n) (hashedElGamalEncrypt, hashedElGamalDecrypt, encodeHashedElGamalEncrypt, decodeHashedElGamal), decryption correctness, and plain polynomial-time certificates.
    • Chosen-plaintext experiment hashedElGamalCPAGame, DDH + hash-smoothing hybrid reduction (advantage_hashedElGamalCPAGame_le), uniform strict-PPT certificates for both reduction distinguishers, and asymptotic IND-CPA security DDH.hashedElGamalINDCPA.
  4. Tests and documentation:
    • Concrete Schnorr-group checks in ComplexityTests/Crypto/DiffieHellman.lean and update ROADMAP.md.

Activity

  1. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Claiming #1047 as worker (worker-jetski-cf53d356, session cf53d356-5fb3-4f07-ba5d-5249ddbd9dba).

    • State: active
    • Branch / Worktree: feat/elgamal-ddh-extensions-1047 (.worktrees/wt-jetski-cf53d356-1047)
  2. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status (worker-jetski-cf53d356): awaiting review in #1053 at 239ae611.

    Implemented and validated:

    • Complexity/Crypto/Computational/DiffieHellman.lean: encodeDDHRerandomize, computableInPolyTime_encodeDDHRerandomize, ddhSampleOrderBitExponents, isPPTOn_ddhSampleOrderBitExponents, ddhSampleSelfReduce, isPPTOn_ddhSampleSelfReduce, ddhSelfReduceDistinguisher, isPPTOn_ddhSelfReduceDistinguisher, ddhRerandomizeGame, ddhRerandomizeGame_real, ddhRerandomizeGame_ideal, advantage_ddhRerandomizeGame_eq, DDH.ddhRerandomizeGame, ddhWorstCaseGame, advantage_ddhRealGame_le_ddhWorstCaseGame, and ddh_of_worstCase.
    • Complexity/Crypto/Computational/ElGamal.lean:
      • Efficient word-level ElGamal operations: encodeElGamalPublicKey, computableInPolyTime_encodeElGamalPublicKey, encodeElGamalEncrypt, computableInPolyTime_encodeElGamalEncrypt, decodeElGamal_encodeElGamalEncrypt.
      • Group-element ElGamal IND-CPA: WordAdversary, WordAdversary.IsPPT, ValidGroupMessages, elGamalGroupCPAGame, elGamalGroupToDDHDistinguisher, advantage_elGamalGroupCPAGame_le, isPPTOn_elGamalGroupToDDHDistinguisher, DDH.negligible_elGamalGroupCPAGame.
      • Hashed ElGamal IND-CPA: hashedElGamalEncrypt, hashedElGamalDecrypt, encodeHashedElGamalEncrypt, decodeHashedElGamal, hashedElGamalCPAGame, HashSmoothing, hashedElGamalToDDHDistinguisher, hashedElGamalToHashDistinguisher, advantage_hashedElGamalCPAGame_le, DDH.negligible_hashedElGamalCPAGame.
    • ComplexityTests/Crypto/DiffieHellman.lean and ROADMAP.md.
  3. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status: active (worker-jetski-cf53d356, session cf53d356-5fb3-4f07-ba5d-5249ddbd9dba).

    Addressing the review findings from reviewer-claude-c4b0c164-46 on PR #1053 (https://github.com/cslib-community/complexitylib/pull/1053#issuecomment-6399732971).

  4. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Agent: worker-jetski-cf53d356 (session cf53d356-5fb3-4f07-ba5d-5249ddbd9dba)
    State: awaiting review
    PR: #1053 (updated head d8613a17eb89d60c240f790c67981d18d52c27c2)
    Summary: Addressed all 10 review findings on PR #1053; full ./scripts/check.sh and scripts/check_hygiene.py pass. Requesting fresh coordinator/reviewer review.

  5. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Agent: worker-jetski-cf53d356 (session cf53d356-5fb3-4f07-ba5d-5249ddbd9dba)
    Status: active
    Branch: feat/elgamal-ddh-extensions-1047 (PR #1053)
    Next step: Addressing the 4 blocking and 3 non-blocking delta-review findings from reviewer-claude-c4b0c164-54 on PR #1053.

  6. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-jetski-cf53d356, session cf53d356-5fb3-4f07-ba5d-5249ddbd9dba):

  7. SamuelSchlesinger commented on Oct 25, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status update (worker-jetski-cf53d356, session cf53d356-5fb3-4f07-ba5d-5249ddbd9dba):

    • State: active
    • Next step: Addressing the review feedback on PR feat(crypto): efficient DDH self-reduction, group-element ElGamal, and hashed ElGamal (#1047) #1053 (https://github.com/cslib-community/complexitylib/pull/1053): rebasing onto origin/main (keeping both uniformList_map_zipWith_xor and uniformList_map_listXor_length in Probability/BitString/List.lean), addressing the WordINDCPA equal-length / admissibility item in Encryption/Basic.lean, updating the PR description with Refs #1047 and verbatim Boneh–Shoup v0.6 quotes, and fixing the remaining nits.
  8. 4 remaining items

  9. SamuelSchlesinger commented on Oct 26, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Claiming the remaining open items of #1047 as worker-antigravity-20261024 (delegated by coordinator-claude-c4b0c164-20261023).

    • State: active (M0 design posted below; starting M1 implementation next)
    • Worktree: /home/samuel/Code/complexitylib-wt/agy-1000-etm-3

    M0 Design: Remaining Items of #1047 (Exercise 10.10 Worst-Case DDH Decider, Theorem 11.5 General-Cipher Hashed ElGamal, Non-Degenerate SecureKDF, and Strict-PPT KeyGen/Encryption)

    1. Pinned Source Quotations and Locators (Boneh–Shoup v0.6)

    All page numbers are verified against the printed page footers before \f in book.txt:

    1. Exercise 10.10 ([BonehShoup2023], Section 10.11, p. 426):

      10.10 (Random self-reduction for DDH (III)). Continuing with the previous exercise, prove the following. Suppose $\mathcal{A}$ is an efficient algorithm that takes as input three group elements and outputs a bit, and which satisfies the following property: if $\alpha, \beta, \gamma \in \mathbb{Z}_q$ are chosen at random, then
      $$\left|\Pr[\mathcal{A}(g^\alpha, g^\beta, g^{\alpha\beta}) = 1] - \Pr[\mathcal{A}(g^\alpha, g^\beta, g^\gamma) = 1]\right| = \epsilon,$$
      where the probability is over the random choice of $\alpha, \beta, \gamma$, as well as any random choices made by $\mathcal{A}$. Assuming that $1/\epsilon$ is poly-bounded, show how to use $\mathcal{A}$ to build an efficient algorithm $\mathcal{B}$ that for all inputs $(u, v, w)$ correctly decides whether or not $(u, v, w) \in \mathrm{DH}$ with negligible error probability. That is, adversary $\mathcal{B}$ may output an incorrect answer, but for all inputs, the probability that its answer is incorrect should be negligible.
      Hint: Use a Chernoff bound.

    2. Section 11.5 ($\mathcal{E}{\mathrm{EG}}$ construction, p. 445) and Remark 11.1 ($\mathcal{E}'{\mathrm{EG}}$ variant, p. 446):

      The encryption scheme is a variant of a scheme first proposed by ElGamal, and we call it $\mathcal{E}_{\mathrm{EG}}$. It is built out of several components:

      • a cyclic group $\mathbb{G}$ of prime order $q$ with generator $g \in \mathbb{G}$,
      • a symmetric cipher $\mathcal{E}_s = (E_s, D_s)$, defined over $(\mathcal{K}, \mathcal{M}, \mathcal{C})$,
      • a hash function $H : \mathbb{G}^2 \to \mathcal{K}$.

      The message space for $\mathcal{E}{\mathrm{EG}}$ is $\mathcal{M}$, and the ciphertext space is $\mathbb{G} \times \mathcal{C}$. We now describe the key generation, encryption, and decryption algorithms for $\mathcal{E}{\mathrm{EG}}$.

      • the key generation algorithm runs as follows:
        $$G() := \alpha \stackrel{R}{\leftarrow} \mathbb{Z}_q,\ u \leftarrow g^\alpha,\ pk \leftarrow u,\ sk \leftarrow \alpha,\ \text{output } (pk, sk);$$
      • for a given public key $pk = u \in \mathbb{G}$ and message $m \in \mathcal{M}$, the encryption algorithm runs as follows:
        $$E(pk, m) := \beta \stackrel{R}{\leftarrow} \mathbb{Z}_q,\ v \leftarrow g^\beta,\ w \leftarrow u^\beta,\ k \leftarrow H(v, w),\ c \leftarrow E_s(k, m),\ \text{output } (v, c);$$
      • for a given secret key $sk = \alpha \in \mathbb{Z}_q$ and a ciphertext $(v, c) \in \mathbb{G} \times \mathcal{C}$, the decryption algorithm runs as follows:
        $$D(sk, (v, c)) := w \leftarrow v^\alpha,\ k \leftarrow H(v, w),\ m \leftarrow D_s(k, c),\ \text{output } m.$$

      Remark 11.1 (Hashing $(v, w)$ vs hashing only $w$). In $\mathcal{E}{\mathrm{EG}}$, we derive the key $k$ by hashing both $v$ and $w$. In a variant, which we call $\mathcal{E}'{\mathrm{EG}}$, we could derive the key $k$ by hashing just $w$. The security results that we prove in this chapter hold for $\mathcal{E}'{\mathrm{EG}}$ as well as for $\mathcal{E}{\mathrm{EG}}$ (and the proofs carry over with little change). …

    3. Attack Game 11.3 (pp. 448–449), Definition 11.5 (p. 449), and Theorem 11.5 (pp. 449–451):

      Attack Game 11.3 (secure key derivation). For a given hash function $F : \mathcal{X} \times \mathcal{Y} \to \mathcal{Z}$, and for a given adversary $\mathcal{A}$, we define two experiments.
      Experiment $b$ ($b = 0, 1$):

      • The challenger computes
        $$x \stackrel{R}{\leftarrow} \mathcal{X},\quad y \stackrel{R}{\leftarrow} \mathcal{Y},\quad z_0 \leftarrow F(x, y),\quad z_1 \stackrel{R}{\leftarrow} \mathcal{Z},$$
        and sends $(x, z_b)$ to the adversary.
      • The adversary outputs a bit $\hat{b} \in {0, 1}$.

      If $W_b$ is the event that $\mathcal{A}$ outputs $1$ in Experiment $b$, then we define $\mathcal{A}$'s advantage with respect to $F$ as
      $$\mathrm{KDFadv}[\mathcal{A}, F] := |\Pr[W_0] - \Pr[W_1]|.$$

      Definition 11.5 (secure key derivation). A hash function $F : \mathcal{X} \times \mathcal{Y} \to \mathcal{Z}$ is a secure KDF if for every efficient adversary $\mathcal{A}$, the value $\mathrm{KDFadv}[\mathcal{A}, F]$ is negligible.
      …
      One may even build a secure KDF without making any assumptions at all: the construction in Section 8.10.4 based on a universal hash function and the leftover hash lemma yields an unconditionally secure KDF.

      Theorem 11.5. If the DDH assumption holds for $\mathbb{G}$, $H : \mathbb{G}^2 \to \mathcal{K}$ is a secure KDF, and $\mathcal{E}s$ is semantically secure, then $\mathcal{E}{\mathrm{EG}}$ is semantically secure.
      In particular, for every SS adversary $\mathcal{A}$ that plays Attack Game 11.1 with respect to $\mathcal{E}{\mathrm{EG}}$, there exist a DDH adversary $\mathcal{B}{\mathrm{ddh}}$ that plays Attack Game 10.6 with respect to $\mathbb{G}$, a KDF adversary $\mathcal{B}{\mathrm{kdf}}$ that plays Attack Game 11.3 with respect to $H$, and an SS adversary $\mathcal{B}s$ that plays Attack Game 2.1 with respect to $\mathcal{E}s$, where $\mathcal{B}{\mathrm{ddh}}$, $\mathcal{B}{\mathrm{kdf}}$, and $\mathcal{B}s$ are elementary wrappers around $\mathcal{A}$, such that
      $$\mathrm{SSadv}[\mathcal{A}, \mathcal{E}
      {\mathrm{EG}}] \le 2 \cdot \mathrm{DDHadv}[\mathcal{B}
      {\mathrm{ddh}}, \mathbb{G}] + 2 \cdot \mathrm{KDFadv}[\mathcal{B}_{\mathrm{kdf}}, H] + \mathrm{SSadv}[\mathcal{B}_s, \mathcal{E}_s]. \qquad (11.14)$$

    4. Theorem 8.11 (Leftover Hash Lemma, Section 8.10.4, p. 334):

      Theorem 8.11 (Leftover Hash Lemma). Let $H$ be a keyed hash function defined over $(\mathcal{K}, \mathcal{S}, \mathcal{T})$. Assume that $H$ is a $(1 + \alpha)/N$-UHF, where $N := |\mathcal{T}|$. Let $k, s_1, \dots, s_m$ be mutually independent random variables, where $k$ is uniformly distributed over $\mathcal{K}$, and each $s_i$ has guessing probability at most $\gamma$. Let $\delta$ be the statistical difference between
      $$(k, H(k, s_1), \dots, H(k, s_m))$$
      and the uniform distribution on $\mathcal{K} \times \mathcal{T}^m$. Then we have
      $$\delta \le \frac{1}{2} m \sqrt{N\gamma + \alpha}.$$


    2. Exact Statements & Architecture

    Part (a): Exercise 10.10 — Worst-Case DDH Decider via Chernoff Amplification (Complexity/Crypto/Computational/DiffieHellman.lean)

    We reuse the single-invocation random self-reduction from #1053 (encodeDDHRerandomize, ddhSampleModExponents, ddhSelfReduceDistinguisher, isPPTOn_ddhSelfReduceDistinguisher, ddhRerandomizeGame_real, ddhRerandomizeGame_ideal, advantage_ddhRerandomizeGame_ddhWorstCaseGame_le) together with the empirical success-counter and concentration infrastructure (OracleComp.countTrue, IsPPTOn.countTrue, ProbComp.countTrue_average_deviation_pow from Complexity/Languages/Probabilistic/Concentration.lean):

    • Reference tuples (ddhRealRefTuple, ddhIdealRefTuple):
      For any group description d : F.Desc, g := F.encode d (F.generator d) and z := F.smul (d, 0, g) encode $1 \cdot g$ and $0 \cdot g$:
      • F.ddhRealRefTuple d := (z, z, z) encodes the canonical DH triple $(0 \cdot g, 0 \cdot g, (0 \cdot 0) \cdot g) \in \mathrm{DH}$.
      • F.ddhIdealRefTuple d := (z, z, g) encodes the canonical non-DH triple $(0 \cdot g, 0 \cdot g, 1 \cdot g) \notin \mathrm{DH}$ (since $1 \ne 0 \cdot 0$ in $\mathbb{Z}_q$ for prime $q = \mathrm{F.order}(d)$).
        By ddhRerandomizeGame_real, ddhRerandomizeGame_ideal, and advantage_ddhRerandomizeGame_ddhWorstCaseGame_le specialized to setup := fun _ => PMF.pure d, a single trial of F.ddhSelfReduceDistinguisher distinguisher n on any encoded DH triple (d, encode (α • g), encode (β • g), encode ((α * β) • g)) has acceptance probability within $3 / 2^n$ of p_real(n, d) := (F.ddhRealGame (fun _ => PMF.pure d) distinguisher n true).toReal, and on any encoded non-DH triple (d, encode (α • g), encode (β • g), encode (γ • g)) ($\gamma \ne \alpha \beta$) has acceptance probability within $3 / 2^n$ of p_ideal(n, d) := (F.ddhIdealGame (fun _ => PMF.pure d) distinguisher n true).toReal.
    • Amplified worst-case decider (ddhAmplifiedDecider):
      noncomputable def ddhAmplifiedDecider
          (distinguisher : ℕ → F.Desc × List Bool × List Bool × List Bool → ProbComp Bool)
          (invEps : ℕ → ℕ) (n : ℕ)
          (input : F.Desc × List Bool × List Bool × List Bool) : ProbComp Bool := do
        let d := input.1
        let N := (n + 3) * (7 * invEps n) ^ 2
        let cIn ← OracleComp.countTrue N
          (F.ddhSelfReduceDistinguisher distinguisher n (d, input.2))
        let cReal ← OracleComp.countTrue N
          (F.ddhSelfReduceDistinguisher distinguisher n (d, F.ddhRealRefTuple d))
        let cIdeal ← OracleComp.countTrue N
          (F.ddhSelfReduceDistinguisher distinguisher n (d, F.ddhIdealRefTuple d))
        return decide ((cIn - cReal) + (cReal - cIn) ≤ (cIn - cIdeal) + (cIdeal - cIn))
    • Exact theorems:
      • isPPTOn_ddhAmplifiedDecider: uniform strict-PPT certificate when distinguisher is IsPPTOn and invEps is ComputableInPolyTime invEps encUnary encUnary.
      • ddhAmplifiedDecider_error_le_pow: for every $n$, $d$, and every $\alpha, \beta, \gamma \in \mathbb{Z}_q$, if 1 / (invEps n : ℝ) ≤ Game.advantage (F.ddhRealGame (fun _ => PMF.pure d) distinguisher n) (F.ddhIdealGame (fun _ => PMF.pure d) distinguisher n) and 3 / (2 ^ n : ℝ) ≤ 1 / (12 * (invEps n : ℝ)), then
        ((ProbComp.eval (F.ddhAmplifiedDecider distinguisher invEps n
          (d, F.encode d (α • F.generator d), F.encode d (β • F.generator d),
            F.encode d (γ • F.generator d)))).toOuterMeasure
          {b | b ≠ decide (γ = α * β)}).toReal ≤ (1 / 2 : ℝ) ^ n
      • negligible_ddhAmplifiedDecider_error: when invEps is computable in polynomial time (ComputableInPolyTime invEps encUnary encUnary) and 1 / (invEps n : ℝ) ≤ Game.advantage (F.ddhRealGame (fun _ => PMF.pure (d n)) distinguisher n) (F.ddhIdealGame (fun _ => PMF.pure (d n)) distinguisher n) holds eventually, for any worst-case family of inputs (d n, α n, β n, γ n), the error probability fun n => ((ProbComp.eval (F.ddhAmplifiedDecider distinguisher invEps n (d n, F.encode (d n) (α n • g), F.encode (d n) (β n • g), F.encode (d n) (γ n • g)))) (!decide (γ n = α n * β n))).toNNReal is Negligible.

    Part (b): Theorem 11.5 General-Cipher Hashed ElGamal, Non-Degenerate SecureKDF via Leftover Hash Lemma, and Strict-PPT KeyGen/Encryption (Complexity/Crypto/Computational/ElGamal.lean / ElGamal/Hashed.lean)

    1. General-cipher Hashed ElGamal ([BonehShoup2023], Section 11.5, p. 445, Remark 11.1, p. 446, and Theorem 11.5, pp. 449–451):
      • We support both the PMF-level security game over an arbitrary setup distribution setup : ℕ → PMF F.Desc and key length keyLen : ℕ → ℕ AND the native ProbComp-level KEM–DEM hybrid encryption Encryption.hybridEncrypt via Encryption.KEMINDCPA.hybrid_indcpaOn:
      • Symmetric cipher experiment at arbitrary key length keyLen : ℕ → ℕ:
        symCPAGameOn valid keyLen encryptSym adversary bit n : Game draws k ← BitString.uniformList (keyLen n) and runs the one-time symmetric experiment (agreeing with ProbComp.eval (Encryption.demGameOn valid encryptSym adversary bit n) when keyLen = id).
      • Hashed ElGamal with general symmetric cipher (encryptSym, decryptSym):
        • hashedElGamalCipherEncrypt H encryptSym n d u m β : ProbComp (F.Carrier d × List Bool) and hashedElGamalCipherDecrypt H decryptSym n d α ct : Msg, plus word-level encodeHashedElGamalCipherEncrypt and decodeHashedElGamalCipher, with round-trip correctness hashedElGamalCipherDecrypt_hashedElGamalCipherEncrypt and efficiency certificates isPPTOn_encodeHashedElGamalCipherEncrypt and computableInPolyTime_decodeHashedElGamalCipher.
        • Games 0, 1, 2 (hashedElGamalCipherCPAGameOn, hashedElGamalCipherIdealDDHGameOn, hashedElGamalCipherUniformKeyGameOn) with challenge-pair admissibility predicate valid : ℕ → List Bool → Msg → Msg → Bool.
        • Reductions: hashedElGamalCipherToDDHDistinguisher, hashedElGamalCipherToDDHHiddenBitDistinguisher, hashedElGamalCipherToKDFDistinguisher, hashedElGamalCipherToKDFHiddenBitDistinguisher, hashedElGamalCipherToSymAdversary, with IsPPTOn / AdversaryOf.IsPPT certificates.
        • Quantitative bounds:
          • advantage_hashedElGamalCipherCPAGameOn_le (two-distinguisher triangle bound)
          • advantage_hashedElGamalCipherCPAGameOn_le_two_mul (single hidden-bit distinguisher bound matching eq. (11.14) of Theorem 11.5: $\mathrm{SSadv} \le 2 \cdot \mathrm{DDHadv} + 2 \cdot \mathrm{KDFadv} + \mathrm{SSadv}[\mathcal{B}_s, \mathcal{E}_s]$).
        • Asymptotic theorem DDH.negligible_hashedElGamalCipherCPAGameOn: under F.DDH setup, F.SecureKDF setup H keyLen, and one-time semantic security of encryptSym (Encryption.DEMOneTimeINDCPAOn valid encMsg encryptSym for keyLen = id, or SymOneTimeINDCPAOn valid encMsg keyLen encryptSym for general keyLen), every uniform strict PPT Encryption.AdversaryOf Msg has negligible advantage.
        • Specialization bridge: when encryptSym is the XOR one-time pad (fun _ pad m => pure (BitString.listXor pad.length [pad, m])) and valid = fun _ _ _ _ => true, hashedElGamalCipherCPAGameOn reduces definitionally/propositionally to hashedElGamalCPAGame.
    2. Strict-PPT KeyGen, Encryption, and KEMINDCPA / Encryption.INDCPAOn Bridge:
      • Given a strict-PPT group setup sampler genDesc : ℕ → ProbComp F.Desc:
        • elGamalKeyGen genDesc (n : ℕ) : ProbComp (List Bool × List Bool): samples d ← genDesc n and a ← ProbComp.sampleModNat ((F.order d).size + n) (F.order d), returning (encPair F.encDesc encBits (d, F.encodeElGamalPublicKey (d, a)), encPair F.encDesc encNat (d, a)), certified by isPPTOn_elGamalKeyGen.
        • hashedElGamalEncaps H (n : ℕ) (pk : List Bool) : ProbComp (List Bool × List Bool) and hashedElGamalDecaps H (n : ℕ) (sk ctKem : List Bool) : List Bool, certified by isPPTOn_hashedElGamalEncaps, computableInPolyTime_hashedElGamalDecaps, and hashedElGamalDecaps_hashedElGamalEncaps.
        • DDH.kemINDCPA_hashedElGamalEncaps: under F.DDH (fun n => ProbComp.eval (genDesc n)) and F.SecureKDF (fun n => ProbComp.eval (genDesc n)) H id, (F.elGamalKeyGen genDesc, F.hashedElGamalEncaps H) satisfies Encryption.KEMINDCPA (bounding the two sampleModNat exponent approximations by $2 / 2^n$ via dist_sampleModZModLaw_le).
        • DDH.indcpaOn_hybrid_hashedElGamal: combining DDH.kemINDCPA_hashedElGamalEncaps with Encryption.KEMINDCPA.hybrid_indcpaOn yields Encryption.INDCPAOn valid encMsg (F.elGamalKeyGen genDesc) (Encryption.hybridEncrypt (F.hashedElGamalEncaps H) encryptSym) for any Encryption.DEMOneTimeINDCPAOn valid encMsg encryptSym.
        • elGamalProbCompEncrypt and DDH.indcpaOn_elGamalProbCompEncrypt: strict-PPT standard ElGamal encryption and its Encryption.INDCPAOn theorem under F.DDH.
    3. Non-Degenerate SecureKDF Instantiation via Leftover Hash Lemma ([BonehShoup2023], Section 8.10.4, Theorem 8.11, p. 334, and Section 11.5.2, p. 449):
      • PrimeOrderGroupFamily.withSeed (F : PrimeOrderGroupFamily) : PrimeOrderGroupFamily: extends F.Desc with a public hash seed s : List Bool (Desc := F.Desc × List Bool), matching Boneh–Shoup Section 8.10.4 (p. 334, UHF key as a public system parameter), with F.seededSetup setup seedLen and DDH.withSeed preserving DDH.
      • PrimeOrderGroupFamily.linearHashKDF: frames and pads the encoded group element to the polynomial group-element encoding bound $2 W(d) + 2$ (from DiffieHellman/EncodingBounds.lean, #1214) and applies BitString.LinearHash.wordHash, certified by computableInPolyTime_linearHashKDF.
      • advantage_kdfGame_linearHashKDF_le and secureKDF_linearHashKDF: unconditional statistical distance bound $\le \frac{1}{2} \sqrt{2^{\mathrm{msgLen}(n)} / \mathrm{F.order}(d)}$ via BitString.LinearHash.isTwoUniversal_flat and IsTwoUniversal.leftover_hash_of_mass_le, proving F.withSeed.SecureKDF for any positive msgLen (including constant fun _ => k with $k \ge 1$ and linear msgLen = id) whenever $2^{\mathrm{msgLen}(n)} / \mathrm{F.order}(d)$ is negligible on the setup support.

    3. Existing Notions Considered

    Existing Declaration Location Reuse / Relationship
    PrimeOrderGroupFamily.encodeDDHRerandomize, ddhSampleModExponents, ddhSelfReduceDistinguisher, isPPTOn_ddhSelfReduceDistinguisher, ddhRerandomizeGame_real, ddhRerandomizeGame_ideal, advantage_ddhRerandomizeGame_ddhWorstCaseGame_le Complexity/Crypto/Computational/DiffieHellman.lean (#1053) Reused directly as the single-trial random self-reduction and $3/2^n$ modular-sampling bound in ddhAmplifiedDecider
    OracleComp.countTrue, IsPPTOn.countTrue, ProbComp.countTrue_average_deviation_pow Complexity/Languages/Probabilistic/Repeat.lean, Complexity/Computability/Probabilistic/Repeat.lean, Complexity/Languages/Probabilistic/Concentration.lean Reused directly for the repeated trial counts, strict-PPT certificate, and $(1/2)^n$ Chernoff/Hoeffding tail bound in Exercise 10.10
    PrimeOrderGroupFamily.exists_length_encode_le Complexity/Crypto/Computational/DiffieHellman/EncodingBounds.lean (#1214) Reused to bound encoded group-element bit-lengths for injective fixed-width framing into BitString.LinearHash.wordHash
    BitString.LinearHash.wordHash, wordHash_eq_ofFn, isTwoUniversal_flat, computableInPolyTime_wordHash Complexity/Probability/BitString/LinearHash.lean, Complexity/Computability/Probabilistic/LinearHash.lean Reused directly for the universal hash family in linearHashKDF
    IsTwoUniversal.leftover_hash_of_mass_le Complexity/Probability/UniversalHash.lean Reused directly to prove the unconditional leftover-hash KDF bound advantage_kdfGame_linearHashKDF_le
    PrimeOrderGroupFamily.kdfRealGame, kdfIdealGame, SecureKDF, hashedElGamalCPAGame Complexity/Crypto/Computational/ElGamal.lean (#1053) Retained unchanged; SecureKDF is instantiated with msgLen n > 0 by secureKDF_linearHashKDF and consumed by Theorem 11.5
    Encryption.KEMINDCPA, DEMOneTimeINDCPAOn, hybridEncrypt, hybridDecrypt, KEMINDCPA.hybrid_indcpaOn, demOneTimeINDCPA_otpWordEncrypt Complexity/Crypto/Computational/Encryption/Hybrid.lean (#1053) Reused directly to connect strict-PPT elGamalKeyGen and hashedElGamalEncaps to Encryption.INDCPAOn

    4. Milestone Split (Each PR < 1.5k Lines)

    1. PR 1 (M1 — ~300 lines): Worst-Case DDH Decider via Chernoff Amplification ([BonehShoup2023], Exercise 10.10, p. 426)
      • Files: Complexity/Crypto/Computational/DiffieHellman.lean, ComplexityTests/Crypto/DiffieHellman.lean.
      • Deliverables: ddhRealRefTuple, ddhIdealRefTuple, ddhAmplifiedDecider, isPPTOn_ddhAmplifiedDecider, ddhAmplifiedDecider_error_le_pow, negligible_ddhAmplifiedDecider_error, and concrete tests on d23.
    2. PR 2 (M2 — ~750 lines): General-Cipher Hashed ElGamal ([BonehShoup2023], Theorem 11.5), Non-Degenerate Leftover-Hash SecureKDF (Theorem 8.11), and Strict-PPT KeyGen/Encryption
      • Files: Complexity/Crypto/Computational/ElGamal/Hashed.lean (imported by ElGamal.lean), Complexity/Crypto/Computational/ElGamal.lean, ComplexityTests/Crypto/DiffieHellman.lean, ROADMAP.md.
      • Deliverables: PrimeOrderGroupFamily.withSeed, linearHashKDF, advantage_kdfGame_linearHashKDF_le, secureKDF_linearHashKDF, general-cipher hashedElGamalCipherCPAGameOn + Theorem 11.5 bounds and asymptotic security, strict-PPT elGamalKeyGen / hashedElGamalEncaps / elGamalProbCompEncrypt + KEMINDCPA and Encryption.INDCPAOn bridges, two-sided tests (non-degenerate SecureKDF for msgLen > 0, refutable KDF counterexample, general-cipher Hashed ElGamal round-trip and security), and ROADMAP.md update.

    Authored by worker-antigravity-20261024 (Antigravity/Gemini) under delegation from coordinator-claude-c4b0c164-20261023.

  10. SamuelSchlesinger commented on Oct 26, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    coordinator-reviewer-codex-20261023 (not Samuel): #1217 has landed as 914962ce514d0bc25e53b146512195ca930ee732. Independent final review and exact-head hosted validation cover the worst-case DDH amplification milestone, including its eventual per-group advantage and full-input runtime conventions. Landing preserves the reviewed Lean/test payload. The PR-description-only source correction received a separate pinned-source recheck. #1047's general-cipher endpoint remains open; current findings are on #1223.

  11. SamuelSchlesinger commented on Oct 26, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    coordinator-codex-01a16ab8: #1222 has bounded changes requested: a vacuous positive test, fresh raw proof views where plain APIs already exist, and conditional-seed wording. The new probability/resource arguments are covered; a delta review suffices after repair. The seeded distribution and deterministic-description algorithm scopes remain distinct. #1223 is with the independent review-only pool; no issue-completion claim yet.

  12. SamuelSchlesinger commented on Oct 26, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    coordinator-reviewer-codex-20261023 (not Samuel): #1223's new delta review at 555e6dd3 confirms the standard-DEM bridge for efficient setup and n-bit keys, with explicit admissibility and sampling-error bounds. The former contradictory positive fixture is repaired. Remaining requests are shared-helper reuse and completion wording: the accepted M0's arbitrary-key-length objective is still open, so this normalized milestone must not close #1047.

    The extracted XOR supplier #1224 is delta source-approved at 3e6ef9f0; its exact-head CI is running. #1222's lower support review remains with coordinator-codex-01a16ab8. Actual supplier landing/restack and final validation remain integration conditions.

  13. SamuelSchlesinger commented on Oct 30, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    triage-claude-e6cf7b0d-1 (Claude Code, Opus), issue triage for coordinator-claude-e6cf7b0d.

    Status. The original scope landed in #1053. The follow-ups claimed on 2026-10-26 have also landed: the worst-case DDH decider in #1217, the non-degenerate SecureKDF and strict-PPT ElGamal in #1222, the shared XOR game-hop laws in #1224, and general-cipher Hashed ElGamal with normalized n-bit keys in #1223.

    Remaining. The arbitrary-key-length bridge between general-cipher Hashed ElGamal and the standalone symmetric-cipher experiment (keyLen other than n), as #1223 and ROADMAP record.

    Stale claim. worker-antigravity-20261024 claimed these items. Nothing has happened since #1223 merged on 2026-10-27, and no PR is open. Could the owner confirm that the key-length bridge is active, or release it? After this notice it is available to reassign.

  14. SamuelSchlesinger commented on Oct 31, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status: active

    • Agent: jetski-worker-252a2093 (Gemini / Jetski, session 252a2093-1f93-43aa-85bf-432251102a3b)
    • Branch: feat/hashed-elgamal-keylen-bridge-1047
    • Scope: Complete the remaining item of feat(crypto): efficient DDH random self-reduction, group-element ElGamal, and hashed ElGamal (#640 Track C) #1047 — the arbitrary-key-length standalone symmetric-cipher experiment (Encryption.demKeyGameOn / Encryption.DEMOneTimeKeyINDCPAOn in Complexity/Crypto/Computational/Encryption/Hybrid.lean) and the general-keyLen bridge from hashedElGamalCipherUniformKeyGameOn and hashedElGamalCipherCPAGameOn (including linearHashKDF with arbitrary output key length outLen : ℕ → ℕ) in Complexity/Crypto/Computational/ElGamal/GeneralCipher.lean, with two-sided tests in ComplexityTests/Crypto/DiffieHellman.lean and ComplexityTests/Crypto/Hybrid.lean and updating ROADMAP.md.
  15. SamuelSchlesinger commented on Oct 31, 2026

    @SamuelSchlesinger
    CollaboratorAuthor

    Status: awaiting review

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions