Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Proof of Lemma 5.1, p. 34:36 — the decryption residue b − ⟨a, s⟩ equals Σ_{i∈S} e_i (plus ⌊p/2⌋ for bit 1)

Proved
RegevLWE.Correctness.residue_eq

by mikedeng1 · Oct 6, 2026 · Mathlib 0df444a (Lean v4.33.1)

lattice-cryptographylearning-with-errorsp2o-batch-pfp2bp2o-gran-per-chapterp2o-plan-paperp2o-v1public-key-encryption

Let p≥1p \ge 1p≥1, n,m≥0n, m \ge 0n,m≥0, s∈Zpns \in \mathbb Z_p^ns∈Zpn​, a1,…,am∈Zpna_1, \dots, a_m \in \mathbb Z_p^na1​,…,am​∈Zpn​, e1,…,em∈Zpe_1, \dots, e_m \in \mathbb Z_pe1​,…,em​∈Zp​, and let (ai,bi)i=1m(a_i, b_i)_{i=1}^m(ai​,bi​)i=1m​ with bi=⟨ai,s⟩+eib_i = \langle a_i, s\rangle + e_ibi​=⟨ai​,s⟩+ei​ be the public key of Regev's cryptosystem. For any subset S⊆[m]S \subseteq [m]S⊆[m], let (a,b)(a, b)(a,b) be the encryption of a bit under SSS, so that a=∑i∈Saia = \sum_{i\in S} a_ia=∑i∈S​ai​. Then

b−⟨a,s⟩=∑i∈Seifor the bit 0,b−⟨a,s⟩=⌊p2⌋+∑i∈Seifor the bit 1.b - \langle a, s\rangle = \sum_{i\in S} e_i \quad\text{for the bit } 0, \qquad b - \langle a, s\rangle = \Bigl\lfloor \frac p2 \Bigr\rfloor + \sum_{i\in S} e_i \quad\text{for the bit } 1 .b−⟨a,s⟩=i∈S∑​ei​for the bit 0,b−⟨a,s⟩=⌊2p​⌋+i∈S∑​ei​for the bit 1.

The identity reduces the correctness of decryption to the size of the accumulated noise ∑i∈Sei\sum_{i\in S} e_i∑i∈S​ei​.

Formalization Note The page states the bit-0 case and says the bit-1 case is similar; both are stated. No hypothesis on ppp beyond [NeZero p] is needed for this algebraic identity.

Preamble
import Mathlib
import Definitions.Def_RegevLWE_Correctness_Cryptosystem

open Matrix
Formal statement
namespace RegevLWE.Correctness

/-- Proof of Lemma 5.1 (Regev, J. ACM 2009, p. 34:36): for the public key `(aᵢ, bᵢ)` with
`bᵢ = ⟨aᵢ, s⟩ + eᵢ` and any subset `S ⊆ [m]`, the encryption `(a, b)` of `0` satisfies
`b − ⟨a, s⟩ = ∑_{i∈S} eᵢ`, and the encryption `(a, b)` of `1` satisfies
`b − ⟨a, s⟩ = ⌊p/2⌋ + ∑_{i∈S} eᵢ` ("the proof for an encryption of 1 is similar"). -/
theorem residue_eq {p : ℕ} [NeZero p] {n m : ℕ} (a : Fin m → Fin n → ZMod p)
    (s : Fin n → ZMod p) (e : Fin m → ZMod p) (S : Finset (Fin m)) :
    (encrypt (publicKey a s e) 0 S).2 - (encrypt (publicKey a s e) 0 S).1 ⬝ᵥ s
        = ∑ i ∈ S, e i ∧
      (encrypt (publicKey a s e) 1 S).2 - (encrypt (publicKey a s e) 1 S).1 ⬝ᵥ s
        = ((p / 2 : ℕ) : ZMod p) + ∑ i ∈ S, e i := by sorry

end RegevLWE.Correctness
Source
Regev, On Lattices, Learning with Errors, Random Linear Codes, and Cryptography, J. ACM 56(6) (2009), Article 34, p. 34:36, proof of Lemma 5.1 (display and the sentence after it)
Human review
  • Endorsed by Shuze Chen · Oct 7, 2026

    Confirmed by the moderator at approval.

  • Endorsed by mikedeng1 · Oct 7, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me