Browse Source

removed auditing

Simon 2 years ago
parent
commit
e99c31f8be
3 changed files with 3 additions and 276 deletions
  1. 1 54
      client/client.go
  2. 1 95
      follower/follower.go
  3. 1 127
      leader/leader.go

+ 1 - 54
client/client.go

@@ -188,6 +188,7 @@ func client(tweet []byte, clientNumber int) {
 			var dpfQueryA *C.uchar
 			var dpfQueryB *C.uchar
 
+			//change
 			C.prepQuery(C.int(1), C.int(dbWriteSize), (*C.uchar)(&tweet[0]), C.int(dataSize), &cQuerySize, &dpfQueryA, &dpfQueryB)
 
 			intQuerySize := int(cQuerySize) //byteToInt(querySize)
@@ -231,60 +232,6 @@ func client(tweet []byte, clientNumber int) {
 				panic(err)
 			}
 
-			//auditing starts here
-
-			//read seed from leader(in preparation for auditing)
-			seed := make([]byte, 16)
-			_, err = leaderConn.Read(seed)
-			if err != nil {
-				panic(err)
-			}
-
-			//prepare message for auditor, box it, and send to server A
-			//prepare the auditor message
-			outputsA := (*C.uchar)(C.malloc(C.ulong(160)))
-			outputsB := (*C.uchar)(C.malloc(C.ulong(160)))
-
-			C.prepAudit((*C.uchar)(&seed[0]), outputsA, outputsB, dpfQueryA, dpfQueryB)
-
-			auditPlaintextLeader := C.GoBytes(unsafe.Pointer(outputsA), C.int(160))
-			auditPlaintextFollower := C.GoBytes(unsafe.Pointer(outputsB), C.int(160))
-
-			//encrypt messages for auditing
-			//fill nonce with randomness
-			_, err = rand.Read(nonce[:])
-			if err != nil {
-				panic("couldn't get randomness for nonce!")
-			}
-			auditCiphertextLeader := box.Seal(nonce[:], auditPlaintextLeader, &nonce, leaderPublicKey, clientPrivateKey)
-
-			//fill nonce with randomness
-			_, err = rand.Read(nonce[:])
-			if err != nil {
-				panic("couldn't get randomness for nonce!")
-			}
-			auditCiphertextFollower := box.Seal(nonce[:], auditPlaintextFollower, &nonce, followerPublicKey, clientPrivateKey)
-
-			//send boxed audits to leader
-			auditLengthBytes := intToByte(len(auditCiphertextLeader))
-
-			_, err = leaderConn.Write(auditLengthBytes)
-			if err != nil {
-				panic(err)
-			}
-
-			_, err = leaderConn.Write(auditCiphertextLeader)
-			if err != nil {
-				panic(err)
-			}
-
-			_, err = leaderConn.Write(auditCiphertextFollower)
-			if err != nil {
-				panic(err)
-			}
-
-			C.free(unsafe.Pointer(outputsA))
-			C.free(unsafe.Pointer(outputsB))
 			C.free(unsafe.Pointer(dpfQueryA))
 			C.free(unsafe.Pointer(dpfQueryB))
 		} else if phase[0] == 3 {

+ 1 - 95
follower/follower.go

@@ -272,39 +272,8 @@ func phase1(id int, leaderWorkerConnection net.Conn, m sync.Mutex, wg *sync.Wait
 			panic(err)
 		}
 
-		//auditing starts here
-
-		//gets seeed from leader
-		seed := make([]byte, 16)
-		_, err = leaderWorkerConnection.Read(seed)
-		if err != nil {
-			panic(err)
-		}
-
-		//receive client audit result
-		auditLengthBytes := make([]byte, 4)
-		_, err = leaderWorkerConnection.Read(auditLengthBytes)
-		if err != nil {
-			panic(err)
-		}
-
-		auditLength := 200 //byteToInt(auditLengthBytes)
-		clientAuditEncrypted := make([]byte, auditLength)
-
-		_, err = leaderWorkerConnection.Read(clientAuditEncrypted)
-		if err != nil {
-			panic(err)
-		}
-
-		//decrypts the clients audit result
-		var decryptNonce [24]byte
-		copy(decryptNonce[:], clientAuditEncrypted[:24])
-		clientAuditB, ok := box.Open(nil, clientAuditEncrypted[24:], &decryptNonce, clientPublicKey, followerPrivateKey)
-		if !ok {
-			panic("clientAuditB decryption not ok")
-		}
-
 		//decrypt dpfQueryB for sorting into db
+		var decryptNonce [24]byte
 		copy(decryptNonce[:], dpfQueryBEncrypted[:24])
 		dpfQueryB, ok := box.Open(nil, dpfQueryBEncrypted[24:], &decryptNonce, clientPublicKey, followerPrivateKey)
 		if !ok {
@@ -325,69 +294,6 @@ func phase1(id int, leaderWorkerConnection net.Conn, m sync.Mutex, wg *sync.Wait
 			}
 		}
 
-		//prepare for audit
-		mVal := make([]byte, 16)
-		cVal := make([]byte, 16)
-
-		C.serverSetupProof(C.ctx[id], (*C.uchar)(&seed[0]), C.dbSize, (*C.uchar)(&vector[0]), (*C.uchar)(&mVal[0]), (*C.uchar)(&cVal[0]))
-
-		//compute audit query
-		auditResultB := make([]byte, 96)
-		C.serverComputeQuery(C.ctx[id], (*C.uchar)(&seed[0]), (*C.uchar)(&mVal[0]), (*C.uchar)(&cVal[0]), (*C.uchar)(&clientAuditB[0]), (*C.uchar)(&auditResultB[0]))
-
-		//encrypt follower audit result
-		var nonce [24]byte
-		//fill nonce with randomness
-		_, err = rand.Read(nonce[:])
-		if err != nil {
-			panic("couldn't get randomness for nonce!")
-		}
-		auditResultBEncrypted := box.Seal(nonce[:], auditResultB, &nonce, leaderPublicKey, followerPrivateKey)
-
-		//gets audit result from leader
-		auditResultAEncryptedLengthBytes := make([]byte, 4)
-		_, err = leaderWorkerConnection.Read(auditResultAEncryptedLengthBytes)
-		if err != nil {
-			panic(err)
-		}
-
-		auditResultAEncryptedLength := byteToInt(auditResultAEncryptedLengthBytes)
-
-		auditResultAEncrypted := make([]byte, auditResultAEncryptedLength)
-		_, err = leaderWorkerConnection.Read(auditResultAEncrypted)
-		if err != nil {
-			panic(err)
-		}
-
-		//send follower audit result to leader
-		auditResultBEncryptedLengthBytes := intToByte(len(auditResultBEncrypted))
-		_, err = leaderWorkerConnection.Write(auditResultBEncryptedLengthBytes)
-		if err != nil {
-			panic(err)
-		}
-
-		_, err = leaderWorkerConnection.Write(auditResultBEncrypted)
-		if err != nil {
-			panic(err)
-		}
-
-		//decrypts the audit result from leader
-		copy(decryptNonce[:], auditResultAEncrypted[:24])
-		auditResultA, ok := box.Open(nil, auditResultAEncrypted[24:], &decryptNonce, leaderPublicKey, followerPrivateKey)
-		if !ok {
-			panic("auditResultA decryption not ok")
-		}
-
-		//compute audit result
-		auditResult := int(C.serverVerifyProof((*C.uchar)(&auditResultA[0]), (*C.uchar)(&auditResultB[0])))
-
-		if auditResult == 0 {
-			//fmt.Println("audit failed")
-		} /*else {
-			fmt.Println("audit passed")
-		}
-		*/
-
 		//xor the worker's DB into the main DB
 		for i := 0; i < dbSize; i++ {
 			m.Lock()

+ 1 - 127
leader/leader.go

@@ -406,71 +406,8 @@ func phase1(id int, phase []byte, followerConnection net.Conn, wg *sync.WaitGrou
 			panic(err)
 		}
 
-		//auditing starts here
-
-		//generate seed
-		var seed [16]byte
-		_, err = rand.Read(seed[:])
-		if err != nil {
-			panic(err)
-		}
-
-		//send seed to client
-		_, err = clientConnection.Write(seed[:])
-		if err != nil {
-			panic(err)
-		}
-
-		//send seed to follower
-		_, err = followerConnection.Write(seed[:])
-		if err != nil {
-			panic(err)
-		}
-
-		//receive proofs
-		auditLengthBytes := make([]byte, 4)
-
-		_, err = clientConnection.Read(auditLengthBytes)
-		if err != nil {
-			panic(err)
-		}
-
-		auditLength := byteToInt(auditLengthBytes)
-
-		clientAuditA := make([]byte, auditLength)
-		clientAuditB := make([]byte, auditLength)
-
-		_, err = clientConnection.Read(clientAuditA)
-		if err != nil {
-			panic(err)
-		}
-
-		_, err = clientConnection.Read(clientAuditB)
-		if err != nil {
-			panic(err)
-		}
-
-		//send client audit to follower
-		_, err = followerConnection.Write(auditLengthBytes)
-		if err != nil {
-			panic(err)
-		}
-
-		_, err = followerConnection.Write(clientAuditB)
-		if err != nil {
-			panic(err)
-		}
-
-		//decrypts the client audit
-		var decryptNonce [24]byte
-		copy(decryptNonce[:], clientAuditA[:24])
-
-		clientAuditA, ok := box.Open(nil, clientAuditA[24:], &decryptNonce, clientPublicKey, leaderPrivateKey)
-		if !ok {
-			panic("clientAudit decryption not ok")
-		}
-
 		//decrypt dpfQueryA for sorting into db
+		var decryptNonce [24]byte
 		copy(decryptNonce[:], dpfQueryAEncrypted[:24])
 		dpfQueryA, ok := box.Open(nil, dpfQueryAEncrypted[24:], &decryptNonce, clientPublicKey, leaderPrivateKey)
 		if !ok {
@@ -491,69 +428,6 @@ func phase1(id int, phase []byte, followerConnection net.Conn, wg *sync.WaitGrou
 			}
 		}
 
-		//prepare for audit
-		mVal := make([]byte, 16)
-		cVal := make([]byte, 16)
-		C.serverSetupProof(C.ctx[id], (*C.uchar)(&seed[0]), C.dbSize, (*C.uchar)(&vector[0]), (*C.uchar)(&mVal[0]), (*C.uchar)(&cVal[0]))
-
-		//compute audit query
-		auditResultA := make([]byte, 96)
-		C.serverComputeQuery(C.ctx[id], (*C.uchar)(&seed[0]), (*C.uchar)(&mVal[0]), (*C.uchar)(&cVal[0]), (*C.uchar)(&clientAuditA[0]), (*C.uchar)(&auditResultA[0]))
-
-		//encrypt leader audit result
-		var nonce [24]byte
-		//fill nonce with randomness
-		_, err = rand.Read(nonce[:])
-		if err != nil {
-			panic("couldn't get randomness for nonce!")
-		}
-
-		auditResultAEncrypted := box.Seal(nonce[:], auditResultA, &nonce, followerPublicKey, leaderPrivateKey)
-
-		encryptedAuditResultALengthBytes := intToByte(len(auditResultAEncrypted))
-
-		//send audit result to follower
-		_, err = followerConnection.Write(encryptedAuditResultALengthBytes)
-		if err != nil {
-			panic(err)
-		}
-
-		_, err = followerConnection.Write(auditResultAEncrypted)
-		if err != nil {
-			panic(err)
-		}
-
-		//receive follower audit result
-		auditResultBEncryptedLengthBytes := make([]byte, 4)
-		_, err = followerConnection.Read(auditResultBEncryptedLengthBytes)
-		if err != nil {
-			panic(err)
-		}
-		auditResultBEncryptedLength := byteToInt(auditResultBEncryptedLengthBytes)
-
-		auditResultBEncrypted := make([]byte, auditResultBEncryptedLength)
-		_, err = followerConnection.Read(auditResultBEncrypted)
-		if err != nil {
-			panic(err)
-		}
-
-		//decrypts the audit result from follower
-		copy(decryptNonce[:], auditResultBEncrypted[:24])
-		auditResultB, ok := box.Open(nil, auditResultBEncrypted[24:], &decryptNonce, followerPublicKey, leaderPrivateKey)
-		if !ok {
-			panic("auditResultB decryption not ok")
-		}
-
-		//compute audit result
-		auditResult := int(C.serverVerifyProof((*C.uchar)(&auditResultA[0]), (*C.uchar)(&auditResultB[0])))
-
-		if byteToInt(auditResultB) == 0 || auditResult == 0 {
-			//fmt.Println("audit failed")
-		} /*else {
-			fmt.Println("audit passed")
-		}
-		*/
-
 		//xor the worker's DB into the main DB
 		for i := 0; i < dbSize; i++ {
 			m.Lock()