-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathpredicate_apir.go
51 lines (41 loc) · 1.29 KB
/
predicate_apir.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 server
import (
"runtime"
"github.com/si-co/vpir-code/lib/database"
"github.com/si-co/vpir-code/lib/field"
"github.com/si-co/vpir-code/lib/fss"
"github.com/si-co/vpir-code/lib/query"
)
// PredicateAPIR represent the server for the FSS-based complex-queries authenticated PIR
type PredicateAPIR struct {
*serverFSS
}
func NewPredicateAPIR(db *database.DB, serverNum byte, cores ...int) *PredicateAPIR {
// use variadic argument for cores to achieve backward compatibility
numCores := runtime.NumCPU()
if len(cores) > 0 {
numCores = cores[0]
}
return &PredicateAPIR{
&serverFSS{
db: db,
cores: numCores,
serverNum: serverNum,
// one value for the data, four values for the info-theoretic MAC
fss: fss.ServerInitialize(1 + field.ConcurrentExecutions),
},
}
}
func (s *PredicateAPIR) DBInfo() *database.Info {
return s.serverFSS.dbInfo()
}
func (s *PredicateAPIR) AnswerBytes(q []byte) ([]byte, error) {
out := make([]uint32, 1+field.ConcurrentExecutions)
tmp := make([]uint32, 1+field.ConcurrentExecutions)
return s.serverFSS.answerBytes(q, out, tmp)
}
func (s *PredicateAPIR) Answer(q *query.FSS) []uint32 {
out := make([]uint32, 1+field.ConcurrentExecutions)
tmp := make([]uint32, 1+field.ConcurrentExecutions)
return s.serverFSS.answer(q, out, tmp)
}