Documentation

GaudisCrypt.Examples.PIR

Private information retrieval (EasyCrypt examples/PIR.ec) #

Two-server PIR: to read entry i of a database a replicated on two servers without either server learning i, the client sends the first server a random subset s of the indices [0, N) and the second server s with i flipped; each server returns the xor of the entries it was asked for, and the two answers xor to a i.

EC's file, declaration by declaration and script line by line: correctness (PIR_correct), security by a coupling (PIR_secure1, PIR_secure2 and the two byequiv lemmas), the probability of each query computed in pHL (Pr_PIR_s, Pr_PIR_s' and the two bypr lemmas), and the uniformity equivalences (PIR_s_uniform, PIR_s'_uniform). All of EC's lemmas are proven.

Translation:

Gap list (what keeps the file from reading as EC's):

The file's operators: the length n of words (EC's clone import BitWord as BS), the size N of the database, and the database a.

Instances

    EC's pred sxor.

    Equations
    Instances For
      theorem GaudisCrypt.Examples.PIR.sxor2_cons [Params] (s s' : List ℤ) (i j : ℤ) :
      sxor2 s s' i → sxor2 (j :: s) (j :: s') i
      theorem GaudisCrypt.Examples.PIR.xorw_cancel [Params] (x y z : word) :
      x +^ y +^ (x +^ (z +^ y)) = z ∧ x +^ (z +^ y) +^ (x +^ y) = z

      EC's ring on the answers of PIR_correct.

      Equations
      Instances For
        instance GaudisCrypt.Examples.PIR.instIsGlobalVarListIntSMk :
        PIR.s.IsGlobalVar (VariableName.mk "GaudisCrypt.Examples.PIR.PIR.s" (List ℤ))
        Equations
        Instances For
          instance GaudisCrypt.Examples.PIR.instIsGlobalVarListIntS'Mk :
          PIR.s'.IsGlobalVar (VariableName.mk "GaudisCrypt.Examples.PIR.PIR.s'" (List ℤ))
          theorem GaudisCrypt.Examples.PIR.PIR.main.procedure.apply_simp [Params] (holeArgs✝ : HoleSigs.empty.Instantiation) :
          procedure.instantiate holeArgs✝ = proc (i : ℤ) : word { var j : ℤ, b : Bool, r : word, r' : word; j <- 0; s, s' <- ([], []); while (decide (§j < N)) { b <$ EC.dbool; if (decide (§j = §i)) { if (§b) { s <- §j :: §s; } else { s' <- §j :: §s'; } } else { if (§b) { s <- §j :: §s; s' <- §j :: §s'; } } j <- §j + 1; } r <- call query.procedure (§s); r' <- call query.procedure (§s'); return §r +^ §r' }

          Instantiating the holes of PIR.main.procedure with a tuple holeArgs of procedures: the body of proc main as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.

          Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [PIR.main.procedure.apply_simp]).

          @[simp]

          @[simp]: PIR.query = Module.proc PIR.query.procedure — true by definition, proc query using no module parameter and so having no holes to fill.

          The body of proc query of module PIR, as a procedure of its own: it calls no module parameter, so it has no holes.

          A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see PIR.query.procedure.apply_simp) rather than run. Use PIR.query for this procedure as a module.

          Equations
          • One or more equations did not get rendered due to their size.
          Instances For

            proc query of module PIR as a module: Module.proc PIR.query.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — PIR.query.apply_simp says exactly that.

            Equations
            Instances For

              The body of proc main of module PIR, as a procedure of its own: it calls no module parameter, so it has no holes.

              A hole stands for a call whose callee is not known here — a module parameter is supplied only when the module is applied — so the body is a ProcedureWithHoles, to be instantiated (see PIR.main.procedure.apply_simp) rather than run. Use PIR.main for this procedure as a module.

              Equations
              • One or more equations did not get rendered due to their size.
              Instances For
                theorem GaudisCrypt.Examples.PIR.PIR.query.procedure.apply_simp [Params] (holeArgs✝ : HoleSigs.empty.Instantiation) :
                procedure.instantiate holeArgs✝ = proc (s : List ℤ) : word { skip; return BBS.big EC.predT a §s }

                Instantiating the holes of PIR.query.procedure with a tuple holeArgs of procedures: the body of proc query as written, with each hole call replaced by the matching holeArgs.lookup (HoleIndex.zero being the first hole the body declared). True by rfl.

                Deliberately not @[simp], unlike the other apply_simp lemmas: its right-hand side is the whole body written out, so letting it fire on its own would turn any goal mentioning an instantiated procedure into that body. Inlining a procedure is a step to ask for by name (simp [PIR.query.procedure.apply_simp]).

                proc main of module PIR as a module: Module.proc PIR.main.procedure, of type Module.Proc (procsig …). It uses no module parameter, so it is not a function — PIR.main.apply_simp says exactly that.

                Equations
                Instances For
                  @[simp]

                  @[simp]: PIR.main = Module.proc PIR.main.procedure — true by definition, proc main using no module parameter and so having no holes to fill.

                  The module declared by module PIR: the record of its procedures PIR.query, PIR.main.

                  The declaration has no parameter list, so no procedure of it can call one either and the module is not a function — it is the plain record itself, and there is no PIR.apply_simp to apply it with.

                  Equations
                  Instances For
                    theorem GaudisCrypt.Examples.PIR.PIR_correct [Params] (m : VariableAssignment) (i0 : ℤ) :
                    0 ≤ i0 ∧ i0 < N → Pr[ PIR.main (i0) @ &m : §res = PIR.a i0 ] = 1
                    theorem GaudisCrypt.Examples.PIR.PIR_secure1 [Params] :
                    equiv[ PIR.main (i) ~ PIR.main (i) : True ==> ={PIR.s} ]
                    theorem GaudisCrypt.Examples.PIR.PIR_secure2 [Params] :
                    equiv[ PIR.main (i) ~ PIR.main (i) : True ==> ={PIR.s'} ]
                    theorem GaudisCrypt.Examples.PIR.PIR_secuity_s_byequiv [Params] (i1 i2 : ℤ) (m1 m2 : VariableAssignment) (x : List ℤ) :
                    Pr[ PIR.main (i1) @ &m1 : §PIR.s = x ] = Pr[ PIR.main (i2) @ &m2 : §PIR.s = x ]
                    theorem GaudisCrypt.Examples.PIR.PIR_secuity_s'_byequiv [Params] (i1 i2 : ℤ) (m1 m2 : VariableAssignment) (x : List ℤ) :
                    Pr[ PIR.main (i1) @ &m1 : §PIR.s' = x ] = Pr[ PIR.main (i2) @ &m2 : §PIR.s' = x ]

                    Alternative proof: we show that the distribution of PIR.s and PIR.s' is uniform. First version: we use phoare.

                    EC's op restr (s : int fset) n = s & oflist (iota_ 0 n).

                    Equations
                    Instances For
                      theorem GaudisCrypt.Examples.PIR.mem_restr [Params] (s : EC.FSet ℤ) (n x : ℤ) :
                      x ∈ restr s n ↔ x ∈ s ∧ 0 ≤ x ∧ x < n

                      Membership in restr s n (EC's rewrite /restr in_fsetI mem_oflist mem_iota).

                      theorem GaudisCrypt.Examples.PIR.is_restr_Ueq [Params] (n : ℤ) (s1 s2 : EC.FSet ℤ) :
                      is_restr s1 n → is_restr s2 n → (EC.FSet.fset1 n ∪ s1 = EC.FSet.fset1 n ∪ s2) = (s1 = s2)
                      theorem GaudisCrypt.Examples.PIR.is_restrS [Params] (n : ℤ) (s : EC.FSet ℤ) :
                      0 ≤ n → is_restr s n → is_restr s (n + 1)

                      Other version without explicit computation of the probability: we first show that the probability is uniform. (EC: "unfortunately this does not allow to conclude in EasyCrypt. We need to be able to do the projection of memories.")

                      theorem GaudisCrypt.Examples.PIR.PIR_s_uniform [Params] (x1 x2 : EC.FSet ℤ) :
                      0 ≤ N → is_restr x1 N → is_restr x2 N → equiv[ PIR.main (i) ~ PIR.main (i) : ={i} ==> (EC.FSet.oflist §PIR.s{1} = x1) = (EC.FSet.oflist §PIR.s{2} = x2) ]
                      theorem GaudisCrypt.Examples.PIR.PIR_s'_uniform [Params] (x1 x2 : EC.FSet ℤ) :
                      0 ≤ N → is_restr x1 N → is_restr x2 N → equiv[ PIR.main (i) ~ PIR.main (i) : ={i} ==> (EC.FSet.oflist §PIR.s'{1} = x1) = (EC.FSet.oflist §PIR.s'{2} = x2) ]