Documentation

CslibFrontier.Crypto.Computational.LWE.NormalForm

Finite probability bounds for LWE normal-form sample transformations #

Decision and search LWE in normal form — where the secret is drawn from the error distribution — relate to their standard uniform-secret variants via Peikert's leading-block transformation, losing at most the probability that a uniform n × n matrix over ZMod q is singular.

Given n + m samples [A * s + e | A], the sample transformation splits A into a top n × n block A₁ and a bottom block A₂. When A₁ is invertible it outputs the m samples [A' * e₁ + e₂ | A'] with A' = -A₂ A₁⁻¹, whose secret is the top error vector e₁; the uniform secret s cancels. Otherwise it gives up. The loss is the probability that a uniform n × n matrix is singular.

These theorems are finite probability steps toward Peikert's normal-form hardness reductions (#3673): they operate on framed bit-word ProbComp callers over uniform secrets and prime ZMod q, whereas gaussInv? computes the matrix inverse via determinants and adjugates rather than a polynomial-time algorithm, leaving IsPPTOn reduction certificates open.

Main definitions #

Main results #

References #

Decode a vector over ZMod q.

def Cslib.Crypto.PrimeLWE.decodeMatrix (n m q : ℕ) (word : List Bool) :
Matrix (Fin n) (Fin m) (ZMod q)

Decode a matrix over ZMod q.

def Cslib.Crypto.PrimeLWE.gaussInv? {n q : ℕ} [Fact (Nat.Prime q)] (A : Matrix (Fin n) (Fin n) (ZMod q)) :
Option (Matrix (Fin n) (Fin n) (ZMod q))

The inverse of a square matrix over ZMod q, or none when it is singular. This definition uses determinants and adjugates rather than a native polynomial-time recursive Gaussian elimination certificate. It supports exact finite-game semantic bounds but does not currently provide an executable IsPPT reduction bridge.

def Cslib.Crypto.PrimeLWE.topBlock {m n q : ℕ} (A : Matrix (Fin (n + m)) (Fin n) (ZMod q)) :
Matrix (Fin n) (Fin n) (ZMod q)

Extract the top block.

def Cslib.Crypto.PrimeLWE.bottomBlock {m n q : ℕ} (A : Matrix (Fin (n + m)) (Fin n) (ZMod q)) :
Matrix (Fin m) (Fin n) (ZMod q)

Extract the bottom block.

def Cslib.Crypto.PrimeLWE.topVec {m n q : ℕ} (b : Fin (n + m) → ZMod q) :
Fin n → ZMod q

Extract the top n elements.

def Cslib.Crypto.PrimeLWE.bottomVec {m n q : ℕ} (b : Fin (n + m) → ZMod q) :
Fin m → ZMod q

Extract the bottom m elements.

def Cslib.Crypto.PrimeLWE.transform {m n q : ℕ} (inv : Matrix (Fin n) (Fin n) (ZMod q)) (A : Matrix (Fin (n + m)) (Fin n) (ZMod q)) (b : Fin (n + m) → ZMod q) :
Matrix (Fin m) (Fin n) (ZMod q) × (Fin m → ZMod q)

Transform a sample into an error-secret sample using a computed inverse inv of the top block.

def Cslib.Crypto.PrimeLWE.transformAugmented {m n q : ℕ} (inv : Matrix (Fin n) (Fin n) (ZMod q)) (Ab : Matrix (Fin (n + m)) (Fin (n + 1)) (ZMod q)) :
Matrix (Fin m) (Fin (n + 1)) (ZMod q)

Transform an augmented matrix using a computed inverse inv of its top block.

Finite sample-transformation caller for Decision LWE in normal form.

Finite sample-transformation caller for Search LWE in normal form.

Correctness of the reductions #

theorem Cslib.Crypto.PrimeLWE.decodeMatrix_encMatrix {n m q : ℕ} (M : Matrix (Fin n) (Fin m) (ZMod q)) :
decodeMatrix n m q ((encMatrix n m q) M) = M

Decoding inverts the matrix encoding.

theorem Cslib.Crypto.PrimeLWE.decisionNormalForm {n m q : ℕ} [Fact (Nat.Prime q)] {noise : PMF (ZMod q)} (adversary : List Bool → ProbComp Bool) :
↑((distinguishingGame (realEnsembleErrorSecret (fun (x : ℕ) => n) (fun (x : ℕ) => m) (fun (x : ℕ) => q) (fun (x : ℕ) => noise) 0) adversary).advantage (distinguishingGame (uniformEnsemble (fun (x : ℕ) => n) (fun (x : ℕ) => m) (fun (x : ℕ) => q) 0) adversary)) ≤ ↑((distinguishingGame (realEnsemble (fun (x : ℕ) => n) (fun (x : ℕ) => n + m) (fun (x : ℕ) => q) (fun (x : ℕ) => noise) 0) (reduceNormalDecision adversary)).advantage (distinguishingGame (uniformEnsemble (fun (x : ℕ) => n) (fun (x : ℕ) => n + m) (fun (x : ℕ) => q) 0) (reduceNormalDecision adversary))) + ((Probability.PMF.uniformOfFintype (Matrix (Fin n) (Fin n) (ZMod q))).toOuterMeasure {A : Matrix (Fin n) (Fin n) (ZMod q) | A.det = 0}).toReal

Finite probability step toward normal-form decision LWE ([Pei16], §4.2.1, p. 23). An adversary's error-secret decision-LWE advantage on m samples is bounded by reduceNormalDecision's uniform-secret advantage on n + m samples plus the probability that a uniform n × n matrix over ZMod q is singular; polynomial-time efficiency (IsPPTOn) remains open (#3673).

theorem Cslib.Crypto.PrimeLWE.searchNormalForm {n m q : ℕ} [Fact (Nat.Prime q)] {noise : PMF (ZMod q)} (adversary : List Bool → ProbComp (List Bool)) :
↑(searchGameErrorSecret n m q noise adversary).succProbability ≤ ↑(searchGame n (n + m) q noise (reduceNormalSearch adversary)).succProbability + ((Probability.PMF.uniformOfFintype (Matrix (Fin n) (Fin n) (ZMod q))).toOuterMeasure {A : Matrix (Fin n) (Fin n) (ZMod q) | A.det = 0}).toReal

Finite probability step toward normal-form search LWE ([Pei16], §4.2.1, p. 23). An adversary's success probability in searchGameErrorSecret on m samples is bounded by reduceNormalSearch's success probability in uniform-secret searchGame on n + m samples plus the probability that a uniform n × n matrix over ZMod q is singular; polynomial-time efficiency (IsPPTOn) remains open (#3673).