|
@@ -1,6 +1,8 @@
|
|
|
#include <iostream>
|
|
|
#include <fstream>
|
|
|
#include <sstream>
|
|
|
+#include <ctime>
|
|
|
+#include <chrono>
|
|
|
|
|
|
#include "networkServer.hpp"
|
|
|
|
|
@@ -94,17 +96,29 @@ void make_epoch(
|
|
|
const std::string& selfIP,
|
|
|
int selfPort,
|
|
|
std::mutex& updateMtx,
|
|
|
- std::atomic<size_t>& epochNum)
|
|
|
+ std::atomic<size_t>& epochNum,
|
|
|
+ const CivetServer& civetServer,
|
|
|
+ std::mutex& buildUpOutputMtx,
|
|
|
+ const std::string& buildUpOutputFilename,
|
|
|
+ std::mutex& breakDownOutputMtx,
|
|
|
+ const std::string& breakDownOutputFilename,
|
|
|
+ std::mutex& fullOutputMtx,
|
|
|
+ const std::string& fullOutputFilename)
|
|
|
{
|
|
|
// As before, the fresh generator always starts from the same G
|
|
|
Twistpoint nextGenerator = PrsonaServer::EL_GAMAL_GENERATOR;
|
|
|
|
|
|
- // Take update locks on every machine
|
|
|
std::unique_lock<std::mutex> updateLock(updateMtx, std::defer_lock);
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer.getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
+
|
|
|
+ // Take update locks on every machine
|
|
|
obtain_update_locks(updateLock, serverIPs, serverPorts, selfIP, selfPort);
|
|
|
|
|
|
// Do the first half of the epoch calculations (building up the intermediary values)
|
|
|
- std::vector<Proof> generatorProof = epoch_build_up(rng, prsonaServer, serverIPs, serverPorts, selfIP, selfPort, nextGenerator);
|
|
|
+ std::vector<Proof> generatorProof = epoch_build_up(rng, prsonaServer, serverIPs, serverPorts, selfIP, selfPort, nextGenerator, civetServer, buildUpOutputMtx, buildUpOutputFilename);
|
|
|
|
|
|
// Tally up the current scores at the end of the epoch for the users
|
|
|
std::vector<EGCiphertext> currentUserEncryptedTallies;
|
|
@@ -115,13 +129,27 @@ void make_epoch(
|
|
|
distribute_tallied_scores(prsonaServer, serverIPs, serverPorts, selfIP, selfPort, nextGenerator, currentUserEncryptedTallies, currentServerEncryptedTallies);
|
|
|
|
|
|
// Do the second half of the epoch calculations (breaking down values to their final values, to be given to users)
|
|
|
- epoch_break_down(rng, prsonaServer, serverIPs, serverPorts, selfIP, selfPort, generatorProof, nextGenerator);
|
|
|
+ epoch_break_down(rng, prsonaServer, serverIPs, serverPorts, selfIP, selfPort, generatorProof, nextGenerator, civetServer, breakDownOutputMtx, breakDownOutputFilename);
|
|
|
|
|
|
// Indicate we are in a new epoch
|
|
|
epochNum.fetch_add(1);
|
|
|
|
|
|
// Release the update locks from every machine
|
|
|
release_update_locks(updateLock, serverIPs, serverPorts, selfIP, selfPort);
|
|
|
+
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer.getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0];
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
+
|
|
|
+ write_log_data(fullOutputMtx, fullOutputFilename, timingData, bandwidthData);
|
|
|
}
|
|
|
|
|
|
/*********************************************************
|
|
@@ -430,7 +458,10 @@ std::vector<Proof> epoch_build_up(
|
|
|
const std::vector<int>& serverPorts,
|
|
|
const std::string& selfIP,
|
|
|
int selfPort,
|
|
|
- Twistpoint& nextGenerator)
|
|
|
+ Twistpoint& nextGenerator,
|
|
|
+ const CivetServer& civetServer,
|
|
|
+ std::mutex& outputMtx,
|
|
|
+ const std::string& outputFilename)
|
|
|
{
|
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
|
std::vector<std::vector<std::vector<Twistpoint>>> permutationCommits;
|
|
@@ -456,6 +487,10 @@ std::vector<Proof> epoch_build_up(
|
|
|
serverTallyCommits.clear();
|
|
|
partwayVoteMatrixCommits.clear();
|
|
|
finalVoteMatrixCommits.clear();
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer.getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
|
|
|
// Perform the actual calculation
|
|
|
prsonaServer->build_up_midway_pseudonyms(pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, nextGenerator);
|
|
@@ -493,6 +528,20 @@ std::vector<Proof> epoch_build_up(
|
|
|
for (size_t j = 0; j < conns.size(); j++)
|
|
|
mg_close_connection(conns[j]);
|
|
|
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer.getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0];
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
+
|
|
|
+ write_log_data(outputMtx, outputFilename, timingData, bandwidthData);
|
|
|
+
|
|
|
// Keep an up-to-date version of the proof of the new fresh generator
|
|
|
generatorProofHolder = pi[0];
|
|
|
}
|
|
@@ -518,7 +567,10 @@ void epoch_break_down(
|
|
|
const std::string& selfIP,
|
|
|
int selfPort,
|
|
|
const std::vector<Proof>& generatorProof,
|
|
|
- const Twistpoint& nextGenerator)
|
|
|
+ const Twistpoint& nextGenerator,
|
|
|
+ const CivetServer& civetServer,
|
|
|
+ std::mutex& outputMtx,
|
|
|
+ const std::string& outputFilename)
|
|
|
{
|
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
|
std::vector<std::vector<std::vector<Twistpoint>>> permutationCommits;
|
|
@@ -548,6 +600,10 @@ void epoch_break_down(
|
|
|
userTallyMessageCommits.clear();
|
|
|
userTallySeedCommits.clear();
|
|
|
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer.getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
+
|
|
|
// Perform the actual calculation
|
|
|
prsonaServer->break_down_midway_pseudonyms(generatorProof, pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits, nextGenerator);
|
|
|
|
|
@@ -579,6 +635,18 @@ void epoch_break_down(
|
|
|
|
|
|
for (size_t j = 0; j < conns.size(); j++)
|
|
|
mg_close_connection(conns[j]);
|
|
|
+
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer.getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0];
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
}
|
|
|
else // When it's another server's turn, tell them to do their part
|
|
|
{
|
|
@@ -900,12 +968,18 @@ std::string make_epoch_initiator_string(
|
|
|
return buffer.str();
|
|
|
}
|
|
|
|
|
|
-void read_epoch_initiator_string(
|
|
|
+ssize_t read_epoch_initiator_string(
|
|
|
const char *filename,
|
|
|
std::vector<Proof>& generatorProof,
|
|
|
Twistpoint& nextGenerator)
|
|
|
{
|
|
|
std::ifstream file(filename);
|
|
|
+
|
|
|
+ file.ignore(std::numeric_limits<std::streamsize>::max());
|
|
|
+ std::streamsize retval = file.gcount();
|
|
|
+ file.clear();
|
|
|
+ file.seekg(0, std::ios_base::beg);
|
|
|
+
|
|
|
BinarySizeT sizeOfVector;
|
|
|
|
|
|
generatorProof.clear();
|
|
@@ -920,6 +994,8 @@ void read_epoch_initiator_string(
|
|
|
}
|
|
|
|
|
|
file >> nextGenerator;
|
|
|
+
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
std::string make_epoch_update_string(
|
|
@@ -1015,7 +1091,7 @@ std::string make_epoch_update_string(
|
|
|
return buffer.str();
|
|
|
}
|
|
|
|
|
|
-bool read_epoch_update_string(
|
|
|
+ssize_t read_epoch_update_string(
|
|
|
const char *filename,
|
|
|
std::vector<std::vector<Proof>>& pi,
|
|
|
std::vector<std::vector<Twistpoint>>& permutationCommits,
|
|
@@ -1027,9 +1103,16 @@ bool read_epoch_update_string(
|
|
|
std::vector<std::vector<Twistpoint>>& userTallyMaskCommits,
|
|
|
std::vector<std::vector<Twistpoint>>& userTallyMessageCommits,
|
|
|
std::vector<std::vector<Twistpoint>>& userTallySeedCommits,
|
|
|
- Twistpoint& nextGenerator)
|
|
|
+ Twistpoint& nextGenerator,
|
|
|
+ bool& doUserTallies)
|
|
|
{
|
|
|
std::ifstream file(filename);
|
|
|
+
|
|
|
+ file.ignore(std::numeric_limits<std::streamsize>::max());
|
|
|
+ std::streamsize retval = file.gcount();
|
|
|
+ file.clear();
|
|
|
+ file.seekg(0, std::ios_base::beg);
|
|
|
+
|
|
|
BinarySizeT sizeOfVectorI, sizeOfVectorJ;
|
|
|
|
|
|
pi.clear();
|
|
@@ -1198,10 +1281,12 @@ bool read_epoch_update_string(
|
|
|
|
|
|
file >> nextGenerator;
|
|
|
|
|
|
- BinaryBool doUserTallies;
|
|
|
- file >> doUserTallies;
|
|
|
+ BinaryBool binaryDoUserTallies;
|
|
|
+ file >> binaryDoUserTallies;
|
|
|
+
|
|
|
+ doUserTallies = binaryDoUserTallies.val();
|
|
|
|
|
|
- return doUserTallies.val();
|
|
|
+ return retval;
|
|
|
}
|
|
|
|
|
|
/**********************************************************
|
|
@@ -1379,8 +1464,16 @@ PrsonaServerWebSocketHandler::PrsonaServerWebSocketHandler(
|
|
|
const std::string& selfIP,
|
|
|
int selfPort,
|
|
|
std::mutex& updateMtx,
|
|
|
- std::atomic<size_t>& epochNum)
|
|
|
-: rng(rng), prsonaServer(prsonaServer), serverIPs(serverIPs), serverPorts(serverPorts), selfIP(selfIP), selfPort(selfPort), updateMtx(updateMtx), epochNum(epochNum)
|
|
|
+ std::atomic<size_t>& epochNum,
|
|
|
+ std::mutex& buildUpOutputMtx,
|
|
|
+ const std::string& buildUpOutputFilename,
|
|
|
+ std::mutex& breakDownOutputMtx,
|
|
|
+ const std::string& breakDownOutputFilename,
|
|
|
+ std::mutex& updateOutputMtx,
|
|
|
+ const std::string& updateOutputFilename,
|
|
|
+ std::mutex& voteOutputMtx,
|
|
|
+ const std::string& voteOutputFilename)
|
|
|
+: rng(rng), prsonaServer(prsonaServer), serverIPs(serverIPs), serverPorts(serverPorts), selfIP(selfIP), selfPort(selfPort), updateMtx(updateMtx), epochNum(epochNum), buildUpOutputMtx(buildUpOutputMtx), buildUpOutputFilename(buildUpOutputFilename), breakDownOutputMtx(breakDownOutputMtx), breakDownOutputFilename(breakDownOutputFilename), updateOutputMtx(updateOutputMtx), updateOutputFilename(updateOutputFilename), voteOutputMtx(voteOutputMtx), voteOutputFilename(voteOutputFilename)
|
|
|
{ /* */ }
|
|
|
|
|
|
/*
|
|
@@ -1461,7 +1554,7 @@ bool PrsonaServerWebSocketHandler::handleData(
|
|
|
// Requester has indicated they have sent all relevant data
|
|
|
case MG_WEBSOCKET_OPCODE_CONNECTION_CLOSE:
|
|
|
case MG_WEBSOCKET_OPCODE_DATACOMPLETE:
|
|
|
- generate_response(conn, filename);
|
|
|
+ generate_response(server, conn, filename);
|
|
|
break;
|
|
|
|
|
|
// Requester has sent more data (which may theoretically be broken up into multiple packets)
|
|
@@ -1501,6 +1594,7 @@ void PrsonaServerWebSocketHandler::handleClose(
|
|
|
*/
|
|
|
|
|
|
void PrsonaServerWebSocketHandler::generate_response(
|
|
|
+ CivetServer *server,
|
|
|
struct mg_connection *conn,
|
|
|
const char *filename)
|
|
|
{
|
|
@@ -1578,7 +1672,7 @@ void PrsonaServerWebSocketHandler::generate_response(
|
|
|
break;
|
|
|
|
|
|
case PRSONA_RECEIVE_VOTE:
|
|
|
- receive_vote(conn, filename);
|
|
|
+ receive_vote(server, conn, filename);
|
|
|
break;
|
|
|
|
|
|
// CLIENT INTERACTION HELPER
|
|
@@ -1609,15 +1703,15 @@ void PrsonaServerWebSocketHandler::generate_response(
|
|
|
|
|
|
// EPOCH ROUNDS
|
|
|
case PRSONA_PERFORM_EPOCH_BUILD_UP:
|
|
|
- build_up_midway_pseudonyms(conn, filename);
|
|
|
+ build_up_midway_pseudonyms(server, conn, filename);
|
|
|
break;
|
|
|
|
|
|
case PRSONA_PERFORM_EPOCH_BREAK_DOWN:
|
|
|
- break_down_midway_pseudonyms(conn, filename);
|
|
|
+ break_down_midway_pseudonyms(server, conn, filename);
|
|
|
break;
|
|
|
|
|
|
case PRSONA_RECEIVE_EPOCH_UPDATE:
|
|
|
- accept_epoch_updates(conn, filename);
|
|
|
+ accept_epoch_updates(server, conn, filename);
|
|
|
break;
|
|
|
|
|
|
// DISTRIBUTED BGN
|
|
@@ -1992,11 +2086,17 @@ void PrsonaServerWebSocketHandler::add_new_client(
|
|
|
}
|
|
|
|
|
|
void PrsonaServerWebSocketHandler::receive_vote(
|
|
|
+ CivetServer *civetServer,
|
|
|
struct mg_connection *conn,
|
|
|
const char *filename)
|
|
|
{
|
|
|
std::ifstream file(filename);
|
|
|
|
|
|
+ file.ignore(std::numeric_limits<std::streamsize>::max());
|
|
|
+ std::streamsize bandwidthRcv = file.gcount();
|
|
|
+ file.clear();
|
|
|
+ file.seekg(0, std::ios_base::beg);
|
|
|
+
|
|
|
// Un-serialize request
|
|
|
BinarySizeT sizeOfVector;
|
|
|
file >> sizeOfVector;
|
|
@@ -2029,6 +2129,11 @@ void PrsonaServerWebSocketHandler::receive_vote(
|
|
|
|
|
|
// If we're dealing this update to the other servers, obtain global update lock
|
|
|
std::unique_lock<std::mutex> updateLock(updateMtx, std::defer_lock);
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer->getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
+
|
|
|
if (shouldDeal.val())
|
|
|
obtain_update_locks(updateLock, serverIPs, serverPorts, selfIP, selfPort);
|
|
|
|
|
@@ -2044,6 +2149,20 @@ void PrsonaServerWebSocketHandler::receive_vote(
|
|
|
release_update_locks(updateLock, serverIPs, serverPorts, selfIP, selfPort);
|
|
|
}
|
|
|
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer->getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0] + bandwidthRcv;
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
+
|
|
|
+ write_log_data(voteOutputMtx, voteOutputFilename, timingData, bandwidthData);
|
|
|
+
|
|
|
// Notify client their request has been completed
|
|
|
mg_websocket_write(conn, MG_WEBSOCKET_OPCODE_DATACOMPLETE, "", 0);
|
|
|
}
|
|
@@ -2356,6 +2475,7 @@ void PrsonaServerWebSocketHandler::set_generator(
|
|
|
*/
|
|
|
|
|
|
void PrsonaServerWebSocketHandler::build_up_midway_pseudonyms(
|
|
|
+ CivetServer *civetServer,
|
|
|
struct mg_connection *conn,
|
|
|
const char *filename)
|
|
|
{
|
|
@@ -2364,7 +2484,7 @@ void PrsonaServerWebSocketHandler::build_up_midway_pseudonyms(
|
|
|
Twistpoint nextGenerator;
|
|
|
|
|
|
// Un-serialize request
|
|
|
- read_epoch_initiator_string(filename, generatorProof, nextGenerator);
|
|
|
+ ssize_t bandwidthRcv = read_epoch_initiator_string(filename, generatorProof, nextGenerator);
|
|
|
generatorProofHolder.push_back(generatorProof);
|
|
|
|
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
@@ -2376,6 +2496,10 @@ void PrsonaServerWebSocketHandler::build_up_midway_pseudonyms(
|
|
|
std::vector<std::vector<std::vector<std::vector<TwistBipoint>>>> partwayVoteMatrixCommits;
|
|
|
std::vector<std::vector<std::vector<std::vector<TwistBipoint>>>> finalVoteMatrixCommits;
|
|
|
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer->getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
+
|
|
|
// Do actual epoch calculation
|
|
|
prsonaServer->build_up_midway_pseudonyms(pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, nextGenerator);
|
|
|
|
|
@@ -2408,6 +2532,20 @@ void PrsonaServerWebSocketHandler::build_up_midway_pseudonyms(
|
|
|
// Close connections
|
|
|
for (size_t i = 0; i < conns.size(); i++)
|
|
|
mg_close_connection(conns[i]);
|
|
|
+
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer->getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0] + bandwidthRcv;
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
+
|
|
|
+ write_log_data(buildUpOutputMtx, buildUpOutputFilename, timingData, bandwidthData);
|
|
|
|
|
|
// Serialize response
|
|
|
data = make_epoch_initiator_string(pi[0][0], nextGenerator);
|
|
@@ -2418,6 +2556,7 @@ void PrsonaServerWebSocketHandler::build_up_midway_pseudonyms(
|
|
|
}
|
|
|
|
|
|
void PrsonaServerWebSocketHandler::break_down_midway_pseudonyms(
|
|
|
+ CivetServer *civetServer,
|
|
|
struct mg_connection *conn,
|
|
|
const char *filename)
|
|
|
{
|
|
@@ -2425,7 +2564,7 @@ void PrsonaServerWebSocketHandler::break_down_midway_pseudonyms(
|
|
|
Twistpoint nextGenerator;
|
|
|
|
|
|
// Un-serialize request
|
|
|
- read_epoch_initiator_string(filename, generatorProof, nextGenerator);
|
|
|
+ ssize_t bandwidthRcv = read_epoch_initiator_string(filename, generatorProof, nextGenerator);
|
|
|
|
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
|
std::vector<std::vector<std::vector<Twistpoint>>> permutationCommits;
|
|
@@ -2438,6 +2577,10 @@ void PrsonaServerWebSocketHandler::break_down_midway_pseudonyms(
|
|
|
std::vector<std::vector<std::vector<Twistpoint>>> userTallyMessageCommits;
|
|
|
std::vector<std::vector<std::vector<Twistpoint>>> userTallySeedCommits;
|
|
|
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer->getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
+
|
|
|
// Do actual epoch calculation
|
|
|
prsonaServer->break_down_midway_pseudonyms(generatorProof, pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits, nextGenerator);
|
|
|
|
|
@@ -2469,6 +2612,20 @@ void PrsonaServerWebSocketHandler::break_down_midway_pseudonyms(
|
|
|
for (size_t i = 0; i < conns.size(); i++)
|
|
|
mg_close_connection(conns[i]);
|
|
|
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer->getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0] + bandwidthRcv;
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
+
|
|
|
+ write_log_data(breakDownOutputMtx, breakDownOutputFilename, timingData, bandwidthData);
|
|
|
+
|
|
|
// Keep our epoch value up-to-date
|
|
|
epochNum.fetch_add(1);
|
|
|
|
|
@@ -2477,6 +2634,7 @@ void PrsonaServerWebSocketHandler::break_down_midway_pseudonyms(
|
|
|
}
|
|
|
|
|
|
void PrsonaServerWebSocketHandler::accept_epoch_updates(
|
|
|
+ CivetServer *civetServer,
|
|
|
struct mg_connection *conn,
|
|
|
const char *filename)
|
|
|
{
|
|
@@ -2491,13 +2649,32 @@ void PrsonaServerWebSocketHandler::accept_epoch_updates(
|
|
|
std::vector<std::vector<Twistpoint>> userTallyMessageCommits;
|
|
|
std::vector<std::vector<Twistpoint>> userTallySeedCommits;
|
|
|
Twistpoint nextGenerator;
|
|
|
+ bool doUserTallies;
|
|
|
|
|
|
// Un-serialize request
|
|
|
- bool doUserTallies = read_epoch_update_string(filename, pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits, nextGenerator);
|
|
|
+ ssize_t bandwidthRcv = read_epoch_update_string(filename, pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits, nextGenerator, doUserTallies);
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthDataBefore = get_log_data(civetServer->getContext());
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeBefore = std::chrono::high_resolution_clock::now();
|
|
|
+ clock_t cpuTimeBefore = clock();
|
|
|
|
|
|
// Load data into server object
|
|
|
prsonaServer->accept_epoch_updates(pi, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits, serverTallyCommits, partwayVoteMatrixCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits, nextGenerator, doUserTallies);
|
|
|
|
|
|
+ clock_t cpuTimeAfter = clock();
|
|
|
+ std::chrono::high_resolution_clock::time_point wallTimeAfter = std::chrono::high_resolution_clock::now();
|
|
|
+ std::vector<size_t> bandwidthDataAfter = get_log_data(civetServer->getContext());
|
|
|
+
|
|
|
+ std::vector<double> timingData(2);
|
|
|
+ timingData[0] = std::chrono::duration_cast<std::chrono::duration<double>>(wallTimeAfter - wallTimeBefore).count();
|
|
|
+ timingData[1] = ((double)(cpuTimeAfter - cpuTimeBefore)) / CLOCKS_PER_SEC;
|
|
|
+
|
|
|
+ std::vector<size_t> bandwidthData(2);
|
|
|
+ bandwidthData[0] = bandwidthDataAfter[0] - bandwidthDataBefore[0] + bandwidthRcv;
|
|
|
+ bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
+
|
|
|
+ write_log_data(breakDownOutputMtx, breakDownOutputFilename, timingData, bandwidthData);
|
|
|
+
|
|
|
// Acknowledge receipt of request
|
|
|
mg_websocket_write(conn, MG_WEBSOCKET_OPCODE_DATACOMPLETE, "", 0);
|
|
|
}
|