Skip to content

Commit

Permalink
remove socket closed and fix LOG INFO
Browse files Browse the repository at this point in the history
  • Loading branch information
esonghori committed Nov 20, 2015
1 parent d0b1657 commit 5689876
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 56 deletions.
12 changes: 4 additions & 8 deletions crypto/OT_extension_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ int Alice(const void* data, int connfd) {
}
transfer_time = RDTSC - transfer_time;

LOG(INFO) << "OT Extension send total time (ccx1E6) = " << transfer_time / 1E6
<< endl;
LOG(INFO) << "OT Extension send time (cc/B) = " << (1.0 * transfer_time) / len
<< endl;
LOG(INFO) << "OT Extension send total time (cc) = " << transfer_time
<< "\t(cc/bit) = " << (1.0 * transfer_time) / len << endl;

return SUCCESS;
}
Expand Down Expand Up @@ -79,10 +77,8 @@ int Bob(const void *data, int connfd) {
}
}

LOG(INFO) << "OT Extension total recv time (ccx1E6) = " << transfer_time / 1E6
<< endl;
LOG(INFO) << "OT Extension recv time (cc/B) = " << (1.0 * transfer_time) / len
<< endl;
LOG(INFO) << "OT Extension total recv time (cc) = " << transfer_time
<< "\t(cc/bit) = " << (1.0 * transfer_time) / len << endl;

delete[] message_recv;
if (!test_passed) {
Expand Down
8 changes: 4 additions & 4 deletions crypto/OT_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ int Alice(const void* data, int connfd) {
}
transfer_time = RDTSC - transfer_time;

LOG(INFO) << "OT total send time (ccx1E6) = " << transfer_time / 1E6 << endl;
LOG(INFO) << "OT send time (cc/B) = " << (1.0 * transfer_time) / len << endl;
LOG(INFO) << "OT total send time (cc) = " << transfer_time << "\t(cc/bit) = "
<< (1.0 * transfer_time) / len << endl;

return SUCCESS;
}
Expand Down Expand Up @@ -77,8 +77,8 @@ int Bob(const void *data, int connfd) {
}
}

LOG(INFO) << "OT total recv time (ccx1E6) = " << transfer_time / 1E6 << endl;
LOG(INFO) << "OT recv time (cc/B) = " << (1.0 * transfer_time) / len << endl;
LOG(INFO) << "OT total recv time (cc) = " << transfer_time << "\t(cc/bit) = "
<< (1.0 * transfer_time) / len << endl;

delete[] message_recv;
if (!test_passed) {
Expand Down
80 changes: 36 additions & 44 deletions garbled_circuit/garbled_circuit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,14 +288,13 @@ int Garble(const GarbledCircuit& garbled_circuit, block* const_labels,

}

LOG(INFO) << "Total Communication time (cc) = " << comm_time
<< "\tCommunication time per gate (cc/gate) = "
LOG(INFO) << "Alice communication time (cc) = " << comm_time
<< "\t(cc/gate) = "
<< (comm_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

LOG(INFO)
<< "Total Garbling time (cc) = " << garble_time
<< "\tGarbling time per gate (cc/gate) = "
<< "Alice garbling time (cc) = " << garble_time << "\t(cc/gate) = "
<< (garble_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

Expand Down Expand Up @@ -467,13 +466,13 @@ int Evaluate(const GarbledCircuit& garbled_circuit, block* const_labels,
eval_time += RDTSC - eval_start_time;
}

LOG(INFO) << "Total Communication time (cc) = " << comm_time
<< "\tCommunication time per gate (cc/gate) = "
LOG(INFO) << "Bob communication time (cc) = " << comm_time
<< "\t(cc/gate) = "
<< (comm_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

LOG(INFO) << "Total Evaluateing time (cc) = " << eval_time
<< "\tEvaluating time per gate (cc/gate) = "
LOG(INFO) << "Bob evaluation time (cc) = " << eval_time
<< "\t(cc/gate) = "
<< (eval_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

Expand All @@ -483,7 +482,7 @@ int Evaluate(const GarbledCircuit& garbled_circuit, block* const_labels,
}

int GarbleOT(const GarbledCircuit& garbled_circuit, block* init_labels,
block* input_labels, uint64_t clock_cycles, int connfd) {
block* input_labels, uint64_t clock_cycles, int connfd) {

uint32_t message_len = garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size;
Expand All @@ -501,8 +500,8 @@ int GarbleOT(const GarbledCircuit& garbled_circuit, block* init_labels,
+ cid * garbled_circuit.e_input_size + i;
CHECK_ALLOC(message[idx] = new block[2]);
for (uint j = 0; j < 2; j++) {
message[idx][j] = input_labels[(cid * garbled_circuit.get_input_size() + i
+ garbled_circuit.g_input_size) * 2 + j];
message[idx][j] = input_labels[(cid * garbled_circuit.get_input_size()
+ i + garbled_circuit.g_input_size) * 2 + j];
}
}
}
Expand All @@ -524,8 +523,8 @@ int GarbleOT(const GarbledCircuit& garbled_circuit, block* init_labels,
}

int EvalauteOT(const GarbledCircuit& garbled_circuit, BIGNUM* e_init,
block* init_labels, BIGNUM* e_input, block* input_labels,
uint64_t clock_cycles, int connfd) {
block* init_labels, BIGNUM* e_input, block* input_labels,
uint64_t clock_cycles, int connfd) {
uint32_t message_len = garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size;
bool *select = nullptr;
Expand All @@ -538,7 +537,7 @@ int EvalauteOT(const GarbledCircuit& garbled_circuit, BIGNUM* e_init,
uint indx = garbled_circuit.e_init_size
+ cid * garbled_circuit.e_input_size + i;
select[indx] = BN_is_bit_set(e_input,
cid * garbled_circuit.e_input_size + i);
cid * garbled_circuit.e_input_size + i);
}
}

Expand Down Expand Up @@ -658,7 +657,7 @@ int GarbleTransferLabels(const GarbledCircuit& garbled_circuit,
} else {
CHECK(
GarbleOT(garbled_circuit, init_labels, input_labels, clock_cycles,
connfd));
connfd));
}
return SUCCESS;
}
Expand Down Expand Up @@ -708,8 +707,8 @@ int EvaluateTransferLabels(const GarbledCircuit& garbled_circuit,
}
} else {
CHECK(
EvalauteOT(garbled_circuit, e_init, init_labels, e_input,
input_labels, clock_cycles, connfd));
EvalauteOT(garbled_circuit, e_init, init_labels, e_input, input_labels,
clock_cycles, connfd));
}
return SUCCESS;
}
Expand Down Expand Up @@ -990,22 +989,20 @@ int GarbleStr(const string& scd_file_address, const string& init_str,
output_str);
BN_free(output_bn);
LOG(INFO)
<< "Total Garble Transfer Labels time (cc) = "
<< "Alice transfer labels time (cc) = "
<< ot_time
<< "\tGarble Transfer Labels time per byte (cc/Byte) = "
<< "\t(cc/bit) = "
<< ot_time
/ ((double) ((garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size) * sizeof(block)))
/ ((double) (garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size))
<< endl;
LOG(INFO)
<< "Total Communication time (cc) = " << comm_time
<< "\tCommunication time per gate (cc/gate) = "
<< "Alice communication time (cc) = " << comm_time << "\t(cc/gate) = "
<< (comm_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

LOG(INFO)
<< "Total Garbling time (cc) = " << garble_time
<< "\tGarbling time per gate (cc/gate) = "
<< "Alice garbling time (cc) = " << garble_time << "\t(cc/gate) = "
<< (garble_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;
delete[] wires;
Expand All @@ -1027,12 +1024,12 @@ int GarbleStr(const string& scd_file_address, const string& init_str,
ot_time = RDTSC - ot_start_time;

LOG(INFO)
<< "Total Garble Transfer Labels time (cc) = "
<< "Alice transfer labels time (cc) = "
<< ot_time
<< "\tGarble Transfer Labels time per byte (cc/Byte) = "
<< "\t(cc/bit) = "
<< ot_time
/ ((double) ((garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size) * sizeof(block)))
/ ((double) (garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size))
<< endl;

Garble(garbled_circuit, const_labels, init_labels, input_labels, global_key,
Expand All @@ -1049,7 +1046,6 @@ int GarbleStr(const string& scd_file_address, const string& init_str,
delete[] output_labels;

RemoveGarbledCircuit(&garbled_circuit);
ServerClose(connfd);

return SUCCESS;
}
Expand Down Expand Up @@ -1146,22 +1142,20 @@ int EvaluateStr(const string& scd_file_address, const string& init_str,
output_str);
BN_free(output_bn);
LOG(INFO)
<< "Total Evaluate Transfer Labels time (cc) = "
<< "Bob transfer labels time (cc) = "
<< ot_time
<< "\tEvaluate Transfer Labels time per byte (cc/Byte) = "
<< "\t(cc/bit) = "
<< ot_time
/ ((double) ((garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size) * sizeof(block)))
/ ((double) (garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size))
<< endl;
LOG(INFO)
<< "Total Communication time (cc) = " << comm_time
<< "\tCommunication time per gate (cc/gate) = "
<< "Bob communication time (cc) = " << comm_time << "\t(cc/gate) = "
<< (comm_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

LOG(INFO)
<< "Total Evaluateing time (cc) = " << eval_time
<< "\tEvaluating time per gate (cc/gate) = "
<< "Bob evaluation time (cc) = " << eval_time << "\t(cc/gate) = "
<< (eval_time) / ((double) garbled_circuit.gate_size * clock_cycles)
<< endl;

Expand All @@ -1181,12 +1175,12 @@ int EvaluateStr(const string& scd_file_address, const string& init_str,
ot_time = RDTSC - ot_start_time;

LOG(INFO)
<< "Total Evaluate Transfer Labels time (cc) = "
<< "Bob transfer labels time (cc) = "
<< ot_time
<< "\tEvaluate Transfer Labels time per byte (cc/Byte) = "
<< "\t(cc/bit) = "
<< ot_time
/ ((double) ((garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size) * sizeof(block)))
/ ((double) (garbled_circuit.e_init_size
+ clock_cycles * garbled_circuit.e_input_size))
<< endl;

Evaluate(garbled_circuit, const_labels, init_labels, input_labels,
Expand All @@ -1206,8 +1200,6 @@ int EvaluateStr(const string& scd_file_address, const string& init_str,
delete[] output_labels;

RemoveGarbledCircuit(&garbled_circuit);
ClientClose(connfd);

return SUCCESS;
}

0 comments on commit 5689876

Please sign in to comment.