-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpsi_pir_hybrid.go
56 lines (38 loc) · 1.17 KB
/
psi_pir_hybrid.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
53
54
55
56
package main
import (
"math/rand"
"math"
"fmt"
pir_psi "checklist/pir-psi"
db "checklist/db"
)
func rangeIn(low, hi int) uint64 {
return uint64(low + rand.Intn(hi-low))
}
func main() {
// dummies[i] should be number of dummy queries necessary for partitions[i] partitions
partitions := []int{16, 32, 64}
dummies := []int{214, 131, 84}
// create 1000 random contacts
contacts := make([]uint64, 1000)
for i:=0; i < len(contacts); i++ {
contacts[i] = rangeIn(1000000000, 9999999999)
}
// for each partition
for j:=0; j<len(partitions); j++ {
fmt.Print(partitions[j])
fmt.Println(" total partitions")
nBuckets := int(math.Pow(2, 26))
nPartitions := partitions[j]
nRows := int(math.Pow(2, 27))
dummyQueries := dummies[j]
// number of bytes of account identifier/key data, set to 0 for none
metadataLength := uint8(56)
// create a CF database with above params
data := db.New(nBuckets, nPartitions, nRows, metadataLength)
// generates hints (this function prints offline metrics)
scheme := pir_psi.New(data)
// run online phase (this function prints online metrics)
scheme.OnlinePhase(contacts, dummyQueries, 4, metadataLength)
}
}