Documentation

CslibFrontier.Crypto.Protocols.PIR.SmoothConverse

Smooth codes from private information retrieval schemes #

In the converse direction to PIR.SmoothCode (Yekhanin, Lemma 6.2), Goldreich, Karloff, Schulman and Trevisan, Lemma 7.1 (after Katz and Trevisan, restated for perfectly private two-server schemes as Kerenidis and de Wolf, Appendix B, Lemma 3) converts any one-round PIR scheme into a smooth code by tabulating all server answers and duplicating heavily queried entries.

Given a one-round scheme P : PIR.Scheme ι S R Q A over finite server and query alphabets S, Q (l = |S| · |Q|) and a reference index i₀ : ι:

Model boundaries #

In GKST Definition 2.1, smoothness bounds the probability of querying each position j by c / m for a non-adaptive decoder. Here smoothDecoder P i₀ draws all query positions before making any oracle call, makes zero queries in failure mode, and otherwise queries one position per distinct server s : S, so no execution queries the same position j twice; expected reads and query probability therefore coincide, and bounding Code.expectedReads establishes Code.IsSmoothDecoder. Neither machine running time nor fair-coin simulation of rational unifFin draws is certified here.

Main definitions #

Main results #

References #

def Cslib.Crypto.Protocols.PIR.smoothCopies {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (sq : S × Q) :

Replication count max 1 ⌈p₀(s, q) · (|S| · |Q|)⌉₊ of server-query pair sq = (s, q) in the GKST smooth-code construction with reference index i₀ GKST, Section 7.1, Lemma 7.1. Clamping below at 1 matches the proof's low-probability case (p_j ≤ 1 / l gets one copy even when p_j = 0) without increasing the (k + 1) k |Q| length bound.

theorem Cslib.Crypto.Protocols.PIR.smoothCopies_eq {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (sq : S × Q) :
smoothCopies P i₀ sq = max 1 ⌈(P.serverQuery sq.1 i₀).evalRat sq.2 * (↑(Fintype.card S) * ↑(Fintype.card Q))⌉₊
theorem Cslib.Crypto.Protocols.PIR.smoothCopies_pos {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (sq : S × Q) :
0 < smoothCopies P i₀ sq
@[reducible, inline]
abbrev Cslib.Crypto.Protocols.PIR.SmoothPos {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) :

Codeword positions of the GKST smooth code: pairs ⟨(s, q), idx⟩ with idx ranging over the smoothCopies P i₀ (s, q) copies of (s, q).

def Cslib.Crypto.Protocols.PIR.smoothCode {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (x : ι → Bool) :
SmoothPos P i₀ → A

The GKST smooth code C : (ι → Bool) → SmoothPos P i₀ → A: every copy of (s, q) stores P.answer s x q GKST, Section 7.1, Lemma 7.1.

@[simp]
theorem Cslib.Crypto.Protocols.PIR.smoothCode_apply {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (x : ι → Bool) (sq : S × Q) (idx : Fin (smoothCopies P i₀ sq)) :
smoothCode P i₀ x ⟨sq, idx⟩ = P.answer Bool sq.1 x sq.2
theorem Cslib.Crypto.Protocols.PIR.card_smoothPos_le {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) :

Codeword length bound (GKST, Lemma 7.1): the replicated table has at most (|S| + 1) · |S| · |Q| positions.

theorem Cslib.Crypto.Protocols.PIR.card_smoothPos_le_six_mul {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (hS : Fintype.card S = 2) (i₀ : ι) :

Two-server specialization of card_smoothPos_le: m ≤ 6 · |Q| (GKST, Lemma 7.1; Kerenidis and de Wolf, Appendix B, Lemma 3).

Linearity preservation (GKST Lemma 7.1, item 1) #

theorem Cslib.Crypto.Protocols.PIR.smoothCode_zero {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] [Zero A] (hzero : ∀ (s : S) (q : Q), P.answer Bool s 0 q = 0) (i₀ : ι) :
smoothCode P i₀ 0 = 0
theorem Cslib.Crypto.Protocols.PIR.smoothCode_add {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] [Add A] (hadd : ∀ (s : S) (x y : ι → Bool) (q : Q), P.answer Bool s (x + y) q = P.answer Bool s x q + P.answer Bool s y q) (i₀ : ι) (x y : ι → Bool) :
smoothCode P i₀ (x + y) = smoothCode P i₀ x + smoothCode P i₀ y
def Cslib.Crypto.Protocols.PIR.smoothCodeAddHom {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] [AddZeroClass A] (hzero : ∀ (s : S) (q : Q), P.answer Bool s 0 q = 0) (hadd : ∀ (s : S) (x y : ι → Bool) (q : Q), P.answer Bool s (x + y) q = P.answer Bool s x q + P.answer Bool s y q) (i₀ : ι) :
(ι → Bool) →+ SmoothPos P i₀ → A

Linearity preservation (GKST, Lemma 7.1, item 1): when each server's answer map x ↦ P.answer s x q is an additive homomorphism (for instance, XOR linear combinations of database bits over GF(2)), smoothCode P i₀ is an AddMonoidHom.

The GKST smooth decoder #

Upfront random coins sampled by smoothDecoder before making any oracle query.

  • state : R

    Client private state from P.query i.

  • guess : Bool

    Uniform fallback bit returned when any server slot enters failure mode.

  • slots : Fin k → Option Pos

    Per-server optional codeword position (none signals failure mode on that slot).

def Cslib.Crypto.Protocols.PIR.smoothKeepRatio {ι S R Q A : Type} (P : Scheme ι S R Q A) [DecidableEq Q] (i₀ i : ι) (s : S) (q : Q) :

Acceptance probability ratio p₀(s, q) / pᵢ(s, q) (clamped to 1 when pᵢ ≤ p₀) used by the GKST statistical-privacy rejection step GKST, Section 7.1, Lemma 7.1, p. 20.

theorem Cslib.Crypto.Protocols.PIR.smoothKeepRatio_eq {ι S R Q A : Type} (P : Scheme ι S R Q A) [DecidableEq Q] (i₀ i : ι) (s : S) (q : Q) :
smoothKeepRatio P i₀ i s q = if (P.serverQuery s i).evalRat q ≤ (P.serverQuery s i₀).evalRat q then 1 else (P.serverQuery s i₀).evalRat q / (P.serverQuery s i).evalRat q
noncomputable def Cslib.Crypto.Protocols.PIR.smoothCoins {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ i : ι) :

Upfront private-coin draw of the GKST smooth decoder before making any oracle queries.

noncomputable def Cslib.Crypto.Protocols.PIR.smoothDecoder {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) :

GKST smooth decoder (GKST, Section 7.1, Lemma 7.1): sample st ← smoothCoins P i₀ i; if every server slot survived (∀ idx, (st.slots idx).isSome), read all |S| selected codeword positions non-adaptively via Code.readAll and run P.reconstruct i st.state; otherwise output the uniform fallback bit st.guess without querying the codeword.

theorem Cslib.Crypto.Protocols.PIR.isQueryBounded_smoothDecoder {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ i : ι) :
theorem Cslib.Crypto.Protocols.PIR.expectedReads_smoothDecoder_le {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [DecidableEq S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (y : SmoothPos P i₀ → A) (i : ι) (j : SmoothPos P i₀) :
(Code.expectedReads (smoothDecoder P i₀ i) y j).toReal ≤ (↑(Fintype.card S) + 1) / ↑(Fintype.card (SmoothPos P i₀))

Smoothness of the GKST decoder: against every received word y (obliviously), each position j : SmoothPos P i₀ is read at most (|S| + 1) / |SmoothPos P i₀| times in expectation.

theorem Cslib.Crypto.Protocols.PIR.toReal_decodeLaw_smoothDecoder_ge {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) {δ ε : ℝ} (hδ : 0 ≤ δ) (hpriv : P.IsStatPrivateAt i₀ δ) (hrec : P.Recovers ε) (x : ι → Bool) (i : ι) :
1 / 2 + (ε - ↑(Fintype.card S) * δ / 2) ≤ ((Code.decodeLaw (smoothDecoder P i₀ i) (smoothCode P i₀ x)) (x i)).toReal

Recovery bound of the GKST decoder: when each server's query distributions are δ-close in total variation (CloseTo) to those at the reference index i₀ (in particular under pairwise δ-closeness) and P recovers x i with probability at least 1 / 2 + ε, smoothDecoder P i₀ recovers x i from smoothCode P i₀ x with probability at least 1 / 2 + ε - |S| · δ / 2.

theorem Cslib.Crypto.Protocols.PIR.isSmoothDecoder_smoothDecoder {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [DecidableEq S] [Fintype Q] [DecidableEq Q] (i₀ : ι) {δ ε : ℝ} (hδ : 0 ≤ δ) (hpriv : P.IsStatPrivateAt i₀ δ) (hrec : P.Recovers ε) :
Code.IsSmoothDecoder (smoothCode P i₀) (Fintype.card S) (↑(Fintype.card S) + 1) (ε - ↑(Fintype.card S) * δ / 2) (smoothDecoder P i₀)

GKST Lemma 7.1 (general k = |S| servers): a one-round PIR scheme P whose server query distributions are δ-close (CloseTo) to those at the reference index i₀ (in particular when pairwise δ-close) and which recovers each bit with probability at least 1 / 2 + ε yields a (|S|, |S| + 1, ε - |S| · δ / 2)-smooth decoder for smoothCode P i₀ (with codeword length ≤ (|S| + 1) · |S| · |Q|) GKST, Section 7.1, Lemma 7.1.

theorem Cslib.Crypto.Protocols.PIR.isSmoothDecoder_smoothDecoder_two {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [DecidableEq S] [Fintype Q] [DecidableEq Q] (hS : Fintype.card S = 2) (i₀ : ι) {δ ε : ℝ} (hδ : 0 ≤ δ) (hpriv : P.IsStatPrivateAt i₀ δ) (hrec : P.Recovers ε) :
Code.IsSmoothDecoder (smoothCode P i₀) 2 3 (ε - δ) (smoothDecoder P i₀)

GKST Lemma 7.1 (two servers): a (1 - δ)-statistically-private two-server PIR scheme with recovery probability at least 1 / 2 + ε yields a (2, 3, ε - δ)-smooth code of length at most 6 · |Q| GKST, Section 7.1, Lemma 7.1.

Perfect-privacy specializations (δ = 0) #

theorem Cslib.Crypto.Protocols.PIR.decodeLaw_smoothDecoder_of_isPrivate {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [Fintype Q] [DecidableEq Q] (hpriv : P.IsPrivate) (i₀ : ι) (x : ι → Bool) (i : ι) :
Code.decodeLaw (smoothDecoder P i₀ i) (smoothCode P i₀ x) = (P.run x i).eval

Under perfect privacy (P.IsPrivate), smoothDecoder P i₀ never enters failure mode, so its output law on smoothCode P i₀ x equals ProbComp.eval (P.run x i) exactly.

theorem Cslib.Crypto.Protocols.PIR.isSmoothDecoder_smoothDecoder_of_isPrivate {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [DecidableEq S] [Fintype Q] [DecidableEq Q] (hpriv : P.IsPrivate) (i₀ : ι) {ε : ℝ} (hrec : P.Recovers ε) :

Perfect-privacy PIR-to-smooth-code converse (δ = 0 specialization of GKST Lemma 7.1; at |S| = 2, Kerenidis and de Wolf, Appendix B, Lemma 3): a perfectly private k-server PIR scheme with recovery probability at least 1 / 2 + ε yields a (|S|, |S| + 1, ε)-smooth decoder for smoothCode P i₀ (with codeword length ≤ (|S| + 1) · |S| · |Q|).

theorem Cslib.Crypto.Protocols.PIR.isSmoothDecoder_smoothDecoder_of_isCorrect {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype S] [DecidableEq S] [Fintype Q] [DecidableEq Q] (hcorrect : P.IsCorrect) (hpriv : P.IsPrivate) (i₀ : ι) :
Code.IsSmoothDecoder (smoothCode P i₀) (Fintype.card S) (↑(Fintype.card S) + 1) (1 / 2) (smoothDecoder P i₀)

Perfectly correct and perfectly private k-server PIR yields a (|S|, |S| + 1, 1 / 2)-smooth code of length at most (|S| + 1) · |S| · |Q| (converse to PIR.SmoothCode.hasScheme_ofDecoder).

Predetermined answer coordinates (GKST Lemma 7.1, item 2) #

theorem Cslib.Crypto.Protocols.PIR.smoothDecoder_eq_of_predetermined {ι S R Q κ γ : Type} [DecidableEq κ] (P : Scheme ι S R Q (κ → γ)) [Fintype S] [Fintype Q] [DecidableEq Q] (i₀ : ι) (sel : ι → R → S → Finset κ) (pad : γ) (hpred : ∀ (i : ι) (r : R) (a a' : S → κ → γ), (∀ (s : S), ∀ b ∈ sel i r s, a s b = a' s b) → P.reconstruct Bool i r a = P.reconstruct Bool i r a') (i : ι) :
smoothDecoder P i₀ i = do let st ← ProbOracleComp.sample (smoothCoins P i₀ i) if h : ∀ (idx : Fin (Fintype.card S)), (st.slots idx).isSome = true then do let ans ← Code.readAll fun (idx : Fin (Fintype.card S)) => (st.slots idx).get ⋯ have masked : S → κ → γ := fun (s : S) (b : κ) => if b ∈ sel i st.state s then ans ((Fintype.equivFin S) s) b else pad pure (P.reconstruct Bool i st.state masked) else pure st.guess

Predetermined answer-coordinate preservation (GKST, Lemma 7.1, item 2): when P.reconstruct i r inspects at most a predetermined coordinate subset sel i r s : Finset κ of each server's answer a s : κ → γ (for example, k predetermined bit positions out of an a-bit answer), masking every coordinate outside sel i st.state s in the retrieved codeword symbols with any pad : γ leaves smoothDecoder P i₀ i unchanged. Together with smoothCoins P i₀ i, this exhibits both the queried codeword positions st.slots and the predetermined coordinate subsets sel i st.state s for each coin draw st.

Single-server noisy and statistically-private answer-size lower bounds #

theorem Cslib.Crypto.Protocols.PIR.card_mul_sq_le_card_answer_sub_one_of_statPrivate {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype ι] [Unique S] [Finite Q] [Fintype A] [Nonempty A] {δ ε : ℝ} (hδ : 0 ≤ δ) (hε : δ / 2 ≤ ε) (hpriv : P.IsStatPrivate δ) (hrec : P.Recovers ε) :
↑(Fintype.card ι) * (ε - δ / 2) ^ 2 ≤ ↑(Fintype.card A) - 1

Noisy / statistically-private single-server PIR answer-size lower bound (combining GKST Lemma 7.1 at |S| = 1 with Code.IsSmoothDecoder.four_mul_card_mul_sq_le from OneQuery.lean): any one-server PIR scheme over a finite query set whose query distributions are pairwise δ-close (0 ≤ δ) and which recovers each database bit with probability at least 1 / 2 + ε (δ / 2 ≤ ε) has answer alphabet size satisfying |ι| · (ε - δ / 2)² ≤ |A| - 1.

theorem Cslib.Crypto.Protocols.PIR.card_mul_sq_le_card_answer_sub_one_of_isPrivate {ι S R Q A : Type} (P : Scheme ι S R Q A) [Fintype ι] [Unique S] [Finite Q] [Fintype A] [Nonempty A] (hpriv : P.IsPrivate) {ε : ℝ} (hε : 0 ≤ ε) (hrec : P.Recovers ε) :
↑(Fintype.card ι) * ε ^ 2 ≤ ↑(Fintype.card A) - 1

Noisy perfectly-private single-server PIR answer-size lower bound (δ = 0 case of card_mul_sq_le_card_answer_sub_one_of_statPrivate): any perfectly private one-server PIR scheme over a finite query set recovering each bit with probability at least 1 / 2 + ε (0 ≤ ε) satisfies |ι| · ε² ≤ |A| - 1.