|
@@ -20,7 +20,9 @@ import (
|
|
|
"encoding/json"
|
|
|
"fmt"
|
|
|
"math/big"
|
|
|
+ mr "math/rand"
|
|
|
"net"
|
|
|
+ "sort"
|
|
|
"sync"
|
|
|
"time"
|
|
|
"unsafe"
|
|
@@ -326,7 +328,6 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
|
|
|
|
|
|
|
|
|
if len(tmptopicsOfInterest) < tmpNeededSubscriptions && subPhase != -1 {
|
|
|
-
|
|
|
tmptopicsOfInterest = addFakeInterests(tmptopicsOfInterest)
|
|
|
}
|
|
|
|
|
@@ -502,39 +503,38 @@ func createSharedSecret() [numClients][2][32]byte {
|
|
|
return tmpSharedSecret
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
|
|
|
func addFakeInterests(topicsOfInterest []int) []int {
|
|
|
- length := neededSubscriptions
|
|
|
- fakeTopicsOfInterest := make([]int, length)
|
|
|
+ fakeTopicsOfInterest := make([]int, neededSubscriptions)
|
|
|
+ maxInt := neededSubscriptions
|
|
|
|
|
|
|
|
|
- for index := 0; index < length; index++ {
|
|
|
- min := (index * (len(topicList) / length)) + 1
|
|
|
- max := ((index + 1) * (len(topicList) / length))
|
|
|
-
|
|
|
- if max == len(topicList)-1 {
|
|
|
- max++
|
|
|
- }
|
|
|
-
|
|
|
- bigNumber, err := rand.Int(rand.Reader, big.NewInt(int64(max-min+1)))
|
|
|
- if err != nil {
|
|
|
- panic(err)
|
|
|
- }
|
|
|
- var number int = int(bigNumber.Int64()) + min
|
|
|
+ for i := 0; i < neededSubscriptions; i++ {
|
|
|
+ fakeTopicsOfInterest[i] = mr.Intn(maxInt) + 1
|
|
|
|
|
|
- fakeTopicsOfInterest[index] = number
|
|
|
+ for j := 0; j < i; j++ {
|
|
|
+ if fakeTopicsOfInterest[i] == fakeTopicsOfInterest[j] {
|
|
|
+ i--
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
+ sort.Ints(fakeTopicsOfInterest)
|
|
|
+ fmt.Println(fakeTopicsOfInterest)
|
|
|
+
|
|
|
|
|
|
for _, number := range fakeTopicsOfInterest {
|
|
|
if !inList(number, topicsOfInterest) {
|
|
|
topicsOfInterest = append(topicsOfInterest, number)
|
|
|
}
|
|
|
- if len(topicsOfInterest) == length {
|
|
|
+ if len(topicsOfInterest) == neededSubscriptions {
|
|
|
break
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ fmt.Println(topicsOfInterest)
|
|
|
+
|
|
|
return topicsOfInterest
|
|
|
}
|
|
|
|