-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpredicate_pir.go
52 lines (42 loc) · 1.23 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
52
package server
import (
"runtime"
"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 server for the FSS-based complex-queries unauthenticated PIR
type PredicatePIR struct {
*serverFSS
}
// NewPredicatePIR initializes and returns a new server for FSS-based classical PIR
func NewPredicatePIR(db *database.DB, serverNum byte, cores ...int) *PredicatePIR {
numCores := runtime.NumCPU()
if len(cores) > 0 {
numCores = cores[0]
}
return &PredicatePIR{
&serverFSS{
db: db,
cores: numCores,
serverNum: serverNum,
fss: fss.ServerInitialize(1), // only one value for data
},
}
}
// DBInfo returns database info
func (s *PredicatePIR) DBInfo() *database.Info {
return s.serverFSS.dbInfo()
}
// AnswerBytes computes the answer for the given query encoded in bytes
func (s *PredicatePIR) AnswerBytes(q []byte) ([]byte, error) {
out := make([]uint32, 1)
tmp := make([]uint32, 1)
return s.serverFSS.answerBytes(q, out, tmp)
}
// Answer computes the answer for the given query
func (s *PredicatePIR) Answer(q *query.FSS) []uint32 {
out := []uint32{0}
tmp := []uint32{0}
return s.serverFSS.answer(q, out, tmp)
}