Documentation

CslibFrontier.Crypto.Computational.SIS.ModuleEncryption

Ring-LWE and Module-LWE Public-Key Encryption #

This module formalizes a Module-LWE public-key encryption scheme over the negacyclic polynomial ring R_q = ℤ_q[X] / (X^n + 1) and modules R_q^k ([Reg09], [LPR10], [DKL+18]), in which the public key is a Module-LWE sample and the ciphertext is a second Module-LWE sample masked by the encoded message:

  1. Adjoint identity (innerPoly_moduleSISMap_eq): the polynomial inner product innerPoly b r = ∑ j, negacyclicMul (b j) (r j) and the commutative ring algebra of negacyclicMul are in CslibFrontier.Foundations.Algebra.Negacyclic. Here they give innerPoly (moduleSISMap A s) r = innerPoly (moduleSISMap Aᵀ r) s.
  2. Polynomial-ring message encoding and centered-lift rounding (encodePolyMsg, decodePolyMsg, decodePolyMsg_encodePolyMsg_add_noise): A message bit-vector m : Fin n → Bool is encoded into Fin n → ZMod q by mapping false ↦ 0 and true ↦ ⌊q / 2⌋, and decoded by lifting each coefficient to its centered representative in (-q/2, q/2] (SIS.liftCentered) and testing whether its magnitude exceeds ⌊q / 4⌋. Whenever 4 * B + 2 < q and every coefficient of an integer error polynomial err has magnitude at most B, decoding encodePolyMsg q m + err recovers m (decodePolyMsg_encodePolyMsg_add_noise).
  3. Module-LWE public-key encryption and bounded-noise correctness (moduleLWEKeyGen, moduleLWEEncrypt, moduleLWEDecrypt, moduleLWEDecrypt_moduleLWEEncrypt_eq):
    • Key generation maps (A, s, e) to the public key (A, b) = (A, moduleSISMap A s + e).
    • Encryption of m : Fin n → Bool under pk = (A, b) with ephemeral secret r and noises (e₁, e₂) outputs (u, v) = (moduleSISMap Aᵀ r + e₁, innerPoly b r + e₂ + encodePolyMsg q m).
    • Decryption under secret key s computes decodePolyMsg (v - innerPoly u s). By the ring-bilinearity identity innerPoly_moduleSISMap_add_sub, the A · s · r terms cancel and leave encodePolyMsg q m + (innerPoly e r - innerPoly e₁ s + e₂). When the centered coefficients of s, r are bounded by B_s, B_r and those of e, e₁, e₂ are bounded by B_e with 4 * (k * n * B_e * B_r + k * n * B_e * B_s + B_e) + 2 < q (in particular when B_s ≤ B_r and 4 * (2 * k * n * B_e * B_r + B_e) + 2 < q), decryption recovers m deterministically (moduleLWEDecrypt_moduleLWEEncrypt_eq).
  4. Public-key pseudorandomness from DecisionModuleLWE and Module-LWE advantage bounds for ciphertexts:

The statements of item 4 draw the secret s and the ephemeral secret r uniformly from R_q^k, whereas the correctness theorems of item 3 assume centered bounds B_s and B_r on them. When 0 < k * n, bounds that hold for every s and r satisfy q / 2 ≤ B_s and q / 2 ≤ B_r, and the hypothesis on q then forces B_e = 0, that is, e, e₁ and e₂ are zero. Hence, for 0 < k * n and nonzero noise, no choice of bounds makes the correctness theorems apply to every s and r drawn in item 4.

Main definitions #

Main results #

References #

Part 1: Bilinearity of innerPoly against moduleSISMap #

@[simp]
theorem Cslib.Crypto.innerPoly_eq_ringSISMap {k n q : ℕ} (a z : Fin k → Fin n → ZMod q) :

Over ZMod q, innerPoly agrees with ringSISMap.

theorem Cslib.Crypto.innerPoly_moduleSISMap_eq {d k n q : ℕ} (A : Matrix (Fin d) (Fin k) (Fin n → ZMod q)) (s : Fin k → Fin n → ZMod q) (r : Fin d → Fin n → ZMod q) :

Adjoint identity for moduleSISMap and innerPoly: ⟨A · s, r⟩ = ⟨Aᵀ · r, s⟩ over ℤ_q[X] / (X^n + 1).

theorem Cslib.Crypto.innerPoly_moduleSISMap_add_sub {d k n q : ℕ} (A : Matrix (Fin d) (Fin k) (Fin n → ZMod q)) (s e₁ : Fin k → Fin n → ZMod q) (r e : Fin d → Fin n → ZMod q) :

Fundamental noisy ring-bilinearity cancellation: ⟨A · s + e, r⟩ - ⟨Aᵀ · r + e₁, s⟩ = ⟨e, r⟩ - ⟨e₁, s⟩.

Part 2: Polynomial-Ring Message Encoding and Centered-Lift Rounding #

def Cslib.Crypto.encodePolyMsg {n : ℕ} (q : ℕ) (m : Fin n → Bool) :
Fin n → ZMod q

Encode an n-bit message polynomial m : Fin n → Bool into Fin n → ZMod q by mapping false ↦ 0 and true ↦ (q / 2 : ZMod q).

@[simp]
theorem Cslib.Crypto.encodePolyMsg_apply {n : ℕ} (q : ℕ) (m : Fin n → Bool) (i : Fin n) :
encodePolyMsg q m i = if m i = true then ↑(q / 2) else 0
def Cslib.Crypto.decodePolyMsg {n q : ℕ} (w : Fin n → ZMod q) :
Fin n → Bool

Decode a noisy ring element w : Fin n → ZMod q into Fin n → Bool by lifting each coefficient to its centered representative SIS.liftCentered w i in (-q/2, q/2] and testing whether its magnitude exceeds q / 4 (false when |liftCentered w i| ≤ q / 4, true when |liftCentered w i| > q / 4).

@[simp]
theorem Cslib.Crypto.decodePolyMsg_encodePolyMsg_add_noise {n q B : ℕ} (hB : 4 * B + 2 < q) (m : Fin n → Bool) {err : Fin n → ℤ} (herr : ∀ (i : Fin n), (err i).natAbs ≤ B) :
decodePolyMsg (encodePolyMsg q m + fun (i : Fin n) => ↑(err i)) = m

Bounded-error decoding correctness for encodePolyMsg and decodePolyMsg: if 4 * B + 2 < q and every coefficient of the integer error polynomial err : Fin n → ℤ satisfies (err i).natAbs ≤ B, then decodePolyMsg recovers m from encodePolyMsg q m + fun i => (err i : ZMod q).

theorem Cslib.Crypto.decodePolyMsg_encodePolyMsg_add_noise_of_abs_le {n q B : ℕ} (hB : 4 * B + 2 < q) (m : Fin n → Bool) {err : Fin n → ℤ} (herr : ∀ (i : Fin n), |err i| ≤ ↑B) :
decodePolyMsg (encodePolyMsg q m + fun (i : Fin n) => ↑(err i)) = m

Bounded-error decoding correctness stated with |err i| ≤ B.

@[simp]
theorem Cslib.Crypto.decodePolyMsg_encodePolyMsg {n q : ℕ} (hq : 2 < q) (m : Fin n → Bool) :

Noiseless round-trip identity for encodePolyMsg and decodePolyMsg whenever 2 < q.

Part 3: Ring-LWE / Module-LWE Public-Key Encryption and Decryption Correctness #

@[reducible, inline]

A Module-LWE public key (A, b) of module rank k over ℤ_q[X] / (X^n + 1) consists of a k × k polynomial matrix A and a length-k polynomial vector b = A · s + e.

@[reducible, inline]

A Module-LWE ciphertext (u, v) of module rank k over ℤ_q[X] / (X^n + 1) consists of a length-k polynomial vector u and a single ring element v.

def Cslib.Crypto.moduleLWEKeyGen {k n q : ℕ} (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) (s e : Fin k → Fin n → ZMod q) :

Deterministic Module-LWE public-key generation: given public matrix A, secret key s, and error vector e, output (A, moduleSISMap A s + e).

@[simp]
theorem Cslib.Crypto.moduleLWEKeyGen_fst {k n q : ℕ} (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) (s e : Fin k → Fin n → ZMod q) :
(moduleLWEKeyGen A s e).1 = A
@[simp]
theorem Cslib.Crypto.moduleLWEKeyGen_snd {k n q : ℕ} (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) (s e : Fin k → Fin n → ZMod q) :
theorem Cslib.Crypto.moduleLWEKeyGen_eq_sample {k n q : ℕ} (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) (s e : Fin k → Fin n → ZMod q) :

moduleLWEKeyGen A s e is (A, ModuleLWE.sample A s e).

def Cslib.Crypto.moduleLWEEncrypt {k n q : ℕ} (pk : ModuleLWEPublicKey k n q) (r e₁ : Fin k → Fin n → ZMod q) (e₂ : Fin n → ZMod q) (m : Fin n → Bool) :

Deterministic Module-LWE encryption of m : Fin n → Bool under public key pk = (A, b) with ephemeral secret r : Fin k → Fin n → ZMod q and noises e₁ : Fin k → Fin n → ZMod q and e₂ : Fin n → ZMod q: u = moduleSISMap Aᵀ r + e₁ and v = innerPoly b r + e₂ + encodePolyMsg q m.

@[simp]
theorem Cslib.Crypto.moduleLWEEncrypt_fst {k n q : ℕ} (pk : ModuleLWEPublicKey k n q) (r e₁ : Fin k → Fin n → ZMod q) (e₂ : Fin n → ZMod q) (m : Fin n → Bool) :
(moduleLWEEncrypt pk r e₁ e₂ m).1 = moduleSISMap pk.1.transpose r + e₁
@[simp]
theorem Cslib.Crypto.moduleLWEEncrypt_snd {k n q : ℕ} (pk : ModuleLWEPublicKey k n q) (r e₁ : Fin k → Fin n → ZMod q) (e₂ : Fin n → ZMod q) (m : Fin n → Bool) :
(moduleLWEEncrypt pk r e₁ e₂ m).2 = innerPoly pk.2 r + e₂ + encodePolyMsg q m
def Cslib.Crypto.moduleLWEDecrypt {k n q : ℕ} (s : Fin k → Fin n → ZMod q) (ct : ModuleLWECiphertext k n q) :
Fin n → Bool

Deterministic Module-LWE decryption of ciphertext ct = (u, v) using secret key s: compute v - innerPoly u s and apply decodePolyMsg.

theorem Cslib.Crypto.moduleLWEDecrypt_phase_eq {k n q : ℕ} (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) (s e r e₁ : Fin k → Fin n → ZMod q) (e₂ : Fin n → ZMod q) (m : Fin n → Bool) :
(moduleLWEEncrypt (moduleLWEKeyGen A s e) r e₁ e₂ m).2 - innerPoly (moduleLWEEncrypt (moduleLWEKeyGen A s e) r e₁ e₂ m).1 s = encodePolyMsg q m + (innerPoly e r - innerPoly e₁ s + e₂)

Algebraic noise cancellation in decryption: for ct = moduleLWEEncrypt (moduleLWEKeyGen A s e) r e₁ e₂ m, the decryption phase ct.2 - innerPoly ct.1 s equals encodePolyMsg q m + (innerPoly e r - innerPoly e₁ s + e₂).

def Cslib.Crypto.moduleLWEErrorPoly {k n : ℕ} (s r e e₁ : Fin k → Fin n → ℤ) (e₂ : Fin n → ℤ) :
Fin n → ℤ

Combined integer decryption error polynomial innerPoly e r - innerPoly e₁ s + e₂ over ℤ[X] / (X^n + 1).

theorem Cslib.Crypto.intCast_moduleLWEErrorPoly_liftCentered {k n q : ℕ} (s r e e₁ : Fin k → Fin n → ZMod q) (e₂ : Fin n → ZMod q) :
(fun (i : Fin n) => ↑(moduleLWEErrorPoly (fun (j : Fin k) => SIS.liftCentered (s j)) (fun (j : Fin k) => SIS.liftCentered (r j)) (fun (j : Fin k) => SIS.liftCentered (e j)) (fun (j : Fin k) => SIS.liftCentered (e₁ j)) (SIS.liftCentered e₂) i)) = innerPoly e r - innerPoly e₁ s + e₂

Casting moduleLWEErrorPoly to ZMod q agrees with the modular error expression innerPoly e r - innerPoly e₁ s + e₂ on the centered integer lifts.

theorem Cslib.Crypto.abs_moduleLWEErrorPoly_le {k n B_s B_r B_e : ℕ} {s r e e₁ : Fin k → Fin n → ℤ} {e₂ : Fin n → ℤ} (hs : ∀ (j : Fin k) (i : Fin n), |s j i| ≤ ↑B_s) (hr : ∀ (j : Fin k) (i : Fin n), |r j i| ≤ ↑B_r) (he : ∀ (j : Fin k) (i : Fin n), |e j i| ≤ ↑B_e) (he₁ : ∀ (j : Fin k) (i : Fin n), |e₁ j i| ≤ ↑B_e) (he₂ : ∀ (i : Fin n), |e₂ i| ≤ ↑B_e) (i : Fin n) :
|moduleLWEErrorPoly s r e e₁ e₂ i| ≤ ↑(k * n * B_e * B_r + k * n * B_e * B_s + B_e)

Infinity-norm bound on moduleLWEErrorPoly: if ‖s‖_∞ ≤ B_s, ‖r‖_∞ ≤ B_r, and ‖e‖_∞, ‖e₁‖_∞, ‖e₂‖_∞ ≤ B_e, then every coefficient of moduleLWEErrorPoly s r e e₁ e₂ has absolute value at most k * n * B_e * B_r + k * n * B_e * B_s + B_e.

theorem Cslib.Crypto.moduleLWEDecrypt_moduleLWEEncrypt_eq_of_bounds {k n q B_s B_r B_e : ℕ} (hq : 4 * (k * n * B_e * B_r + k * n * B_e * B_s + B_e) + 2 < q) (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) {s r e e₁ : Fin k → Fin n → ZMod q} {e₂ : Fin n → ZMod q} (hs : ModuleSIS.inInfNormBound B_s s) (hr : ModuleSIS.inInfNormBound B_r r) (he : ModuleSIS.inInfNormBound B_e e) (he₁ : ModuleSIS.inInfNormBound B_e e₁) (he₂ : SIS.inInfNormBound B_e e₂) (m : Fin n → Bool) :

Bounded-noise decryption correctness (general B_s, B_r, B_e bounds): when s, r, e, e₁ and e₂ satisfy the centered ℓ_∞ bounds B_s, B_r, B_e and 4 * (k * n * B_e * B_r + k * n * B_e * B_s + B_e) + 2 < q, decrypting an encryption of m recovers m.

theorem Cslib.Crypto.moduleLWEDecrypt_moduleLWEEncrypt_eq {k n q B_s B_r B_e : ℕ} (hBs : B_s ≤ B_r) (hq : 4 * (2 * k * n * B_e * B_r + B_e) + 2 < q) (A : Matrix (Fin k) (Fin k) (Fin n → ZMod q)) {s r e e₁ : Fin k → Fin n → ZMod q} {e₂ : Fin n → ZMod q} (hs : ModuleSIS.inInfNormBound B_s s) (hr : ModuleSIS.inInfNormBound B_r r) (he : ModuleSIS.inInfNormBound B_e e) (he₁ : ModuleSIS.inInfNormBound B_e e₁) (he₂ : SIS.inInfNormBound B_e e₂) (m : Fin n → Bool) :

Bounded-noise decryption correctness: when s and r have centered ℓ_∞ norm bounded by B_s and B_r with B_s ≤ B_r, e, e₁, e₂ have centered ℓ_∞ norm bounded by B_e, and 4 * (2 * k * n * B_e * B_r + B_e) + 2 < q, decrypting moduleLWEEncrypt (moduleLWEKeyGen A s e) r e₁ e₂ m recovers m.

Part 4: Public-Key Pseudorandomness and Module-LWE Advantage Bounds for Ciphertexts #

noncomputable def Cslib.Crypto.moduleLWEPublicKeyLaw (k n q : ℕ) [NeZero q] (noise : PMF (Fin n → ZMod q)) (secretLaw : PMF (Fin k → Fin n → ZMod q) := Probability.PMF.uniformOfFintype (Fin k → Fin n → ZMod q)) :

Draw a secret from secretLaw, a uniform matrix, and independent polynomial errors, then output the existing key generator's public key. The default secret law is uniform, exactly as required by the ModuleLWE.sampleLaw identity and advantage bounds below.

@[simp]

The honest public-key distribution is the k × k Module-LWE sample law ModuleLWE.sampleLaw with a uniform secret and independent polynomial errors drawn from noise.

theorem Cslib.Crypto.publicKey_indistinguishable_of_decisionModuleLWE (k n q : ℕ → ℕ) [∀ (security : ℕ), NeZero (q security)] (noise : (security : ℕ) → PMF (Fin (n security) → ZMod (q security))) (h : DecisionModuleLWE k k n q noise) :

Public-key pseudorandomness (DecisionModuleLWE Hop 1): under DecisionModuleLWE k k n q noise, the encoded honest public-key ensemble is computationally indistinguishable from the encoded uniform public-key ensemble ModuleLWE.uniformEnsemble k k n q.

def Cslib.Crypto.extendPublicKeyMatrix {k n q : ℕ} (pk : ModuleLWEPublicKey k n q) :
Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q)

Embed a public key pk = (A, b) into a (k + 1) × k module matrix by placing b as row 0 and the rows of Aᵀ as rows Fin.succ i.

def Cslib.Crypto.unextendPublicKeyMatrix {k n q : ℕ} (M : Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q)) :

Recover a public key (A, b) from a (k + 1) × k module matrix by reading row 0 as b and the transpose of the remaining k rows as A.

def Cslib.Crypto.extendPublicKeyEquiv (k n q : ℕ) :
ModuleLWEPublicKey k n q ≃ Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q)

Equivalence between ModuleLWEPublicKey k n q and (k + 1) × k module matrices.

def Cslib.Crypto.extendCiphertext {k n q : ℕ} (ct : ModuleLWECiphertext k n q) :
Fin (k + 1) → Fin n → ZMod q

Embed a ciphertext ct = (u, v) into a length-(k + 1) polynomial vector by placing v at coordinate 0 and u at coordinates Fin.succ i.

def Cslib.Crypto.unextendCiphertext {k n q : ℕ} (w : Fin (k + 1) → Fin n → ZMod q) :

Recover a ciphertext (u, v) from a length-(k + 1) polynomial vector.

def Cslib.Crypto.extendCiphertextEquiv (k n q : ℕ) :
ModuleLWECiphertext k n q ≃ (Fin (k + 1) → Fin n → ZMod q)

Equivalence between ModuleLWECiphertext k n q and Fin (k + 1) → Fin n → ZMod q.

theorem Cslib.Crypto.extendCiphertext_moduleLWEEncrypt {k n q : ℕ} (pk : ModuleLWEPublicKey k n q) (r e₁ : Fin k → Fin n → ZMod q) (e₂ : Fin n → ZMod q) (m : Fin n → Bool) :

Structural embedding of encryption into (k + 1) × k Module-LWE: extendCiphertext (moduleLWEEncrypt pk r e₁ e₂ m) is the (k + 1) × k Module-LWE sample ModuleLWE.sample (extendPublicKeyMatrix pk) r (Fin.cons e₂ e₁) masked by Fin.cons (encodePolyMsg q m) 0.

def Cslib.Crypto.maskExtendedSampleEquiv {k n q : ℕ} (m : Fin n → Bool) :
Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q) ≃ Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q)

Equivalence masking the second component of a (k + 1) × k Module-LWE sample by Fin.cons (encodePolyMsg q m) 0.

noncomputable def Cslib.Crypto.uniformKeyEncryptionLaw (k n q : ℕ) [NeZero q] (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) :
PMF (Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q))

Distribution of the extended (k + 1) × k pair (extendPublicKeyMatrix pk, extendCiphertext (moduleLWEEncrypt pk r e₁ e₂ m)) when pk is drawn uniformly, r is drawn uniformly, e₁ ← PMF.pi (fun _ => noise), and e₂ ← noise.

theorem Cslib.Crypto.uniformKeyEncryptionLaw_eq_sampleLaw_map (k n q : ℕ) [NeZero q] (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) :

Second DecisionModuleLWE hop identity: under a uniform public key pk, the extended encryption distribution uniformKeyEncryptionLaw k n q noise m is the pushforward by maskExtendedSampleEquiv m of the (k + 1) × k Module-LWE sample law ModuleLWE.sampleLaw with a uniform secret and independent polynomial errors drawn from noise.

theorem Cslib.Crypto.uniformSample_mask_eq_uniform (k n q : ℕ) [NeZero q] (m : Fin n → Bool) :
PMF.map (⇑(maskExtendedSampleEquiv m)) (Probability.PMF.uniformOfFintype (Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q))) = Probability.PMF.uniformOfFintype (Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q))

Masking the second component of a uniform (k + 1) × k Module-LWE sample by maskExtendedSampleEquiv m leaves the uniform distribution invariant, so the resulting distribution is independent of m.

noncomputable def Cslib.Crypto.encryptionViewOfKeyLaw {k n q : ℕ} [NeZero q] (pkLaw : PMF (ModuleLWEPublicKey k n q)) (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) (ephemeralLaw : PMF (Fin k → Fin n → ZMod q) := Probability.PMF.uniformOfFintype (Fin k → Fin n → ZMod q)) :

Complete encryption view (pk, ct) under an arbitrary public-key distribution pkLaw, drawing r from ephemeralLaw, e₂ ← noise, and e₁ ← PMF.pi (fun _ => noise). The default ephemeral law is uniform, as used by the advantage bounds below.

noncomputable def Cslib.Crypto.realEncryptionView (k n q : ℕ) [NeZero q] (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) (secretLaw ephemeralLaw : PMF (Fin k → Fin n → ZMod q) := Probability.PMF.uniformOfFintype (Fin k → Fin n → ZMod q)) :

Real encryption view (pk, ct) with explicit long-term and ephemeral secret laws. Both default to uniform. The ModuleLWE.sampleLaw identities and advantage bounds of Part 4 concern those defaults; this parameterization does not extend them to other secret distributions. The correctness theorem moduleLWEDecrypt_moduleLWEEncrypt_eq_of_bounds assumes centered bounds B_s and B_r on the two secrets; under its hypothesis on q, such bounds cover every value of a uniform secret only when k * n * B_e = 0.

noncomputable def Cslib.Crypto.hybridEncryptionView (k n q : ℕ) [NeZero q] (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) :

Hybrid encryption view (pk, ct) under a uniform public key pk.

Ideal uniform encryption view (pk, ct), completely independent of the message m.

def Cslib.Crypto.unextendMaskedSampleEquiv {k n q : ℕ} (m : Fin n → Bool) :
Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q) ≃ ModuleLWEPublicKey k n q × ModuleLWECiphertext k n q

Equivalence unextending a masked (k + 1) × k Module-LWE pair (M, w) into a (pk, ct) pair.

def Cslib.Crypto.unextendMaskedSample {k n q : ℕ} (m : Fin n → Bool) (pair : Matrix (Fin (k + 1)) (Fin k) (Fin n → ZMod q) × (Fin (k + 1) → Fin n → ZMod q)) :

Unextending a masked (k + 1) × k Module-LWE pair (M, w) into a (pk, ct) pair.

theorem Cslib.Crypto.hybridEncryptionView_eq_sampleLaw_map (k n q : ℕ) [NeZero q] (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) :

hybridEncryptionView k n q noise m is the pushforward under unextendMaskedSample m of the (k + 1) × k Module-LWE sample law with a uniform secret and independent polynomial errors drawn from noise.

Pushing forward the uniform (k + 1) × k sample distribution under unextendMaskedSample m yields uniformEncryptionView k n q for every message m.

theorem Cslib.Crypto.advantage_realEncryptionView_uniform_le {k n q : ℕ} [NeZero q] (noise : PMF (Fin n → ZMod q)) (m : Fin n → Bool) (D : ModuleLWEPublicKey k n q × ModuleLWECiphertext k n q → Game) :

Two-hop ModuleLWE advantage bound for (pk, ct): for any semantic distinguisher D : ModuleLWEPublicKey k n q × ModuleLWECiphertext k n q → Game and any message m, the distinguishing advantage between realEncryptionView k n q noise m and uniformEncryptionView k n q is bounded by the sum of:

  1. the k × k ModuleLWE advantage (replacing the public key with uniform), and
  2. the (k + 1) × k ModuleLWE advantage (replacing the ciphertext with uniform).
theorem Cslib.Crypto.advantage_realEncryptionView_msg_le {k n q : ℕ} [NeZero q] (noise : PMF (Fin n → ZMod q)) (m₀ m₁ : Fin n → Bool) (D : ModuleLWEPublicKey k n q × ModuleLWECiphertext k n q → Game) :
Game.advantage ((realEncryptionView k n q noise m₀).bind D) ((realEncryptionView k n q noise m₁).bind D) ≤ Game.advantage ((realEncryptionView k n q noise m₀).bind D) ((uniformEncryptionView k n q).bind D) + Game.advantage ((realEncryptionView k n q noise m₁).bind D) ((uniformEncryptionView k n q).bind D)

Two-message CPA distinguishing bound via uniformEncryptionView: for any two messages m₀, m₁ : Fin n → Bool and any semantic distinguisher D, the advantage between realEncryptionView k n q noise m₀ and realEncryptionView k n q noise m₁ is bounded by their respective distances to the message-independent uniformEncryptionView k n q.