Browse Source

auditing done

Simon 2 years ago
parent
commit
6dcb03aec5
3 changed files with 9 additions and 22 deletions
  1. 2 5
      client/client.go
  2. 4 8
      follower/follower.go
  3. 3 9
      leader/leader.go

+ 2 - 5
client/client.go

@@ -52,7 +52,7 @@ var wantsArchive = make([]byte, 1)
 
 var dataLen int = 32
 var numThreads int = 12
-var dbWriteSize int = 2
+var dbWriteSize int = 4
 
 var leaderPublicKey *[32]byte
 var followerPublicKey *[32]byte
@@ -187,7 +187,6 @@ func client(tweet []byte, clientNumber int) {
 			encryptedQueryLeader, encryptedQueryFollower := createAuditPIRQuery(clientNumber)
 			sendQuerys(encryptedQueryLeader, encryptedQueryFollower, leaderConn, false)
 			pos := receiveVirtualAddress(sharedSecret[clientNumber], leaderConn)
-			fmt.Println("virtual address received", pos)
 
 			//prep the query
 			dataSize := len(tweet)
@@ -197,7 +196,6 @@ func client(tweet []byte, clientNumber int) {
 			var dpfQueryA *C.uchar
 			var dpfQueryB *C.uchar
 
-			//change
 			C.prepQuery(C.int(pos), C.int(dbWriteSize), (*C.uchar)(&tweet[0]), C.int(dataSize), &cQuerySize, &dpfQueryA, &dpfQueryB)
 
 			intQuerySize := int(cQuerySize) //byteToInt(querySize)
@@ -340,7 +338,7 @@ func createPIRQuery(subPhase int, clientNumber int) ([]byte, []byte) {
 
 	for topic, position := range tmptopicsOfInterest {
 		//change used to be positon-1
-		topicsOfInterestAsBytes[topic][position] = 1
+		topicsOfInterestAsBytes[topic][position-1] = 1
 	}
 
 	//pirQuery [serverAmount][topicsofinterest][topicAmount]byte
@@ -526,7 +524,6 @@ func createAuditPIRQuery(clientNumber int) ([]byte, []byte) {
 
 	//the positon the virtual address will be taken from
 	pos := mr.Intn(dbWriteSize)
-	fmt.Println("pos to receive", pos)
 	pirQuerys[0][pos] = 1
 	pirQuerys[1][pos] = 0
 

+ 4 - 8
follower/follower.go

@@ -54,7 +54,7 @@ var numThreads int = 12
 
 //has to be dividable by 32
 var dataLength int = 32
-var dbWriteSize int = 2
+var dbWriteSize int = 4
 
 var round int = 1
 var startTime time.Time
@@ -274,8 +274,6 @@ func phase1(id int, leaderWorkerConnection net.Conn, m sync.Mutex, wg *sync.Wait
 
 		clientData[*clientPublicKey] = clientKeys
 
-		fmt.Println(pirQuery[0])
-
 		//gets dpfQuery from leader
 		dpfLengthBytes := make([]byte, 4)
 		_, err = leaderWorkerConnection.Read(dpfLengthBytes)
@@ -327,8 +325,6 @@ func phase1(id int, leaderWorkerConnection net.Conn, m sync.Mutex, wg *sync.Wait
 			}
 		}
 
-		fmt.Println("auditXOR", auditXOR, passedAudit)
-
 		if passedAudit {
 			//run dpf, xor into local db
 			for i := 0; i < dbSize; i++ {
@@ -695,10 +691,10 @@ func handlePirQuery(clientKeys clientKeys, leaderWorkerConnection net.Conn, subP
 func getSendVirtualAddress(pirQuery []byte, virtualAddresses []int, sharedSecret [32]byte, leaderWorkerConnection net.Conn) {
 	//xores all requested addresses into virtuallAddress
 	virtualAddress := make([]byte, 4)
-	fmt.Println(pirQuery[15])
-	for _, num := range pirQuery {
+
+	for index, num := range pirQuery {
 		if num == 1 {
-			currentAddress := intToByte(virtualAddresses[num])
+			currentAddress := intToByte(virtualAddresses[index])
 			for i := 0; i < 4; i++ {
 				virtualAddress[i] = virtualAddress[i] ^ currentAddress[i]
 			}

+ 3 - 9
leader/leader.go

@@ -71,7 +71,7 @@ var numThreads = 12
 var dataLength int = 32
 
 //this needs to be adjusted peridodically
-var dbWriteSize int = 20
+var dbWriteSize int = 4
 
 //counts the number of rounds
 var round int = 1
@@ -262,9 +262,6 @@ func main() {
 
 		//creates a new db containing virtual addresses for auditing
 		virtualAddresses := createVirtualAddresses()
-		for i := 0; i < len(virtualAddresses); i++ {
-			fmt.Println(i, virtualAddresses[i])
-		}
 		//send all virtualAddresses to follower
 		for i := 0; i <= dbWriteSize; i++ {
 			_, err = followerConnection.Write(intToByte(virtualAddresses[i]))
@@ -466,8 +463,6 @@ func phase1(id int, phase []byte, followerConnection net.Conn, wg *sync.WaitGrou
 			}
 		}
 
-		fmt.Println("auditXOR", auditXOR, passedAudit)
-
 		if passedAudit {
 			//run dpf, xor into local db
 			for i := 0; i < dbSize; i++ {
@@ -862,10 +857,9 @@ func createVirtualAddresses() []int {
 func getSendVirtualAddress(pirQuery []byte, virtualAddresses []int, sharedSecret [32]byte, clientConnection, followerConnection net.Conn) {
 	//xores all requested addresses into virtuallAddress
 	virtualAddress := make([]byte, 4)
-	fmt.Println(pirQuery[15])
-	for _, num := range pirQuery {
+	for index, num := range pirQuery {
 		if num == 1 {
-			currentAddress := intToByte(virtualAddresses[num])
+			currentAddress := intToByte(virtualAddresses[index])
 			for i := 0; i < 4; i++ {
 				virtualAddress[i] = virtualAddress[i] ^ currentAddress[i]
 			}