-
Notifications
You must be signed in to change notification settings - Fork 0
/
threaded_psi_pir.go
62 lines (43 loc) · 966 Bytes
/
threaded_psi_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
53
54
55
56
57
58
59
60
61
62
package main
import (
"math/rand"
"math"
"fmt"
"sync"
"time"
pir_psi "checklist/pir-psi"
db "checklist/db"
)
func rangeIn(low, hi int) uint64 {
return uint64(low + rand.Intn(hi-low))
}
func main() {
contacts := make([]uint64, 1000)
for i:=0; i < len(contacts); i++ {
contacts[i] = rangeIn(1000000000, 9999999999)
}
nBuckets := int(math.Pow(2, 26))
nPartitions := 64
nRows := int(math.Pow(2, 27))
dummyQueries := 84
metaSize := uint8(0)
data := db.New(nBuckets, nPartitions, nRows, metaSize)
schemes := make([]*pir_psi.PIR_PSI, 10)
for i:=0; i < 10; i++ {
schemes[i] = pir_psi.New(data)
}
var wg sync.WaitGroup
wg.Add(10)
var lock sync.Mutex
s1 := time.Now()
for i:=0; i < 10; i++ {
go func(i int) {
defer wg.Done()
schemes[i].OnlinePhaseThreaded(contacts, dummyQueries, 4, metaSize, &lock)
} (i)
}
wg.Wait()
t1 := time.Now()
fmt.Print("Time to answer all client queries: ")
fmt.Println(t1.Sub(s1))
}