-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpredicate_pir.go
51 lines (43 loc) · 1.4 KB
/
predicate_pir.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package client
import (
"io"
"github.com/si-co/vpir-code/lib/database"
"github.com/si-co/vpir-code/lib/fss"
"github.com/si-co/vpir-code/lib/query"
)
// PredicatePIR represent the client for the FSS-based complex-queries non-verifiable PIR
type PredicatePIR struct {
*clientFSS
}
// NewPredicatePIR returns a new client for the DPF-base multi-bit classical PIR
// scheme
func NewPredicatePIR(rnd io.Reader, info *database.Info) *PredicatePIR {
executions := 1
return &PredicatePIR{
&clientFSS{
rnd: rnd,
dbInfo: info,
state: nil,
Fss: fss.ClientInitialize(executions), // only one value
executions: executions,
},
}
}
// QueryBytes executes Query and encodes the result a byte array for each
// server
func (c *PredicatePIR) QueryBytes(in []byte, numServers int) ([][]byte, error) {
return c.clientFSS.queryBytes(in, numServers)
}
// Query outputs the queries, i.e. DPF keys, for index i. The DPF
// implementation assumes two servers.
func (c *PredicatePIR) Query(q *query.ClientFSS, numServers int) []*query.FSS {
return c.query(q, numServers)
}
// ReconstructBytes returns []byte
func (c *PredicatePIR) ReconstructBytes(answers [][]byte) (interface{}, error) {
return c.reconstructBytes(answers)
}
// Reconstruct reconstruct the entry of the database from answers
func (c *PredicatePIR) Reconstruct(answers [][]uint32) (uint32, error) {
return c.reconstruct(answers)
}