Documentation

CslibFrontier.Crypto.Computational.SIS.MR07Samplers

Strict-PPT discrete-grid Gaussian and HNF-free quotient samplers #

This module constructs the two lattice-specific strict probabilistic polynomial-time (IsPPTOn) samplers supporting the Micciancio–Regev IncGDD to ℓ₂-SIS reduction (MR07Core):

  1. Cslib.Crypto.SIS.MR07.sampleGridGaussian: draws dim independent 1-D discrete Gaussian coordinates via sampleZ at width q · √(sSq) and center q · t_i, then reduces into the fundamental parallelepiped via gridReduceInt (built on solveFloorMul, ratSolve, Rat.floor, and ListMatrix.dotProduct).
  2. Cslib.Crypto.SIS.MR07.sampleQuotientModS: computes the quotient index D = |det S| / |det B| via staged Bird determinants (quotientIndex), samples dim near-uniform coordinates in ZMod D via sampleModNat, and reduces modulo P(S) via quotientReduceInt (built on solveFloorMul and ListMatrix.dotProduct).

In addition to unconditional strict-PPT and product-pushforward CloseTo certificates, this module proves exact matrix specifications (solveFloorMul_spec, quotientIndex_eq_natAbs_div_det, gridReduceInt_spec, quotientReduceInt_spec) and typed-law bridges connecting the executable list samplers directly to idealGridSample on GridRep B q × intLattice B (via gridPairToLists / decodeGridPair) and to PMF.uniformOfFintype (SublatticeQuot B S) (via sublatticeQuotToList / decodeSublatticeQuot).

Main definitions #

Main results #

References #

1. Shared linear-algebra helpers (ListMatrix.dotProduct, Rat.floor, solveFloorMul) #

Row-wise integer matrix-vector multiplication B *ᵥ v via ListMatrix.dotProduct.

Shared exact rational-solve, coordinatewise Rat.floor, and integer multiply-back helper: solves mat *ᵥ ξ = rhs, sets k = ⌊ξ⌋, and returns mat *ᵥ k via intTableMulVec.

2. Strict-PPT discrete-grid Gaussian sampler (sampleGridGaussian) #

Input specification for the discrete-grid Gaussian sampler sampleGridGaussian ([MR07a], Lemma 5.7, p. 20).

  • dim : ℕ

    Ambient lattice dimension n.

  • modulus : ℕ

    Integer grid modulus q > 0.

  • Basis matrix B of the lattice L(B) (columns are basis vectors).

  • sSq : ℚ

    Rational squared Gaussian width s² > 0.

  • target : List ℚ

    Target center t ∈ ℚ^n.

  • tail : ℕ

    Unary tail-cutoff multiplier t_tail passed to sampleZ.

  • prec : ℕ

    Unary dyadic acceptance-coin precision prec passed to sampleZ.

  • maxTrials : ℕ

    Unary rejection-trial cap maxTrials passed to sampleZ.

Instances For
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_mk_deg :
    Turing.MultiTapeTM.ComputableInDegree (fun (p : ℕ × ℕ × RowTable ℤ × ℚ × List ℚ × ℕ × ℕ × ℕ) => { dim := p.1, modulus := p.2.1, basis := p.2.2.1, sSq := p.2.2.2.1, target := p.2.2.2.2.1, tail := p.2.2.2.2.2.1, prec := p.2.2.2.2.2.2.1, maxTrials := p.2.2.2.2.2.2.2 }) encFields enc 1 1
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_prec_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).prec) encIn✝ Turing.MultiTapeTM.encUnary S✝
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_target_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_modulus_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_sSq_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).sSq) encIn✝ Turing.MultiTapeTM.encRat S✝
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_maxTrials_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_tail_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).tail) encIn✝ Turing.MultiTapeTM.encUnary S✝
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 x1 : γ → ℕ} {x2 : γ → RowTable ℤ} {x3 : γ → ℚ} {x4 : γ → List ℚ} {x5 x6 x7 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn Turing.MultiTapeTM.encNat budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn LinearAlgebra.IntTable.enc budget) (h3 : Turing.MultiTapeTM.ComputableInSpace x3 encIn Turing.MultiTapeTM.encRat budget) (h4 : Turing.MultiTapeTM.ComputableInSpace x4 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encRat) budget) (h5 : Turing.MultiTapeTM.ComputableInSpace x5 encIn Turing.MultiTapeTM.encUnary budget) (h6 : Turing.MultiTapeTM.ComputableInSpace x6 encIn Turing.MultiTapeTM.encUnary budget) (h7 : Turing.MultiTapeTM.ComputableInSpace x7 encIn Turing.MultiTapeTM.encUnary budget) :
    Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { dim := x0 x, modulus := x1 x, basis := x2 x, sSq := x3 x, target := x4 x, tail := x5 x, prec := x6 x, maxTrials := x7 x }) encIn enc budget

    Framing encoding of GridSampleInput (binary modulus to permit super-polynomial q).

    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_dim_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).dim) encIn✝ Turing.MultiTapeTM.encUnary S✝
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 x1 T1 S1 : γ → ℕ} {x2 : γ → RowTable ℤ} {T2 S2 : γ → ℕ} {x3 : γ → ℚ} {T3 S3 : γ → ℕ} {x4 : γ → List ℚ} {T4 S4 x5 T5 S5 x6 T6 S6 x7 T7 S7 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn Turing.MultiTapeTM.encNat T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn LinearAlgebra.IntTable.enc T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encRat T3 S3) (h4 : Turing.MultiTapeTM.ComputableInO x4 encIn (Turing.MultiTapeTM.encList Turing.MultiTapeTM.encRat) T4 S4) (h5 : Turing.MultiTapeTM.ComputableInO x5 encIn Turing.MultiTapeTM.encUnary T5 S5) (h6 : Turing.MultiTapeTM.ComputableInO x6 encIn Turing.MultiTapeTM.encUnary T6 S6) (h7 : Turing.MultiTapeTM.ComputableInO x7 encIn Turing.MultiTapeTM.encUnary T7 S7) :
    Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { dim := x0 x, modulus := x1 x, basis := x2 x, sSq := x3 x, target := x4 x, tail := x5 x, prec := x6 x, maxTrials := x7 x }) encIn enc (fun (x : γ) => T0 x + (T1 x + (T2 x + (T3 x + (T4 x + (T5 x + (T6 x + T7 x))))))) fun (x : γ) => S0 x + (S1 x + (S2 x + (S3 x + (S4 x + (S5 x + (S6 x + S7 x))))))
    theorem Cslib.Crypto.SIS.MR07.GridSampleInput.enc_basis_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → GridSampleInput} :
    Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).basis) encIn✝ LinearAlgebra.IntTable.enc S✝

    Exact integer grid reduction: given r' ∈ ℤ^dim, computes bk = solveFloorMul dim B (-r' / q) and returns (u, y) = (-r' - q • bk, -bk).

    Strict-PPT discrete-grid Gaussian sampler (r' ~ D_{ℤ^dim, q*s, q*t} followed by exact gridReduceInt).

    theorem Cslib.Crypto.SIS.MR07.closeTo_eval_sampleGridGaussian_pi (inp : GridSampleInput) (hsSq : 0 < inp.sSq) (hq : 0 < inp.modulus) (hqs1 : 1 ≤ ↑inp.modulus * √↑inp.sSq) (ht : 1 ≤ inp.tail) {ε : ℝ} (hε0 : 0 ≤ ε) (hε : ε ≤ 1 / 2) (hdual : ZLattice.gaussianMass (LinearMap.BilinForm.dualSubmodule (innerₗ ℝ) ZLattice.intLatticeReal) (1 / (↑inp.modulus * √↑inp.sSq)) 0 - 1 ≤ ε) (hprec : 8 * (2 * inp.tail + 6) ≤ 2 ^ inp.prec) :
    Probability.CloseTo (sampleGridGaussian inp).eval (PMF.map (fun (r : Fin inp.dim → ℤ) => gridReduceInt inp.dim inp.modulus inp.basis (List.ofFn r)) (Probability.PMF.piFin fun (i : Fin inp.dim) => ZLattice.discreteGaussianInt (↑inp.modulus * √↑inp.sSq) ⋯ (↑inp.modulus * ↑(inp.target.getD (↑i) 0)))) (ENNReal.ofReal (↑inp.dim * ((1 - 1 / (16 * (2 * ↑inp.tail + 6))) ^ inp.maxTrials + (8 * ↑inp.tail + 24) / 2 ^ inp.prec + (1 + ε) / (1 - ε) * (2 * Real.exp (-Real.pi * ↑inp.tail ^ 2)))))

    CloseTo bound for sampleGridGaussian against PMF.piFin of 1-D discrete Gaussians at width q * √sSq and centers q * t_i, pushed forward by gridReduceInt.

    theorem Cslib.Crypto.SIS.MR07.closeTo_eval_sampleGridGaussian_pi_of_smoothingParameter_le (inp : GridSampleInput) (hsSq : 0 < inp.sSq) (hq : 0 < inp.modulus) (hqs1 : 1 ≤ ↑inp.modulus * √↑inp.sSq) (ht : 1 ≤ inp.tail) {ε : ℝ} (hε : 0 < ε) (hε_le : ε ≤ 1 / 2) (hη : ZLattice.smoothingParameter ZLattice.intLatticeReal ε ≤ ↑inp.modulus * √↑inp.sSq) (hprec : 8 * (2 * inp.tail + 6) ≤ 2 ^ inp.prec) :
    Probability.CloseTo (sampleGridGaussian inp).eval (PMF.map (fun (r : Fin inp.dim → ℤ) => gridReduceInt inp.dim inp.modulus inp.basis (List.ofFn r)) (Probability.PMF.piFin fun (i : Fin inp.dim) => ZLattice.discreteGaussianInt (↑inp.modulus * √↑inp.sSq) ⋯ (↑inp.modulus * ↑(inp.target.getD (↑i) 0)))) (ENNReal.ofReal (↑inp.dim * ((1 - 1 / (16 * (2 * ↑inp.tail + 6))) ^ inp.maxTrials + (8 * ↑inp.tail + 24) / 2 ^ inp.prec + (1 + ε) / (1 - ε) * (2 * Real.exp (-Real.pi * ↑inp.tail ^ 2)))))

    Smoothing-parameter (η_ε(ℤ) ≤ q · √sSq) form of closeTo_eval_sampleGridGaussian_pi.

    Every output pair in the support of sampleGridGaussian inp is the exact gridReduceInt image of some length-inp.dim integer vector.

    3. Strict-PPT HNF-free quotient sampler (sampleQuotientModS) #

    Input specification for the HNF-free quotient sampler sampleQuotientModS.

    Instances For
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_dim_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → QuotientSampleInput} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).dim) encIn✝ Turing.MultiTapeTM.encUnary S✝
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_mk_budget {γ : Type} {encIn : γ ↪ List Bool} {budget x0 : γ → ℕ} {x1 x2 : γ → RowTable ℤ} {x3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInSpace x0 encIn Turing.MultiTapeTM.encUnary budget) (h1 : Turing.MultiTapeTM.ComputableInSpace x1 encIn LinearAlgebra.IntTable.enc budget) (h2 : Turing.MultiTapeTM.ComputableInSpace x2 encIn LinearAlgebra.IntTable.enc budget) (h3 : Turing.MultiTapeTM.ComputableInSpace x3 encIn Turing.MultiTapeTM.encUnary budget) :
      Turing.MultiTapeTM.ComputableInSpace (fun (x : γ) => { dim := x0 x, basis := x1 x, sublattice := x2 x, extraBits := x3 x }) encIn enc budget
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_basis_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → QuotientSampleInput} :
      Turing.MultiTapeTM.ComputableInSpace g✝ encIn✝ enc S✝ → Turing.MultiTapeTM.ComputableInSpace (fun (c : γ✝) => (g✝ c).basis) encIn✝ LinearAlgebra.IntTable.enc S✝
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_sublattice_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → QuotientSampleInput} :
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_mk_inO {γ : Type} {encIn : γ ↪ List Bool} {x0 T0 S0 : γ → ℕ} {x1 : γ → RowTable ℤ} {T1 S1 : γ → ℕ} {x2 : γ → RowTable ℤ} {T2 S2 x3 T3 S3 : γ → ℕ} (h0 : Turing.MultiTapeTM.ComputableInO x0 encIn Turing.MultiTapeTM.encUnary T0 S0) (h1 : Turing.MultiTapeTM.ComputableInO x1 encIn LinearAlgebra.IntTable.enc T1 S1) (h2 : Turing.MultiTapeTM.ComputableInO x2 encIn LinearAlgebra.IntTable.enc T2 S2) (h3 : Turing.MultiTapeTM.ComputableInO x3 encIn Turing.MultiTapeTM.encUnary T3 S3) :
      Turing.MultiTapeTM.ComputableInO (fun (x : γ) => { dim := x0 x, basis := x1 x, sublattice := x2 x, extraBits := x3 x }) encIn enc (fun (x : γ) => T0 x + (T1 x + (T2 x + T3 x))) fun (x : γ) => S0 x + (S1 x + (S2 x + S3 x))
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_extraBits_budget {γ✝ : Type} {encIn✝ : γ✝ ↪ List Bool} {S✝ : γ✝ → ℕ} {g✝ : γ✝ → QuotientSampleInput} :
      theorem Cslib.Crypto.SIS.MR07.QuotientSampleInput.enc_mk_deg :
      Turing.MultiTapeTM.ComputableInDegree (fun (p : ℕ × RowTable ℤ × RowTable ℤ × ℕ) => { dim := p.1, basis := p.2.1, sublattice := p.2.2.1, extraBits := p.2.2.2 }) encFields enc 1 1

      Integer quotient index D = |det S| / |det B| computed via staged Bird determinants.

      Exact integer quotient representative reduction: given x ∈ ℕ^dim, computes v0 = B *ᵥ x via intTableMulVec, sk = solveFloorMul dim S v0, and returns v0 - sk.

      HNF-free strict-PPT quotient sampler for L(B) ∩ P(S). Returns 0 if D = 0.

      sampleModNat (Nat.clog 2 D + extraBits) D read in ZMod D is within 1 / 2 ^ extraBits of PMF.uniformOfFintype (ZMod D) in CloseTo.

      CloseTo bound for sampleQuotientModS against PMF.piFin of uniformOfFintype (ZMod D) pushed forward by quotientReduceInt.

      Every vector in the support of sampleQuotientModS inp is either the zero fallback (when quotientIndex = 0) or the exact quotientReduceInt image of some length-inp.dim list.

      4. Exact IntTable.toMatrix / WellFormed specifications #

      theorem Cslib.Crypto.SIS.MR07.intTableMulVec_getD {n : ℕ} (T : LinearAlgebra.IntTable) (B : Matrix (Fin n) (Fin n) ℤ) (hrows : T.numRows = n) (hcols : T.numCols = n) (hmat : ∀ (i j : Fin n), RowTable.entry T ↑i ↑j = B i j) (v : List ℤ) (i : Fin n) :
      (intTableMulVec T v).getD (↑i) 0 = B.mulVec (fun (j : Fin n) => v.getD (↑j) 0) i

      Coordinatewise matrix specification of intTableMulVec: for any square IntTable T representing B : Matrix (Fin n) (Fin n) ℤ, (intTableMulVec T v).getD i 0 = (B *ᵥ v) i.

      theorem Cslib.Crypto.SIS.MR07.ratSolve_intTable_real_spec {n : ℕ} (T : LinearAlgebra.IntTable) (B : Matrix (Fin n) (Fin n) ℤ) (hrows : T.numRows = n) (hcols : T.numCols = n) (hmat : ∀ (i j : Fin n), RowTable.entry T ↑i ↑j = B i j) (hB : B.det ≠ 0) (rhs fallback : List ℚ) (i : Fin n) :
      ↑(((LinearAlgebra.ratSolve { matrix := RowTable.map Int.cast T, rhs := rhs }).solution.getD fallback).getD (↑i) 0) = (B.map Int.cast)⁻¹.mulVec (fun (k : Fin n) => ↑(rhs.getD (↑k) 0)) i

      Exact real-cast specification of ratSolve on a square invertible IntTable: for any T representing B : Matrix (Fin n) (Fin n) ℤ with B.det ≠ 0, ratSolve returns a solution whose real cast equals (B_ℝ)⁻¹ *ᵥ rhs coordinatewise (regardless of the .getD fallback).

      theorem Cslib.Crypto.SIS.MR07.solveFloorMul_spec {n : ℕ} (T : LinearAlgebra.IntTable) (B : Matrix (Fin n) (Fin n) ℤ) (hrows : T.numRows = n) (hcols : T.numCols = n) (hmat : ∀ (i j : Fin n), RowTable.entry T ↑i ↑j = B i j) (hB : B.det ≠ 0) (rhs : List ℚ) (i : Fin n) :
      (solveFloorMul n T rhs).getD (↑i) 0 = B.mulVec (fun (j : Fin n) => ⌊(B.map Int.cast)⁻¹.mulVec (fun (k : Fin n) => ↑(rhs.getD (↑k) 0)) j⌋) i

      Exact matrix specification of solveFloorMul: for any square invertible IntTable T representing B : Matrix (Fin n) (Fin n) ℤ, solveFloorMul n T rhs equals B *ᵥ ⌊(B_ℝ)⁻¹ *ᵥ rhs⌋ coordinatewise.

      theorem Cslib.Crypto.SIS.MR07.quotientIndex_eq_natAbs_div_det {n : ℕ} (TB TS : LinearAlgebra.IntTable) (B S : Matrix (Fin n) (Fin n) ℤ) (hBwf : RowTable.WellFormed TB) (hSwf : RowTable.WellFormed TS) (hBrows : TB.numRows = n) (hBmat : ∀ (i j : Fin n), RowTable.entry TB ↑i ↑j = B i j) (hSrows : TS.numRows = n) (hSmat : ∀ (i j : Fin n), RowTable.entry TS ↑i ↑j = S i j) (hB : B.det ≠ 0) (hSB : intLattice S ≤ intLattice B) :

      Exact determinant-index specification of quotientIndex: for well-formed square IntTables representing B, S : Matrix (Fin n) (Fin n) ℤ with B.det ≠ 0 and intLattice S ≤ intLattice B, quotientIndex TB TS = (S.det / B.det).natAbs.

      theorem Cslib.Crypto.SIS.MR07.gridReduceInt_spec {n q : ℕ} (T : LinearAlgebra.IntTable) (B : Matrix (Fin n) (Fin n) ℤ) (hrows : T.numRows = n) (hcols : T.numCols = n) (hmat : ∀ (i j : Fin n), RowTable.entry T ↑i ↑j = B i j) (hB : B.det ≠ 0) (hq : 0 < q) (r' : List ℤ) :
      have p := gridReduceInt n q T r'; have rVec := (↑q)⁻¹ • WithLp.toLp 2 fun (i : Fin n) => ↑(r'.getD (↑i) 0); have uVec := (↑q)⁻¹ • WithLp.toLp 2 fun (i : Fin n) => ↑(p.1.getD (↑i) 0); have yVec := WithLp.toLp 2 fun (i : Fin n) => ↑(p.2.getD (↑i) 0); p.1.length = n ∧ p.2.length = n ∧ uVec = modParallelepiped B (-rVec) ∧ yVec = rVec + uVec ∧ yVec ∈ intLattice B

      Exact geometric specification of gridReduceInt against modParallelepiped and intLattice: for invertible B and 0 < q, (u, y) from gridReduceInt n q T r' satisfies u / q = (-r' / q) mod P(B) and y = r' / q + u / q ∈ intLattice B.

      theorem Cslib.Crypto.SIS.MR07.quotientReduceInt_spec {n : ℕ} (TB TS : LinearAlgebra.IntTable) (B S : Matrix (Fin n) (Fin n) ℤ) (hBrows : TB.numRows = n) (hBcols : TB.numCols = n) (hBmat : ∀ (i j : Fin n), RowTable.entry TB ↑i ↑j = B i j) (hSrows : TS.numRows = n) (hScols : TS.numCols = n) (hSmat : ∀ (i j : Fin n), RowTable.entry TS ↑i ↑j = S i j) (hS : S.det ≠ 0) (x : List ℕ) :
      have v := quotientReduceInt n TB TS x; v.length = n ∧ (WithLp.toLp 2 fun (i : Fin n) => ↑(v.getD (↑i) 0)) = modParallelepiped S (WithLp.toLp 2 fun (i : Fin n) => ↑(B.mulVec (fun (j : Fin n) => ↑(x.getD (↑j) 0)) i))

      Exact geometric specification of quotientReduceInt against MR07Core.modParallelepiped: for B = TB.toMatrix and invertible S = TS.toMatrix, v = quotientReduceInt n TB TS x has length n and equals modParallelepiped S (B *ᵥ x).

      5. Typed-law bridges to MR07Core.idealGridSample and SublatticeQuot #

      5.1 Discrete-grid Gaussian sampler ↔ MR07.idealGridSample #

      noncomputable def Cslib.Crypto.SIS.MR07.gridEmbed (n q : ℕ) (hq : 0 < q) :
      (Fin n → ℤ) ≃ ↥(gridLattice n q)

      Bijection identifying Fin n → ℤ with the fine grid lattice G_q = (1 / q) ℤⁿ.

      noncomputable def Cslib.Crypto.SIS.MR07.gridPairToLists {n : ℕ} {B : Matrix (Fin n) (Fin n) ℤ} {q : ℕ} :

      Canonical injective encoding of a typed GridRep B q × intLattice B sample into List ℤ × List ℤ.

      gridPairToLists is injective on GridRep B q × intLattice B.

      noncomputable def Cslib.Crypto.SIS.MR07.decodeGridPair {n : ℕ} (B : Matrix (Fin n) (Fin n) ℤ) (q : ℕ) :

      Left-inverse decoder from List ℤ × List ℤ to GridRep B q × intLattice B.

      theorem Cslib.Crypto.SIS.MR07.piFin_discreteGaussianInt_map_gridEmbed {n q : ℕ} (hq : 0 < q) (s : ℝ) (hs : 0 < s) (t : EuclideanSpace ℝ (Fin n)) :
      have hqs := ⋯; PMF.map (⇑(gridEmbed n q hq)) (Probability.PMF.piFin fun (i : Fin n) => ZLattice.discreteGaussianInt (↑q * s) hqs (↑q * t.ofLp i)) = ZLattice.discreteGaussian (gridLattice n q) s hs t

      Exact product factorization: PMF.piFin of 1-D integer discrete Gaussians at (q · s, q · t_i) pushed through gridEmbed equals ZLattice.discreteGaussian (gridLattice n q) s hs t.

      theorem Cslib.Crypto.SIS.MR07.gridReduceInt_exists_gridRep {n q : ℕ} (T : LinearAlgebra.IntTable) (B : Matrix (Fin n) (Fin n) ℤ) (hrows : T.numRows = n) (hcols : T.numCols = n) (hmat : ∀ (i j : Fin n), RowTable.entry T ↑i ↑j = B i j) (hB : B.det ≠ 0) (hq : 0 < q) (r' : List ℤ) :
      have rVec := (↑q)⁻¹ • WithLp.toLp 2 fun (i : Fin n) => ↑(r'.getD (↑i) 0); ∃ (gy : GridRep B q × ↥(intLattice B)), gridReduceInt n q T r' = gridPairToLists gy ∧ gy.1.toVec = modParallelepiped B (-rVec) ∧ ↑gy.2 = rVec + gy.1.toVec

      Build the typed GridRep B q × intLattice B witness from gridReduceInt_spec on any r' : List ℤ (zero decoding loss).

      theorem Cslib.Crypto.SIS.MR07.mem_support_sampleGridGaussian_exists_gridRep (inp : GridSampleInput) (B : Matrix (Fin inp.dim) (Fin inp.dim) ℤ) (hrows : inp.basis.numRows = inp.dim) (hcols : inp.basis.numCols = inp.dim) (hmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.basis ↑i ↑j = B i j) (hB : B.det ≠ 0) (hq : 0 < inp.modulus) {p : List ℤ × List ℤ} (hp : p ∈ (sampleGridGaussian inp).eval.support) :
      ∃ (gy : GridRep B inp.modulus × ↥(intLattice B)), p = gridPairToLists gy ∧ decodeGridPair B inp.modulus p = gy

      Every output pair in the support of sampleGridGaussian inp encodes a valid GridRep B inp.modulus × intLattice B recovered losslessly by decodeGridPair.

      theorem Cslib.Crypto.SIS.MR07.map_gridReduceInt_piFin_eq_map_idealGridSample {n q : ℕ} (T : LinearAlgebra.IntTable) (B : Matrix (Fin n) (Fin n) ℤ) (hrows : T.numRows = n) (hcols : T.numCols = n) (hmat : ∀ (i j : Fin n), RowTable.entry T ↑i ↑j = B i j) (hB : B.det ≠ 0) (hq : 0 < q) (s : ℝ) (hs : 0 < s) (t : EuclideanSpace ℝ (Fin n)) :
      have hqs := ⋯; PMF.map (fun (r : Fin n → ℤ) => gridReduceInt n q T (List.ofFn r)) (Probability.PMF.piFin fun (i : Fin n) => ZLattice.discreteGaussianInt (↑q * s) hqs (↑q * t.ofLp i)) = PMF.map gridPairToLists (idealGridSample B hB q hq s hs t)

      Exact target-law equality connecting sampleGridGaussian's product-pushforward PMF to MR07Core.idealGridSample pushed through gridPairToLists.

      theorem Cslib.Crypto.SIS.MR07.closeTo_eval_sampleGridGaussian_idealGridSample (inp : GridSampleInput) (B : Matrix (Fin inp.dim) (Fin inp.dim) ℤ) (hrows : inp.basis.numRows = inp.dim) (hcols : inp.basis.numCols = inp.dim) (hmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.basis ↑i ↑j = B i j) (hB : B.det ≠ 0) (hsSq : 0 < inp.sSq) (hq : 0 < inp.modulus) (hqs1 : 1 ≤ ↑inp.modulus * √↑inp.sSq) (ht : 1 ≤ inp.tail) {ε : ℝ} (hε0 : 0 ≤ ε) (hε : ε ≤ 1 / 2) (hdual : ZLattice.gaussianMass (LinearMap.BilinForm.dualSubmodule (innerₗ ℝ) ZLattice.intLatticeReal) (1 / (↑inp.modulus * √↑inp.sSq)) 0 - 1 ≤ ε) (hprec : 8 * (2 * inp.tail + 6) ≤ 2 ^ inp.prec) :
      have tVec := WithLp.toLp 2 fun (i : Fin inp.dim) => ↑(inp.target.getD (↑i) 0); Probability.CloseTo (PMF.map (decodeGridPair B inp.modulus) (sampleGridGaussian inp).eval) (idealGridSample B hB inp.modulus hq √↑inp.sSq ⋯ tVec) (ENNReal.ofReal (↑inp.dim * ((1 - 1 / (16 * (2 * ↑inp.tail + 6))) ^ inp.maxTrials + (8 * ↑inp.tail + 24) / 2 ^ inp.prec + (1 + ε) / (1 - ε) * (2 * Real.exp (-Real.pi * ↑inp.tail ^ 2)))))

      CloseTo guarantee for sampleGridGaussian decoded into the typed GridRep B inp.modulus × intLattice B law idealGridSample.

      theorem Cslib.Crypto.SIS.MR07.closeTo_eval_sampleGridGaussian_idealGridSample_of_smoothingParameter_le (inp : GridSampleInput) (B : Matrix (Fin inp.dim) (Fin inp.dim) ℤ) (hrows : inp.basis.numRows = inp.dim) (hcols : inp.basis.numCols = inp.dim) (hmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.basis ↑i ↑j = B i j) (hB : B.det ≠ 0) (hsSq : 0 < inp.sSq) (hq : 0 < inp.modulus) (hqs1 : 1 ≤ ↑inp.modulus * √↑inp.sSq) (ht : 1 ≤ inp.tail) {ε : ℝ} (hε : 0 < ε) (hε_le : ε ≤ 1 / 2) (hη : ZLattice.smoothingParameter ZLattice.intLatticeReal ε ≤ ↑inp.modulus * √↑inp.sSq) (hprec : 8 * (2 * inp.tail + 6) ≤ 2 ^ inp.prec) :
      have tVec := WithLp.toLp 2 fun (i : Fin inp.dim) => ↑(inp.target.getD (↑i) 0); Probability.CloseTo (PMF.map (decodeGridPair B inp.modulus) (sampleGridGaussian inp).eval) (idealGridSample B hB inp.modulus hq √↑inp.sSq ⋯ tVec) (ENNReal.ofReal (↑inp.dim * ((1 - 1 / (16 * (2 * ↑inp.tail + 6))) ^ inp.maxTrials + (8 * ↑inp.tail + 24) / 2 ^ inp.prec + (1 + ε) / (1 - ε) * (2 * Real.exp (-Real.pi * ↑inp.tail ^ 2)))))

      Smoothing-parameter (η_ε(ℤ) ≤ q · √sSq) form of closeTo_eval_sampleGridGaussian_idealGridSample.

      5.2 HNF-free quotient sampler ↔ PMF.uniformOfFintype (SublatticeQuot B S) #

      Canonical injective encoding of a typed SublatticeQuot B S element into List ℤ.

      noncomputable def Cslib.Crypto.SIS.MR07.decodeSublatticeQuot {n : ℕ} (B S : Matrix (Fin n) (Fin n) ℤ) :

      Left-inverse decoder from List ℤ to SublatticeQuot B S.

      theorem Cslib.Crypto.SIS.MR07.quotientIndex_pos {n : ℕ} (TB TS : LinearAlgebra.IntTable) (B S : Matrix (Fin n) (Fin n) ℤ) (hBwf : RowTable.WellFormed TB) (hSwf : RowTable.WellFormed TS) (hBrows : TB.numRows = n) (hBmat : ∀ (i j : Fin n), RowTable.entry TB ↑i ↑j = B i j) (hSrows : TS.numRows = n) (hSmat : ∀ (i j : Fin n), RowTable.entry TS ↑i ↑j = S i j) (hB : B.det ≠ 0) (hS : S.det ≠ 0) (hSB : intLattice S ≤ intLattice B) :

      Positivity of quotientIndex TB TS for invertible B, S with intLattice S ≤ intLattice B.

      theorem Cslib.Crypto.SIS.MR07.quotientReduceInt_exists_sublatticeQuot {n : ℕ} (TB TS : LinearAlgebra.IntTable) (B S : Matrix (Fin n) (Fin n) ℤ) (hBrows : TB.numRows = n) (hBcols : TB.numCols = n) (hBmat : ∀ (i j : Fin n), RowTable.entry TB ↑i ↑j = B i j) (hSrows : TS.numRows = n) (hScols : TS.numCols = n) (hSmat : ∀ (i j : Fin n), RowTable.entry TS ↑i ↑j = S i j) (hS : S.det ≠ 0) (hSB : intLattice S ≤ intLattice B) (x : List ℕ) :

      Every quotientReduceInt n TB TS x output is the exact sublatticeQuotToList image of a typed SublatticeQuot B S representative (zero decoding loss).

      theorem Cslib.Crypto.SIS.MR07.mem_support_sampleQuotientModS_exists_sublatticeQuot (inp : QuotientSampleInput) (B S : Matrix (Fin inp.dim) (Fin inp.dim) ℤ) (hBrows : inp.basis.numRows = inp.dim) (hBcols : inp.basis.numCols = inp.dim) (hBmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.basis ↑i ↑j = B i j) (hSrows : inp.sublattice.numRows = inp.dim) (hScols : inp.sublattice.numCols = inp.dim) (hSmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.sublattice ↑i ↑j = S i j) (hS : S.det ≠ 0) (hSB : intLattice S ≤ intLattice B) {v : List ℤ} (hv : v ∈ (sampleQuotientModS inp).eval.support) :

      Every output in the support of sampleQuotientModS inp encodes a valid SublatticeQuot B S representative recovered losslessly by decodeSublatticeQuot B S.

      theorem Cslib.Crypto.SIS.MR07.quotientReduceInt_eq_quotientHom {n : ℕ} (TB TS : LinearAlgebra.IntTable) (B S : Matrix (Fin n) (Fin n) ℤ) (hBrows : TB.numRows = n) (hBcols : TB.numCols = n) (hBmat : ∀ (i j : Fin n), RowTable.entry TB ↑i ↑j = B i j) (hSrows : TS.numRows = n) (hScols : TS.numCols = n) (hSmat : ∀ (i j : Fin n), RowTable.entry TS ↑i ↑j = S i j) (hS : S.det ≠ 0) (hSB : intLattice S ≤ intLattice B) (z : Fin n → ZMod (S.det / B.det).natAbs) :
      quotientReduceInt n TB TS (List.ofFn fun (i : Fin n) => (z i).val) = sublatticeQuotToList (quotientHom B S hS hSB z)

      Pointwise identity: quotientReduceInt on z : Fin n → ZMod (S.det / B.det).natAbs equals sublatticeQuotToList (MR07Core.quotientHom B S hS hSB z).

      theorem Cslib.Crypto.SIS.MR07.map_quotientReduceInt_piFin_eq_map_uniform {n : ℕ} (TB TS : LinearAlgebra.IntTable) (B S : Matrix (Fin n) (Fin n) ℤ) (hBwf : RowTable.WellFormed TB) (hSwf : RowTable.WellFormed TS) (hBrows : TB.numRows = n) (hBcols : TB.numCols = n) (hBmat : ∀ (i j : Fin n), RowTable.entry TB ↑i ↑j = B i j) (hSrows : TS.numRows = n) (hScols : TS.numCols = n) (hSmat : ∀ (i j : Fin n), RowTable.entry TS ↑i ↑j = S i j) (hB : B.det ≠ 0) (hS : S.det ≠ 0) (hSB : intLattice S ≤ intLattice B) :

      Exact target-law equality connecting sampleQuotientModS's product-pushforward PMF to PMF.uniformOfFintype (SublatticeQuot B S) pushed through sublatticeQuotToList.

      theorem Cslib.Crypto.SIS.MR07.closeTo_eval_sampleQuotientModS_uniform (inp : QuotientSampleInput) (B S : Matrix (Fin inp.dim) (Fin inp.dim) ℤ) (hBwf : RowTable.WellFormed inp.basis) (hSwf : RowTable.WellFormed inp.sublattice) (hBrows : inp.basis.numRows = inp.dim) (hBcols : inp.basis.numCols = inp.dim) (hBmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.basis ↑i ↑j = B i j) (hSrows : inp.sublattice.numRows = inp.dim) (hScols : inp.sublattice.numCols = inp.dim) (hSmat : ∀ (i j : Fin inp.dim), RowTable.entry inp.sublattice ↑i ↑j = S i j) (hB : B.det ≠ 0) (hS : S.det ≠ 0) (hSB : intLattice S ≤ intLattice B) :

      CloseTo guarantee for sampleQuotientModS decoded into the typed uniform law PMF.uniformOfFintype (SublatticeQuot B S).