Documentation

CslibFrontier.Crypto.Protocols.PIR.GeneralCover

Exact unbalanced covering-code schemes (Theorem 1) and general radius-r covers #

PIR.CoveringCode formalizes Chor, Goldreich, Kushilevitz and Sudan, Section 3.3 in the uniform PIR.Scheme model, where every server sends answers of the same fixed bit length. Because non-perfect covering codes assign unequal numbers of non-codewords to different servers, PIR.CoveringCode proves Theorem 1's exact bit count k + (2 ^ d + (d - 1) · k) · ℓ only for balanced covers (k · (m + 1) = 2 ^ d, which forces k to divide 2 ^ d, excluding for example Figure 1's optimal d = 5, k = 7 and d = 6, k = 12 codes) and covers only radius 1.

This module completes both directions of Section 3.3 (pp. 8–10):

Main definitions #

Main results #

References #

Multi-coordinate subcube emulation #

Coordinates at which σ and w disagree; its cardinality is definitionally hammingDist σ w.

@[simp]
@[simp]
theorem Cslib.Crypto.Protocols.PIR.mem_diffCoords {D : Type} [Fintype D] {σ w : D → Bool} {l : D} :
l ∈ diffCoords σ w ↔ σ l ≠ w l
def Cslib.Crypto.Protocols.PIR.emulateCubeQuery {D ι : Type} [DecidableEq ι] [DecidableEq D] (a : D → ι → Bool) (T : Finset D) (δ : ↥T → ι) (l : D) :
ι → Bool

Emulate a subcube query at disagreement set T : Finset D by flipping coordinate δ ⟨l, hl⟩ in a l for every l ∈ T and leaving a l unchanged outside T.

@[simp]
theorem Cslib.Crypto.Protocols.PIR.emulateCubeQuery_of_mem {D ι : Type} [DecidableEq ι] [DecidableEq D] (a : D → ι → Bool) (T : Finset D) (δ : ↥T → ι) {l : D} (hl : l ∈ T) :
emulateCubeQuery a T δ l = a l + Pi.single (δ ⟨l, hl⟩) true
@[simp]
theorem Cslib.Crypto.Protocols.PIR.emulateCubeQuery_of_notMem {D ι : Type} [DecidableEq ι] [DecidableEq D] (a : D → ι → Bool) (T : Finset D) (δ : ↥T → ι) {l : D} (hl : l ∉ T) :
emulateCubeQuery a T δ l = a l
theorem Cslib.Crypto.Protocols.PIR.query_cube_eq_emulateCubeQuery {D ι : Type} [Fintype D] [Fintype ι] [DecidableEq ι] [DecidableEq D] {i : D → ι} {r : Unit} {q : (D → Bool) → D → ι → Bool} (hrq : (r, q) ∈ ((cube D ι).query Bool i).eval.support) (σ w : D → Bool) :
q w = emulateCubeQuery (q σ) (diffCoords σ w) fun (l : ↥(diffCoords σ w)) => i ↑l

Multi-coordinate generalization of PIR.query_update_cube: for any draw (r, q) of PIR.cube D ι on target i and any two words σ, w : D → Bool, the query q w is obtained from q σ by flipping (i l) on diffCoords σ w.

Exact partitions of radius-1 covers and full CGKS Theorem 1 #

An exact partition of the cube D → Bool into subsets of radius-1 balls around |S| distinct codewords CGKS, Section 3.3, Footnote 1, p. 9: each word w is assigned to a server assign w within Hamming distance 1, and each codeword code s is assigned to s itself (which forces code to be injective).

  • code : S → D → Bool

    The distinct codeword held by each server.

  • assign : (D → Bool) → S

    Assignment of every cube word to the server whose ball covers it.

  • assign_code (s : S) : self.assign (self.code s) = s

    Each codeword is covered by its own server (c_s ∈ S(c_s)).

  • hammingDist_assign_le_one (w : D → Bool) : hammingDist (self.code (self.assign w)) w ≤ 1

    Every word lies within Hamming distance 1 of its assigned server's codeword.

noncomputable def Cslib.Crypto.Protocols.PIR.ExactRadiusOneCover.ofHammingDist {S D : Type} [Fintype D] (code : S → D → Bool) (hinj : Function.Injective code) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (code s) w ≤ 1) :

Build an ExactRadiusOneCover canonically from any injective radius-1 covering code code : S → D → Bool: each codeword code s is assigned to s, and each non-codeword is assigned to a covering codeword within Hamming distance 1.

@[simp]
theorem Cslib.Crypto.Protocols.PIR.ExactRadiusOneCover.code_ofHammingDist {S D : Type} [Fintype D] (code : S → D → Bool) (hinj : Function.Injective code) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (code s) w ≤ 1) :
(ofHammingDist code hinj hc).code = code
@[reducible, inline]

Non-codeword cube vertices assigned to server s in the exact cover K.

The |S| codewords together with all AssignedNeighbour K s partition D → Bool.

noncomputable def Cslib.Crypto.Protocols.PIR.ExactRadiusOneCover.indexedScheme {S D : Type} [Fintype D] (K : ExactRadiusOneCover S D) [DecidableEq D] (ι : Type) [Fintype ι] [DecidableEq ι] :
IndexedScheme (D → ι) S Unit (fun (x : S) => D → ι → Bool) fun (s : S) => Bool × (K.AssignedNeighbour s → ι → Bool)

Per-server covering-code PIR scheme CGKS, Section 3.3, Theorem 1 and Footnote 1: server s receives the subcube query for K.code s, replies with 1 bit for K.code s itself and |ι| bits for each assigned non-codeword w : K.AssignedNeighbour s, and the user sums the 2 ^ |D| recovered subcube parities.

K.indexedScheme ι is perfectly private, inheriting uniform subcube queries from PIR.cube.

K.indexedScheme ι is perfectly correct: every word w : D → Bool is either K.code s or differs from K.code s at a single coordinate l₀, so (a s) supplies its exact PIR.cube answer.

Raw exact communication count of K.indexedScheme ι (valid even when D is empty): |S| queries of |D| · |ι| bits, |S| codeword bits, and (2 ^ |D| - |S|) · |ι| non-codeword bits.

Theorem 1's exact communication count for arbitrary radius-1 covers CGKS, Section 3.3, Theorem 1, p. 9: on any nonempty coordinate set (0 < |D|), K.indexedScheme ι communicates k + (2 ^ d + (d - 1) · k) · ℓ bits, with no balancedness assumption on K.

Any ExactRadiusOneCover on d ≥ 1 coordinates yields a k-server IndexedScheme for n ≤ ℓ ^ d communicating k + (2 ^ d + (d - 1) · k) · ℓ bits.

theorem Cslib.Crypto.Protocols.PIR.hasIndexedScheme_of_hammingDist {S D : Type} [Fintype S] [Fintype D] (hD : 0 < Fintype.card D) {c : S → D → Bool} (hinj : Function.Injective c) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ 1) {n ℓ : ℕ} (h : n ≤ ℓ ^ Fintype.card D) :

CGKS Section 3.3, Theorem 1 (general unbalanced form) CGKS, p. 9: if D → Bool (0 < |D|) admits an injective k-word radius-1 covering code c : S → D → Bool, then every n ≤ ℓ ^ |D| has a perfectly correct and perfectly private k-server IndexedScheme communicating k + (2 ^ d + (d - 1) · k) · ℓ bits.

Explicit 7-word unbalanced radius-1 covering code of Fin 5 → Bool (CGKS Figure 1) #

Explicit 7-word radius-1 covering code of {0, 1}^5 attaining optimal size K(5, 1) = 7 listed in CGKS, Figure 1, p. 10. Because 7 ∤ 2 ^ 5, no balanced PIR.RadiusOneCover exists for (d, k) = (5, 7).

Seven servers with 60 · ℓ + 7 bits (d = 5 row of CGKS Figure 1, p. 10) CGKS, Section 3.3: every n ≤ ℓ ^ 5 has a perfectly correct and perfectly private 7-server IndexedScheme communicating 60 · ℓ + 7 bits (saving 10 · ℓ bits over the uniform 70 · ℓ + 7 bound of PIR.RadiusOneCover.hasScheme_of_hammingDist).

General radius-r and radius-2 covering-code schemes #

Index of emulated subcube answers within a Hamming ball of radius r: a disagreement subset coords ⊆ D of size at most r together with candidate coordinates offsets : coords → ι.

  • coords : Finset D

    Subset of coordinates where the emulated cube vertex disagrees with the server's codeword.

  • card_coords_le : self.coords.card ≤ r

    The disagreement set has size at most r.

  • offsets : ↥self.coords → ι

    Candidate target coordinate along each flipped dimension.

Instances For
    def Cslib.Crypto.Protocols.PIR.RadiusBallQuery.sigmaEquiv (D : Type) (r : ℕ) (ι : Type) :
    RadiusBallQuery D r ι ≃ (T : { T : Finset D // T.card ≤ r }) × (↥↑T → ι)

    Equivalence between RadiusBallQuery D r ι and the corresponding dependent pair.

    @[instance_reducible]

    A server emulating a Hamming ball of radius r tabulates ∑ j ≤ r, C(|D|, j) · |ι| ^ j single-bit subcube answers.

    noncomputable def Cslib.Crypto.Protocols.PIR.radiusCoverScheme {S D : Type} [Fintype D] [DecidableEq D] (r : ℕ) (c : S → D → Bool) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ r) (ι : Type) [Fintype ι] [DecidableEq ι] :
    Scheme (D → ι) S Unit (D → ι → Bool) (RadiusBallQuery D r ι → Bool)

    General radius-r covering-code PIR scheme CGKS, Section 3.3, pp. 9–10: given a radius-r covering code c : S → D → Bool, server s receives the subcube query for c s and returns the emulated subcube answer bit for every u : RadiusBallQuery D r ι.

    theorem Cslib.Crypto.Protocols.PIR.eval_serverQuery_radiusCoverScheme {S D : Type} [Fintype D] [DecidableEq D] (r : ℕ) (c : S → D → Bool) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ r) (ι : Type) [Fintype ι] [DecidableEq ι] (s : S) (i : D → ι) :
    ((radiusCoverScheme r c hc ι).serverQuery s i).eval = ((cube D ι).serverQuery (c s) i).eval
    theorem Cslib.Crypto.Protocols.PIR.isPrivate_radiusCoverScheme {S D : Type} [Fintype D] [DecidableEq D] (r : ℕ) (c : S → D → Bool) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ r) (ι : Type) [Fintype ι] [DecidableEq ι] :
    theorem Cslib.Crypto.Protocols.PIR.isCorrect_radiusCoverScheme {S D : Type} [Fintype D] [DecidableEq D] (r : ℕ) (c : S → D → Bool) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ r) (ι : Type) [Fintype ι] [DecidableEq ι] :
    theorem Cslib.Crypto.Protocols.PIR.hasScheme_of_hammingDist_le {S D : Type} [Fintype D] [Fintype S] {r : ℕ} {c : S → D → Bool} (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ r) {n ℓ : ℕ} (h : n ≤ ℓ ^ Fintype.card D) :
    HasScheme (Fin n) (Fintype.card S) (Fintype.card S * (Fintype.card D * ℓ + ∑ j ∈ Finset.range (r + 1), (Fintype.card D).choose j * ℓ ^ j))

    Schemes from radius-r covering codes CGKS, Section 3.3, pp. 9–10: if every word of D → Bool is within Hamming distance r of one of k = |S| codewords, every n ≤ ℓ ^ d has a perfectly correct and perfectly private k-server scheme communicating k · (d · ℓ + ∑ j ≤ r, C(d, j) · ℓ ^ j) bits.

    theorem Cslib.Crypto.Protocols.PIR.hasScheme_of_hammingDist_two {S D : Type} [Fintype D] [Fintype S] {c : S → D → Bool} (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ 2) {n ℓ : ℕ} (h : n ≤ ℓ ^ Fintype.card D) :
    HasScheme (Fin n) (Fintype.card S) (Fintype.card S * (2 * Fintype.card D * ℓ + (Fintype.card D).choose 2 * ℓ ^ 2 + 1))

    Radius-2 covering-code PIR scheme (full-ball count) CGKS, Section 3.3, pp. 9–10: a k-word radius-2 covering code of D → Bool yields a k-server PIR scheme for n ≤ ℓ ^ d communicating k · (2 d ℓ + C(d, 2) · ℓ² + 1) = k · d · ℓ + k · C(d, 2) · ℓ² + k · (d · ℓ + 1) bits (the k · d · ℓ + k · C(d, 2) · ℓ² query and distance-2 answer terms displayed on p. 10 of CGKS, together with the k · (d · ℓ + 1) distance-0 and distance-1 answer bits).

    theorem Cslib.Crypto.Protocols.PIR.hasScheme_of_hammingDist_two_sq {S D : Type} [Fintype D] [Fintype S] {c : S → D → Bool} (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ 2) (hD : 2 ≤ Fintype.card D) {n ℓ : ℕ} (hℓ : 1 ≤ ℓ) (h : n ≤ ℓ ^ Fintype.card D) :

    Coarser polynomial radius-2 bound (k · d · ℓ + k · d² · ℓ²): when 2 ≤ |D| and 1 ≤ ℓ, replacing C(d, 2) by d² absorbs the lower-order k · (d · ℓ + 1) distance-0 and distance-1 answer bits in hasScheme_of_hammingDist_two, giving a k-server scheme for n ≤ ℓ ^ d within k · d · ℓ + k · d² · ℓ² bits.

    The 2-word repetition code {00000, 11111} on Fin 5 → Bool has covering radius 2 (every 5-bit word has at most 2 zeros or at most 2 ones), but not covering radius 1.

    theorem Cslib.Crypto.Protocols.PIR.hasScheme_two_radius_two_of_le_pow_five {n ℓ : ℕ} (h : n ≤ ℓ ^ 5) :
    HasScheme (Fin n) 2 (20 * ℓ ^ 2 + 20 * ℓ + 2)

    Two servers using the radius-2 cover {00000, 11111} of Fin 5 → Bool achieve 20 ℓ² + 20 ℓ + 2 bits for every n ≤ ℓ ^ 5.