Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Pinsketch decoder II: tabulated field arithmetic, the standard evaluation point and the syndrome polynomial

Definition
LinearSetReconciliation327_Main_DecoderTables

by djwj233 · Nov 19, 2026 · Mathlib 0df444a (Lean v4.33.1)

pinsketchset-reconciliationword-ram

This bundle fixes the field data that the decoder reads from its environment, and the two derived objects that the read stage materialises.

For a field FFF that is a Z2\mathbb{Z}_2Z2​-algebra, a basis bbb of FFF over Z2\mathbb{Z}_2Z2​ with www coordinates, and an injective sequence (ι0,…,ιN−1)(\iota_0,\dots,\iota_{N-1})(ι0​,…,ιN−1​) of nonzero elements of FFF, the standard decoding table detStd t N b ι is a list of word-sized natural numbers. Its first three entries carry the parameters (t,w,N)(t,w,N)(t,w,N); the remaining blocks encode the multiplication, squaring, inversion, positivity and image tables on the basis coordinates, whose addresses are delimited by detMulBase, detSqBase, detInvBase, detPosBase, detImgBase and detEnd.

Two further objects are defined: eSeq b y turns a packed syndrome y∈(Z2w)ty \in (\mathbb{Z}_2^{w})^{t}y∈(Z2w​)t into the ttt field elements it encodes, and syndromePoly is the polynomial whose coefficients are the field elements stored by the read stage. payloadAt and payloadField extract the payload bits of one coordinate block. These are the objects compared by the verifier and consumed by the key solver, so the algebraic content of the decoder never has to mention a memory address.

Definition code
import Definitions.Def_LinearSetReconciliation327_Main_DecoderModel
import Definitions.Def_LinearSetReconciliation327_Main_WordRAM
/-! Decoder tables: `det` address layout, `detStd`, the tabulation tables, `eSeq`, `payloadAt`/`payloadField`, `syndromePoly`.

Generated by `p21opt/gen/emit.py` by skeleton subtraction from
`Solutions/_p21_opt3.lean` (Stage-2 declaration spans). -/

set_option autoImplicit false

open scoped ENNReal
open Finset Polynomial

namespace LinearSetReconciliation327.Main

section FieldFacts

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

end FieldFacts

section PowerSums

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

variable {N : ℕ}

end PowerSums

/-- First address of the multiplication table. -/
def detMulBase (_w : ℕ) : ℕ := 64

/-- First address of the squaring table. -/
def detSqBase (w : ℕ) : ℕ := detMulBase w + 2 ^ (2 * w)

/-- First address of the inversion table. -/
def detInvBase (w : ℕ) : ℕ := detSqBase w + 2 ^ (2 * w)

/-- First address of the position table `ι⁻¹(v) + 1`. -/
def detPosBase (w : ℕ) : ℕ := detInvBase w + 2 ^ w

/-- First address of the image table `i ↦ ι i`. -/
def detImgBase (w : ℕ) : ℕ := detPosBase w + 2 ^ w

/-- One past the last address used by `det`. -/
def detEnd (w : ℕ) : ℕ := detImgBase w + 2 ^ w

/-- The payload `y` read as a function of the bit position, with `0` outside the payload. -/
def payloadAt {M : ℕ} (y : Fin M → ZMod 2) (p : ℕ) : ZMod 2 :=
  if h : p < M then y ⟨p, h⟩ else 0

/-- The field element whose `b`-coordinates are the bits of the `j`-th packed field: this is the
`j`-th syndrome coordinate, written in the basis `b`. -/
noncomputable def payloadField {F : Type} [Field F] [Algebra (ZMod 2) F] {w : ℕ}
    (b : Module.Basis (Fin w) (ZMod 2) F) {M : ℕ} (y : Fin M → ZMod 2) (j : ℕ) : F :=
  b.repr.symm (Finsupp.equivFunOnFinite.symm (fun k : Fin w => payloadAt y (j * w + k.val)))

/-- The finite syndrome polynomial, with coefficient zero equal to `P₁`. -/
noncomputable def syndromePoly {F : Type} [Field F] (e : ℕ → F) (t : ℕ) : F[X] :=
  ∑ j ∈ Finset.range (2 * t), C (e j) * X ^ j

noncomputable def tracePolynomial {F : Type} [Field F] (a : F) : ℕ → F[X]
  | 0 => 0
  | n + 1 => tracePolynomial a n ^ 2 + C a * X

section Enc

variable {F : Type} [Field F] [Algebra (ZMod 2) F] {w : ℕ}

end Enc

section Tables

variable {F : Type} [Field F] [Algebra (ZMod 2) F] {w : ℕ}

/-- The integer spelling of a product: the entry of the multiplication table. -/
noncomputable def mulTab (b : Module.Basis (Fin w) (ZMod 2) F) (a c : ℕ) : ℕ :=
  enc b (dec b a * dec b c)

/-- The integer spelling of a square: the entry of the squaring table. -/
noncomputable def sqTab (b : Module.Basis (Fin w) (ZMod 2) F) (a : ℕ) : ℕ :=
  enc b ((dec b a) ^ 2)

/-- The integer spelling of an inverse: the entry of the inversion table.  (`0⁻¹ = 0`, so no
separate treatment of zero is needed.) -/
noncomputable def invTab (b : Module.Basis (Fin w) (ZMod 2) F) (a : ℕ) : ℕ :=
  enc b ((dec b a)⁻¹)

/-- The position table: `ι⁻¹(v) + 1`, and `0` for a field element outside the image. -/
noncomputable def posTab (N : ℕ) (ι : ℕ → F) (v : F) : ℕ := by
  classical
  exact if h : ∃ i, i < N ∧ ι i = v then (Classical.choose h) + 1 else 0

/-- The image table: `ι i` in integer form. -/
noncomputable def imgTab (b : Module.Basis (Fin w) (ZMod 2) F) (ι : ℕ → F) (i : ℕ) : ℕ :=
  enc b (ι i)

/-- The header of `det`: the parameters the program reads before it does anything else.  Slot `0` is
`t`, `1` is `w`, `2` is `N`, `3` is `2t`; `4 … 12` are the derived addresses and the mask, so that
the program itself never has to compute a table address. -/
noncomputable def hdrTab (t N : ℕ) (w : ℕ) : ℕ → ℕ
  | 0 => t
  | 1 => w
  | 2 => N
  | 3 => 2 * t
  | 4 => wordsOf (8 * w) (t * w)
  | 5 => 2 ^ w - 1
  | 6 => detSqBase w
  | 7 => detMulBase w
  | 8 => detInvBase w
  | 9 => detPosBase w
  | 10 => detImgBase w
  | 11 => detEnd w
  | 12 => 8 * w
  | _ => 0

/-- **The preprocessing table.**  Its storage is not charged (`RAMEnv.det`), and it is fixed before
the payload is seen: it holds only the parameters and the field tables, never any part of `y`. -/
noncomputable def detStd (t N : ℕ) (b : Module.Basis (Fin w) (ZMod 2) F) (ι : ℕ → F)
    (addr : ℕ) : ℕ :=
  if addr < 13 then hdrTab t N w addr
  else if addr < detMulBase w then 0
  else if addr < detSqBase w then
    mulTab b ((addr - detMulBase w) / 2 ^ w) ((addr - detMulBase w) % 2 ^ w)
  else if addr < detInvBase w then sqTab b (addr - detSqBase w)
  else if addr < detPosBase w then invTab b (addr - detInvBase w)
  else if addr < detImgBase w then posTab N ι (dec b (addr - detPosBase w))
  else if addr < detEnd w then imgTab b ι (addr - detImgBase w)
  else 0

end Tables

section ReadInt

end ReadInt

section ReadLoop

end ReadLoop

section ProgramAt

end ProgramAt

section ReadSpec

end ReadSpec

section ReadStmt

end ReadStmt

section Bounds

end Bounds

section Prologue

end Prologue

section ReadAssembly

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

end ReadAssembly

section Expand

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

/-- The sequence of field elements the expansion writes: `eSeq 0 = P_1`, `eSeq (2k) = P_{k+1}` (the
layout the read loop produced), and `eSeq (2k+1) = (eSeq k)^2` — the paper's `P_{2a} = P_a²` in
characteristic two. -/
noncomputable def eSeq {w : ℕ} (b : Module.Basis (Fin w) (ZMod 2) F) {M : ℕ} (y : Fin M → ZMod 2) :
    ℕ → F
  | 0 => payloadField b y 0
  | n + 1 => if Even (n + 1) then payloadField b y ((n + 1) / 2)
             else (eSeq b y ((n + 1) / 2)) ^ 2
termination_by n => n
decreasing_by exact Nat.div_lt_self (Nat.succ_pos n) (by norm_num)

end Expand

section ExpandStd

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

end ExpandStd

section PinBits

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

end PinBits

section Uniqueness

variable {F : Type} [Field F] [Algebra (ZMod 2) F]

end Uniqueness

section Slp

variable {F : Type} [Field F]

end Slp

end LinearSetReconciliation327.Main
Source
arXiv:2611.11409, Section 2.2 (Pinsketch parameters and decoder) and Appendix C; Dodis, Ostrovsky, Reyzin, Smith, Fuzzy Extractors: How to Generate Strong Keys from Biometrics and Other Noisy Data, SIAM J. Comput. 38(1), 2008, Section 6.3

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