|
@@ -34,11 +34,21 @@ Curvepoint PrsonaServerEntity::get_fresh_generator(Proof& pi) const
|
|
|
{
|
|
|
Curvepoint retval = PrsonaServer::elGamalGenerator;
|
|
|
for (size_t j = 0; j < servers.size(); j++)
|
|
|
- servers[j].add_seed_to_generator(pi, retval);
|
|
|
+ retval = servers[j].add_seed_to_generator(pi, retval);
|
|
|
|
|
|
return retval;
|
|
|
}
|
|
|
|
|
|
+Scalar PrsonaServerEntity::decrypt(const CurveBipoint& input)
|
|
|
+{
|
|
|
+ return servers[0].bgn_system.decrypt(input);
|
|
|
+}
|
|
|
+
|
|
|
+std::vector<CurveBipoint> PrsonaServerEntity::get_current_votes_by(Proof& pi, const Curvepoint& shortTermPublicKey) const
|
|
|
+{
|
|
|
+ return servers[0].get_current_votes_by(pi, shortTermPublicKey);
|
|
|
+}
|
|
|
+
|
|
|
void PrsonaServerEntity::add_new_client(PrsonaClient& newUser)
|
|
|
{
|
|
|
Proof proofOfValidGenerator, proofOfValidSTPK, proofOfCorrectAddition, proofOfDefaultTally, proofOfValidVotes;
|
|
@@ -59,7 +69,6 @@ void PrsonaServerEntity::add_new_client(PrsonaClient& newUser)
|
|
|
|
|
|
EGCiphertext defaultTally = get_default_tally(proofOfDefaultTally, shortTermPublicKey);
|
|
|
newUser.receive_vote_tally(proofOfDefaultTally, defaultTally, true);
|
|
|
-
|
|
|
std::vector<CurveBipoint> encryptedDefaults = servers[0].get_current_votes_by(proofOfValidVotes, shortTermPublicKey);
|
|
|
newUser.receive_encrypted_votes(proofOfValidVotes, encryptedDefaults, true);
|
|
|
}
|
|
@@ -72,25 +81,21 @@ void PrsonaServerEntity::receive_vote(const Proof& pi, const std::vector<CurveBi
|
|
|
|
|
|
void PrsonaServerEntity::epoch()
|
|
|
{
|
|
|
- Proof pi, proofOfCorrectTally;
|
|
|
+ Proof pi, proofOfCorrectTally, testUserPi;
|
|
|
Curvepoint nextGenerator = PrsonaServer::elGamalGenerator;
|
|
|
std::vector<Scalar> decryptedTalliedScores = tally_scores(proofOfCorrectTally);
|
|
|
std::vector<TwistBipoint> previousVoteTally;
|
|
|
std::vector<Curvepoint> currentPseudonyms;
|
|
|
std::vector<std::vector<CurveBipoint>> voteMatrix;
|
|
|
|
|
|
- for (size_t i = 0; i < servers.size() - 1; i++)
|
|
|
+ for (size_t i = 0; i < servers.size(); i++)
|
|
|
{
|
|
|
servers[i].epoch_part_one(pi, nextGenerator, decryptedTalliedScores);
|
|
|
-
|
|
|
servers[i].export_updates(previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
- servers[i + 1].import_updates(pi, previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
+ if (i < servers.size() - 1)
|
|
|
+ servers[i + 1].import_updates(pi, previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
}
|
|
|
|
|
|
- servers[servers.size() - 1].epoch_part_one(pi, nextGenerator, decryptedTalliedScores);
|
|
|
-
|
|
|
- servers[servers.size() - 1].export_updates(previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
-
|
|
|
encryptedTallies.clear();
|
|
|
for (size_t i = 0; i < decryptedTalliedScores.size(); i++)
|
|
|
{
|
|
@@ -109,22 +114,20 @@ void PrsonaServerEntity::epoch()
|
|
|
pi = generate_epoch_round_one_proof(pi, proofOfCorrectTally);
|
|
|
servers[0].import_updates(pi, previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
|
|
|
- for (size_t i = 0; i < servers.size() - 1; i++)
|
|
|
+ for (size_t i = 0; i < servers.size(); i++)
|
|
|
{
|
|
|
servers[i].epoch_part_two(pi, encryptedTallies);
|
|
|
-
|
|
|
servers[i].export_updates(previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
- servers[i + 1].import_updates(pi, previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
+ if (i < servers.size() - 1)
|
|
|
+ servers[i + 1].import_updates(pi, previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
}
|
|
|
|
|
|
- servers[servers.size() - 1].epoch_part_two(pi, encryptedTallies);
|
|
|
-
|
|
|
- servers[servers.size() - 1].export_updates(previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
for (size_t i = 0; i < servers.size() - 1; i++)
|
|
|
servers[i].import_updates(pi, previousVoteTally, currentPseudonyms, voteMatrix);
|
|
|
|
|
|
+ tallyProofs.clear();
|
|
|
for (size_t i = 0; i < encryptedTallies.size(); i++)
|
|
|
- tallyProofs[i] = generate_epoch_proof(pi, encryptedTallies[i]);
|
|
|
+ tallyProofs.push_back(generate_epoch_proof(pi, encryptedTallies[i]));
|
|
|
}
|
|
|
|
|
|
void PrsonaServerEntity::transmit_score(PrsonaClient& newUser) const
|