Documentation

CslibFrontier.Crypto.Protocols.PIR.CoveringCode

Covering-code schemes for private information retrieval #

The subcube scheme PIR.cube uses 2 ^ d servers, one for each σ : D → Bool. The covering-code method of Chor, Goldreich, Kushilevitz and Sudan, Section 3.3 keeps only the servers of a radius-1 covering code of D → Bool and lets each of them emulate its neighbours.

The server σ knows its query (T l ⊕ σ l e_{i l})_l. The query of the neighbour that differs from it at l differs from it only in the l-th set, by flipping one unknown position i l. So σ can send the answers for all ℓ choices of that position, and the user picks the right one. The kept servers receive the queries of PIR.cube, so privacy is inherited (PIR.RadiusOneCover.isPrivate_scheme). The user recovers the 2 ^ d answers of PIR.cube, so correctness is too (PIR.RadiusOneCover.isCorrect_scheme).

A PIR.RadiusOneCover S D M fixes this data, following the footnote to Section 3.3 (an exact cover of the cube by subsets of the radius-1 balls):

The volume bound 2 ^ d ≤ |S| (|M| + 1) follows (PIR.RadiusOneCover.two_pow_card_le).

Communication. The library measures communication with fixed-length queries and answers (PIR.communication), so every server answers with 1 + |M| ℓ bits, as if it emulated |M| neighbours. The scheme communicates k ((d + m) ℓ + 1) bits, where k = |S| and m = |M| (PIR.RadiusOneCover.communication_scheme). The source counts k + (2 ^ d - k) ℓ answer bits instead, emulating each non-codeword once with possibly different answer lengths. The two counts agree when the cover is balanced, k (m + 1) = 2 ^ d (PIR.RadiusOneCover.communication_scheme_of_balanced): cover is then a bijection, so every server emulates m distinct neighbours and no word is produced twice. The count is then the bound k + (2 ^ d + (d - 1) k) ℓ of Theorem 1. Balance is a property of the cover; the source's "balancing" (end of Section 3.2, Section 3.4) refers instead to the split of communication between the user and the servers. Variable-length per-server answers and radius-r covers are formalized in PIR.Indexed and PIR.GeneralCover (PIR.hasIndexedScheme_of_hammingDist proves Theorem 1 for arbitrary injective radius-1 covering codes); in the uniform fixed-length model here, Theorem 1 is covered for balanced covers only. Every radius-1 covering code gives a cover with M = D, emulating all neighbours (PIR.RadiusOneCover.ofHammingDist), with k (2 d ℓ + 1) bits; this is the bound of Theorem 1 exactly when the code is perfect.

A new cover of a concrete cube Fin d → Bool can be supplied by discharging coveredWord_cover with decide, as for PIR.RadiusOneCover.cubeThree and PIR.RadiusOneCover.cubeFour.

Both cases of Corollary 2 use balanced covers:

Main definitions #

Main results #

References #

def Cslib.Crypto.Protocols.PIR.RadiusOneCover.coveredWord {S D M : Type} [DecidableEq D] (code : S → D → Bool) (dir : S → M → D) :
S × Option M → D → Bool

The word produced by the server s and an optional direction r: the codeword code s, or the codeword with the coordinate dir s r flipped. Exposed so that downstream modules can check the obligation coveredWord_cover of a concrete cover by decide.

A radius-1 cover of the cube D → Bool by the servers S CGKS, Section 3.3. The server s has the codeword code s and emulates the neighbours of code s in the directions dir s r, for r : M. Every word is produced by the server and the optional direction that cover assigns to it.

  • code : S → D → Bool

    The codeword of each server.

  • dir : S → M → D

    The directions of the neighbours that each server emulates.

  • cover : (D → Bool) → S × Option M

    The server, and possibly the direction, that produce each word.

  • coveredWord_cover (w : D → Bool) : coveredWord self.code self.dir (self.cover w) = w

    Each word is produced by its assigned server and direction.

@[simp]
theorem Cslib.Crypto.Protocols.PIR.RadiusOneCover.coveredWord_none {S D M : Type} [DecidableEq D] (code : S → D → Bool) (dir : S → M → D) (s : S) :
coveredWord code dir (s, none) = code s
@[simp]
theorem Cslib.Crypto.Protocols.PIR.RadiusOneCover.coveredWord_some {S D M : Type} [DecidableEq D] (code : S → D → Bool) (dir : S → M → D) (s : S) (r : M) :
coveredWord code dir (s, some r) = Function.update (code s) (dir s r) !code s (dir s r)

The volume bound CGKS, Section 3.3: a server and its |M| emulated neighbours produce at most |M| + 1 words, so 2 ^ d ≤ |S| (|M| + 1).

The scheme #

def Cslib.Crypto.Protocols.PIR.RadiusOneCover.readAnswer {S D M : Type} [DecidableEq D] (K : RadiusOneCover S D M) {ι : Type} (j : D → ι) :
S × Option M → (S → Bool × (M → ι → Bool)) → Bool

The answer of the 2 ^ d-server scheme that the user reads for the word produced by the server s and the optional direction r: the answer bit of s itself, or the emulated answer for the position j of the flipped coordinate.

noncomputable def Cslib.Crypto.Protocols.PIR.RadiusOneCover.scheme {S D M : Type} [DecidableEq D] (K : RadiusOneCover S D M) [Fintype D] (ι : Type) [Fintype ι] [DecidableEq ι] :
Scheme (D → ι) S Unit (D → ι → Bool) (Bool × (M → ι → Bool))

The covering-code scheme CGKS, Section 3.3. The server s receives the query of PIR.cube for the server code s. It answers with the answer bit of PIR.cube and, for each direction l = dir s r and each position k : ι, with the answer of PIR.cube to the query with e_k added to its l-th set. The user reads the answer of every server of PIR.cube from the emulating server and adds them.

theorem Cslib.Crypto.Protocols.PIR.RadiusOneCover.query_scheme {S D M : Type} [DecidableEq D] (K : RadiusOneCover S D M) [Fintype D] {ι : Type} [Fintype ι] [DecidableEq ι] (i : D → ι) :
(K.scheme ι).query Bool i = (fun (rq : Unit × ((D → Bool) → D → ι → Bool)) => (rq.1, fun (s : S) => rq.2 (K.code s))) <$> (cube D ι).query Bool i
theorem Cslib.Crypto.Protocols.PIR.RadiusOneCover.reconstruct_scheme {S D M : Type} [DecidableEq D] (K : RadiusOneCover S D M) [Fintype D] {ι : Type} [Fintype ι] [DecidableEq ι] (i : D → ι) (r : Unit) (a : S → Bool × (M → ι → Bool)) :
(K.scheme ι).reconstruct Bool i r a = ∑ w : D → Bool, K.readAnswer i (K.cover w) a
theorem Cslib.Crypto.Protocols.PIR.RadiusOneCover.eval_serverQuery_scheme {S D M : Type} [DecidableEq D] (K : RadiusOneCover S D M) [Fintype D] {ι : Type} [Fintype ι] [DecidableEq ι] (s : S) (i : D → ι) :
((K.scheme ι).serverQuery s i).eval = ((cube D ι).serverQuery (K.code s) i).eval

The server s of the covering-code scheme receives the query of the server code s of PIR.cube.

The covering-code scheme is private CGKS, Section 3.3: its queries are those of PIR.cube.

The covering-code scheme is correct CGKS, Section 3.3: the user reads the answer of every server of PIR.cube.

The covering-code scheme sends d sets of ℓ bits to each of the k servers and receives 1 + m ℓ bits from each, in the fixed-length measure: k ((d + m) ℓ + 1) bits.

Theorem 1's count for balanced covers CGKS, Theorem 1: when the k servers and their m emulated neighbours each produce exactly the 2 ^ d words, k (m + 1) = 2 ^ d, the scheme communicates k + (2 ^ d + (d - 1) k) ℓ bits. (Balanced is a property of the cover, not the source's balancing of user and server communication.)

Schemes from radius-1 covers CGKS, Section 3.3: with a cover of D → Bool by k servers each emulating m neighbours, every n ≤ ℓ ^ d has a perfectly correct and perfectly private k-server scheme for n-bit databases communicating k ((d + m) ℓ + 1) bits.

Covers from covering codes #

noncomputable def Cslib.Crypto.Protocols.PIR.RadiusOneCover.ofHammingDist {S D : Type} [DecidableEq D] [Fintype D] (c : S → D → Bool) (hc : ∀ (w : D → Bool), ∃ (s : S), hammingDist (c s) w ≤ 1) :

The cover of a radius-1 covering code c : S → D → Bool in which every server emulates all its neighbours: each word is assigned a codeword within distance 1 and the coordinate where they differ, if any.

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

Schemes from radius-1 covering codes CGKS, Section 3.3: if every word of D → Bool is within Hamming distance 1 of one of k codewords, every n ≤ ℓ ^ d has a perfectly correct and perfectly private k-server scheme for n-bit databases communicating k (2 d ℓ + 1) bits. Each server emulates all d neighbours of its codeword. This matches Theorem 1's k + (2 ^ d + (d - 1) k) ℓ when the code is perfect, k (d + 1) = 2 ^ d, and exceeds it by (k (d + 1) - 2 ^ d) ℓ in general.

The covers of Corollary 2 #

The repetition code {000, 111} covers the cube Fin 3 → Bool with radius 1 CGKS, Section 3.3. Each codeword emulates its three neighbours, so the cover is balanced: 2 (3 + 1) = 2 ^ 3.

The code {0000, 1111, 1000, 0111} covers the cube Fin 4 → Bool with radius 1 CGKS, Section 3.3. The codeword of (a, b) is a b b b, and each codeword emulates its neighbours in the last three coordinates, so the cover is balanced: 4 (3 + 1) = 2 ^ 4.

theorem Cslib.Crypto.Protocols.PIR.hasScheme_two_of_le_pow_three {n ℓ : ℕ} (h : n ≤ ℓ ^ 3) :
HasScheme (Fin n) 2 (12 * ℓ + 2)

Two servers with 12 ℓ + 2 bits CGKS, Corollary 2: every n ≤ ℓ ^ 3 has a perfectly correct and perfectly private two-server scheme for n-bit databases communicating 12 ℓ + 2 bits. With ℓ = ⌈n ^ (1/3)⌉ this is the source's 12 n ^ (1/3) + 2.

theorem Cslib.Crypto.Protocols.PIR.hasScheme_four_of_le_pow_four {n ℓ : ℕ} (h : n ≤ ℓ ^ 4) :
HasScheme (Fin n) 4 (28 * ℓ + 4)

Four servers with 28 ℓ + 4 bits CGKS, Corollary 2: every n ≤ ℓ ^ 4 has a perfectly correct and perfectly private four-server scheme for n-bit databases communicating 28 ℓ + 4 bits. With ℓ = ⌈n ^ (1/4)⌉ this is the source's 28 n ^ (1/4) + 4.