|
@@ -103,7 +103,9 @@ void make_epoch(
|
|
std::mutex& breakDownOutputMtx,
|
|
std::mutex& breakDownOutputMtx,
|
|
const std::string& breakDownOutputFilename,
|
|
const std::string& breakDownOutputFilename,
|
|
std::mutex& fullOutputMtx,
|
|
std::mutex& fullOutputMtx,
|
|
- const std::string& fullOutputFilename)
|
|
|
|
|
|
+ const std::string& fullOutputFilename,
|
|
|
|
+ std::mutex& usageMtx,
|
|
|
|
+ const std::string& usageFilename)
|
|
{
|
|
{
|
|
// As before, the fresh generator always starts from the same G
|
|
// As before, the fresh generator always starts from the same G
|
|
Twistpoint nextGenerator = PrsonaServer::EL_GAMAL_GENERATOR;
|
|
Twistpoint nextGenerator = PrsonaServer::EL_GAMAL_GENERATOR;
|
|
@@ -120,7 +122,7 @@ void make_epoch(
|
|
obtain_update_locks(updateLock, serverIPs, serverPorts, selfIP, selfPort, bandwidthData);
|
|
obtain_update_locks(updateLock, serverIPs, serverPorts, selfIP, selfPort, bandwidthData);
|
|
|
|
|
|
// Do the first half of the epoch calculations (building up the intermediary values)
|
|
// 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, civetServer, buildUpOutputMtx, buildUpOutputFilename, bandwidthData);
|
|
|
|
|
|
+ std::vector<Proof> generatorProof = epoch_build_up(rng, prsonaServer, serverIPs, serverPorts, selfIP, selfPort, nextGenerator, civetServer, buildUpOutputMtx, buildUpOutputFilename, usageMtx, usageFilename, bandwidthData);
|
|
|
|
|
|
// Tally up the current scores at the end of the epoch for the users
|
|
// Tally up the current scores at the end of the epoch for the users
|
|
std::vector<EGCiphertext> currentUserEncryptedTallies;
|
|
std::vector<EGCiphertext> currentUserEncryptedTallies;
|
|
@@ -131,7 +133,7 @@ void make_epoch(
|
|
distribute_tallied_scores(prsonaServer, serverIPs, serverPorts, selfIP, selfPort, nextGenerator, currentUserEncryptedTallies, currentServerEncryptedTallies, bandwidthData);
|
|
distribute_tallied_scores(prsonaServer, serverIPs, serverPorts, selfIP, selfPort, nextGenerator, currentUserEncryptedTallies, currentServerEncryptedTallies, bandwidthData);
|
|
|
|
|
|
// Do the second half of the epoch calculations (breaking down values to their final values, to be given to users)
|
|
// 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, civetServer, breakDownOutputMtx, breakDownOutputFilename, bandwidthData);
|
|
|
|
|
|
+ epoch_break_down(rng, prsonaServer, serverIPs, serverPorts, selfIP, selfPort, generatorProof, nextGenerator, civetServer, breakDownOutputMtx, breakDownOutputFilename, usageMtx, usageFilename, bandwidthData);
|
|
|
|
|
|
// Indicate we are in a new epoch
|
|
// Indicate we are in a new epoch
|
|
epochNum.fetch_add(1);
|
|
epochNum.fetch_add(1);
|
|
@@ -151,6 +153,7 @@ void make_epoch(
|
|
bandwidthData[1] += bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
bandwidthData[1] += bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
|
|
|
write_log_data(fullOutputMtx, fullOutputFilename, timingData, bandwidthData);
|
|
write_log_data(fullOutputMtx, fullOutputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
}
|
|
}
|
|
|
|
|
|
/*********************************************************
|
|
/*********************************************************
|
|
@@ -479,6 +482,8 @@ std::vector<Proof> epoch_build_up(
|
|
const CivetServer& civetServer,
|
|
const CivetServer& civetServer,
|
|
std::mutex& outputMtx,
|
|
std::mutex& outputMtx,
|
|
const std::string& outputFilename,
|
|
const std::string& outputFilename,
|
|
|
|
+ std::mutex& usageMtx,
|
|
|
|
+ const std::string& usageFilename,
|
|
std::vector<size_t>& overallBandwidthData)
|
|
std::vector<size_t>& overallBandwidthData)
|
|
{
|
|
{
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
@@ -571,6 +576,7 @@ std::vector<Proof> epoch_build_up(
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
|
|
|
|
write_log_data(outputMtx, outputFilename, timingData, bandwidthData);
|
|
write_log_data(outputMtx, outputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
|
|
|
|
// Keep an up-to-date version of the proof of the new fresh generator
|
|
// Keep an up-to-date version of the proof of the new fresh generator
|
|
generatorProofHolder = pi[0];
|
|
generatorProofHolder = pi[0];
|
|
@@ -601,6 +607,8 @@ void epoch_break_down(
|
|
const CivetServer& civetServer,
|
|
const CivetServer& civetServer,
|
|
std::mutex& outputMtx,
|
|
std::mutex& outputMtx,
|
|
const std::string& outputFilename,
|
|
const std::string& outputFilename,
|
|
|
|
+ std::mutex& usageMtx,
|
|
|
|
+ const std::string& usageFilename,
|
|
std::vector<size_t>& overallBandwidthData)
|
|
std::vector<size_t>& overallBandwidthData)
|
|
{
|
|
{
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
std::vector<std::vector<std::vector<Proof>>> pi;
|
|
@@ -690,6 +698,9 @@ void epoch_break_down(
|
|
|
|
|
|
bandwidthData[0] += serverBandwidthDataAfter[0] - serverBandwidthDataBefore[0];
|
|
bandwidthData[0] += serverBandwidthDataAfter[0] - serverBandwidthDataBefore[0];
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
|
|
+
|
|
|
|
+ write_log_data(outputMtx, outputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
}
|
|
}
|
|
else // When it's another server's turn, tell them to do their part
|
|
else // When it's another server's turn, tell them to do their part
|
|
{
|
|
{
|
|
@@ -1538,8 +1549,10 @@ PrsonaServerWebSocketHandler::PrsonaServerWebSocketHandler(
|
|
std::mutex& updateOutputMtx,
|
|
std::mutex& updateOutputMtx,
|
|
const std::string& updateOutputFilename,
|
|
const std::string& updateOutputFilename,
|
|
std::mutex& voteOutputMtx,
|
|
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)
|
|
|
|
|
|
+ const std::string& voteOutputFilename,
|
|
|
|
+ std::mutex& usageMtx,
|
|
|
|
+ const std::string& usageFilename)
|
|
|
|
+: 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), usageMtx(usageMtx), usageFilename(usageFilename)
|
|
{ /* */ }
|
|
{ /* */ }
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -2231,6 +2244,7 @@ void PrsonaServerWebSocketHandler::receive_vote(
|
|
bandwidthData[1] += bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
bandwidthData[1] += bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
|
|
|
write_log_data(voteOutputMtx, voteOutputFilename, timingData, bandwidthData);
|
|
write_log_data(voteOutputMtx, voteOutputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
|
|
|
|
// Notify client their request has been completed
|
|
// Notify client their request has been completed
|
|
mg_websocket_write(conn, MG_WEBSOCKET_OPCODE_DATACOMPLETE, "", 0);
|
|
mg_websocket_write(conn, MG_WEBSOCKET_OPCODE_DATACOMPLETE, "", 0);
|
|
@@ -2632,6 +2646,7 @@ void PrsonaServerWebSocketHandler::build_up_midway_pseudonyms(
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
|
|
|
|
write_log_data(buildUpOutputMtx, buildUpOutputFilename, timingData, bandwidthData);
|
|
write_log_data(buildUpOutputMtx, buildUpOutputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
|
|
|
|
// Serialize response
|
|
// Serialize response
|
|
data = make_epoch_initiator_string(pi[0][0], nextGenerator);
|
|
data = make_epoch_initiator_string(pi[0][0], nextGenerator);
|
|
@@ -2720,6 +2735,7 @@ void PrsonaServerWebSocketHandler::break_down_midway_pseudonyms(
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
bandwidthData[1] += serverBandwidthDataAfter[1] - serverBandwidthDataBefore[1];
|
|
|
|
|
|
write_log_data(breakDownOutputMtx, breakDownOutputFilename, timingData, bandwidthData);
|
|
write_log_data(breakDownOutputMtx, breakDownOutputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
|
|
|
|
// Keep our epoch value up-to-date
|
|
// Keep our epoch value up-to-date
|
|
epochNum.fetch_add(1);
|
|
epochNum.fetch_add(1);
|
|
@@ -2769,6 +2785,7 @@ void PrsonaServerWebSocketHandler::accept_epoch_updates(
|
|
bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
bandwidthData[1] = bandwidthDataAfter[1] - bandwidthDataBefore[1];
|
|
|
|
|
|
write_log_data(updateOutputMtx, updateOutputFilename, timingData, bandwidthData);
|
|
write_log_data(updateOutputMtx, updateOutputFilename, timingData, bandwidthData);
|
|
|
|
+ write_usage_data(usageMtx, usageFilename);
|
|
|
|
|
|
// Acknowledge receipt of request
|
|
// Acknowledge receipt of request
|
|
mg_websocket_write(conn, MG_WEBSOCKET_OPCODE_DATACOMPLETE, "", 0);
|
|
mg_websocket_write(conn, MG_WEBSOCKET_OPCODE_DATACOMPLETE, "", 0);
|