|
@@ -8,8 +8,6 @@ package main
|
|
|
//#include "../c/okv.c"
|
|
|
import "C"
|
|
|
|
|
|
-//sssssssssssssssss
|
|
|
-
|
|
|
import (
|
|
|
"2PPS/lib"
|
|
|
"crypto/rand"
|
|
@@ -41,6 +39,7 @@ type clientKeys struct {
|
|
|
var clientData = make(map[[32]byte]clientKeys)
|
|
|
var topicList []byte
|
|
|
var topicAmount int
|
|
|
+var archiveTopicAmount int
|
|
|
|
|
|
var followerPrivateKey *[32]byte
|
|
|
var followerPublicKey *[32]byte
|
|
@@ -53,7 +52,7 @@ const numThreads = 12
|
|
|
//Maximum Transport Unit
|
|
|
const mtu int = 1100
|
|
|
|
|
|
-var dbWriteSize int = 20000
|
|
|
+var dbWriteSize int = 10000
|
|
|
var neededSubscriptions int
|
|
|
|
|
|
var round int = 0
|
|
@@ -512,7 +511,7 @@ func phase3(leaderWorkerConnection net.Conn, wg *sync.WaitGroup, m *sync.RWMutex
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- getSendTweets(clientKeys, nil, leaderWorkerConnection, m, clientPublicKey)
|
|
|
+ getSendTweets(clientKeys, nil, leaderWorkerConnection, clientPublicKey)
|
|
|
|
|
|
wantsArchive, errorBool := readFromWError(leaderWorkerConnection, 1)
|
|
|
if errorBool {
|
|
@@ -520,12 +519,11 @@ func phase3(leaderWorkerConnection net.Conn, wg *sync.WaitGroup, m *sync.RWMutex
|
|
|
}
|
|
|
|
|
|
if wantsArchive[0] == 1 {
|
|
|
- fmt.Println("shouldnt be called")
|
|
|
_, archiveQuerys, errorBool := handlePirQuery(clientKeys, leaderWorkerConnection, -1, clientPublicKey, false)
|
|
|
if errorBool {
|
|
|
continue
|
|
|
}
|
|
|
- getSendTweets(clientKeys, archiveQuerys, leaderWorkerConnection, m, clientPublicKey)
|
|
|
+ getSendTweets(clientKeys, archiveQuerys, leaderWorkerConnection, clientPublicKey)
|
|
|
}
|
|
|
|
|
|
//saves clientKeys
|
|
@@ -536,14 +534,16 @@ func phase3(leaderWorkerConnection net.Conn, wg *sync.WaitGroup, m *sync.RWMutex
|
|
|
}
|
|
|
|
|
|
//gets tweet from db and sends them to leader
|
|
|
-func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, leaderWorkerConnection net.Conn, m *sync.RWMutex, pubKey [32]byte) {
|
|
|
- //todo! repeat for archive
|
|
|
+func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, leaderWorkerConnection net.Conn, pubKey [32]byte) {
|
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
|
if tmpNeededSubscriptions > topicAmount {
|
|
|
tmpNeededSubscriptions = topicAmount
|
|
|
}
|
|
|
if archiveQuerys != nil {
|
|
|
tmpNeededSubscriptions = len(archiveQuerys)
|
|
|
+ if tmpNeededSubscriptions > archiveTopicAmount {
|
|
|
+ tmpNeededSubscriptions = archiveTopicAmount
|
|
|
+ }
|
|
|
}
|
|
|
for i := 0; i < tmpNeededSubscriptions; i++ {
|
|
|
//gets all requested tweets
|
|
@@ -563,25 +563,25 @@ func getSendTweets(clientKeys clientKeys, archiveQuerys [][]byte, leaderWorkerCo
|
|
|
//Xor's sharedSecret with all tweets
|
|
|
lib.Xor(expandedSharedSecret[:], tweets)
|
|
|
|
|
|
- //fmt.Println("tweetsLen", len(tweets))
|
|
|
+ if archiveQuerys != nil {
|
|
|
+ //fmt.Println("length", len(tweets))
|
|
|
+ }
|
|
|
+
|
|
|
//sends tweets to leader
|
|
|
- //fmt.Println("pubKey", pubKey, "Bytes", tweets)
|
|
|
writeTo(leaderWorkerConnection, tweets)
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-var ignoreMe []byte
|
|
|
-
|
|
|
//returns true if client connection is lost
|
|
|
func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subPhase int, clientPublicKey [32]byte, doAuditing bool) (clientKeys, [][]byte, bool) {
|
|
|
|
|
|
archiveNeededSubscriptions := make([]byte, 4)
|
|
|
if subPhase == -1 {
|
|
|
- archiveNeededSubscriptions, errorBool := readFromWError(leaderWorkerConnection, 4)
|
|
|
+ var errorBool bool
|
|
|
+ archiveNeededSubscriptions, errorBool = readFromWError(leaderWorkerConnection, 4)
|
|
|
if errorBool {
|
|
|
return clientKeys, nil, true
|
|
|
}
|
|
|
- ignoreMe = archiveNeededSubscriptions
|
|
|
}
|
|
|
|
|
|
//gets the msg length
|
|
@@ -630,7 +630,6 @@ func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subP
|
|
|
//follower expects pirQuery
|
|
|
|
|
|
//transforms byteArray to ints of wanted topics
|
|
|
- //todo! repeat for archive
|
|
|
tmpNeededSubscriptions := neededSubscriptions
|
|
|
if tmpNeededSubscriptions > topicAmount {
|
|
|
tmpNeededSubscriptions = topicAmount
|
|
@@ -638,7 +637,11 @@ func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subP
|
|
|
tmpTopicAmount := topicAmount
|
|
|
if subPhase == -1 {
|
|
|
tmpNeededSubscriptions = byteToInt(archiveNeededSubscriptions)
|
|
|
- _, tmpTopicAmount = lib.GetTopicList(1)
|
|
|
+ _, archiveTopicAmount = lib.GetTopicList(1)
|
|
|
+ if tmpNeededSubscriptions > archiveTopicAmount {
|
|
|
+ tmpNeededSubscriptions = archiveTopicAmount
|
|
|
+ }
|
|
|
+ tmpTopicAmount = archiveTopicAmount
|
|
|
}
|
|
|
|
|
|
pirQueryFlattened := decrypted
|
|
@@ -655,6 +658,10 @@ func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subP
|
|
|
clientKeys.PirQuery = pirQuerys
|
|
|
}
|
|
|
|
|
|
+ if subPhase == -1 {
|
|
|
+ //fmt.Println("query", pirQuerys)
|
|
|
+ }
|
|
|
+
|
|
|
return clientKeys, pirQuerys, false
|
|
|
}
|
|
|
|