|
@@ -84,6 +84,15 @@ std::vector<CurveBipoint> PrsonaServer::get_current_votes_by(
|
|
size_t voteSubmitter = binary_search(shortTermPublicKey);
|
|
size_t voteSubmitter = binary_search(shortTermPublicKey);
|
|
retval = voteMatrix[voteSubmitter];
|
|
retval = voteMatrix[voteSubmitter];
|
|
|
|
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
pi = generate_valid_vote_row_proof();
|
|
pi = generate_valid_vote_row_proof();
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
@@ -401,6 +410,79 @@ void PrsonaServer::break_down_midway_pseudonyms(
|
|
* DATA MAINTENANCE
|
|
* DATA MAINTENANCE
|
|
*/
|
|
*/
|
|
|
|
|
|
|
|
+bool PrsonaServer::import_new_user_update(
|
|
|
|
+ const std::vector<Proof>& pi,
|
|
|
|
+ const std::vector<TwistBipoint>& otherPreviousVoteTallies,
|
|
|
|
+ const std::vector<Curvepoint>& otherCurrentPseudonyms,
|
|
|
|
+ const std::vector<EGCiphertext>& otherCurrentUserEncryptedTallies,
|
|
|
|
+ const std::vector<std::vector<CurveBipoint>>& otherVoteMatrix)
|
|
|
|
+{
|
|
|
|
+ size_t newIndex = 0;
|
|
|
|
+ if (!currentPseudonyms.empty())
|
|
|
|
+ while (otherCurrentPseudonyms[newIndex] == currentPseudonyms[newIndex])
|
|
|
|
+ newIndex++;
|
|
|
|
+
|
|
|
|
+ Curvepoint shortTermPublicKey = otherCurrentPseudonyms[newIndex];
|
|
|
|
+
|
|
|
|
+ bool flag = verify_proof_of_added_user(
|
|
|
|
+ pi,
|
|
|
|
+ currentFreshGenerator,
|
|
|
|
+ shortTermPublicKey,
|
|
|
|
+ elGamalBlindGenerator,
|
|
|
|
+ bgnSystem.get_public_key().get_bipoint_curvegen(),
|
|
|
|
+ bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen(),
|
|
|
|
+ bgnSystem.get_public_key().get_bipoint_twistgen(),
|
|
|
|
+ bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen(),
|
|
|
|
+ newIndex,
|
|
|
|
+ otherCurrentUserEncryptedTallies[newIndex],
|
|
|
|
+ otherPreviousVoteTallies[newIndex],
|
|
|
|
+ otherVoteMatrix);
|
|
|
|
+
|
|
|
|
+ if (!flag)
|
|
|
|
+ {
|
|
|
|
+ std::cerr << "Other server added new user invalidly, aborting." << std::endl;
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ for (size_t i = 0; i < otherCurrentPseudonyms.size(); i++)
|
|
|
|
+ {
|
|
|
|
+ if (i == newIndex)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ size_t otherI = (i > newIndex ? i - 1 : i);
|
|
|
|
+
|
|
|
|
+ flag = flag && otherCurrentPseudonyms[i] ==
|
|
|
|
+ currentPseudonyms[otherI];
|
|
|
|
+ flag = flag && otherCurrentUserEncryptedTallies[i] ==
|
|
|
|
+ currentUserEncryptedTallies[otherI];
|
|
|
|
+ flag = flag && otherPreviousVoteTallies[i] ==
|
|
|
|
+ previousVoteTallies[otherI];
|
|
|
|
+
|
|
|
|
+ for (size_t j = 0; j < otherCurrentPseudonyms.size(); j++)
|
|
|
|
+ {
|
|
|
|
+ if (j == newIndex)
|
|
|
|
+ continue;
|
|
|
|
+
|
|
|
|
+ size_t otherJ = (j > newIndex ? j - 1 : j);
|
|
|
|
+ flag = flag && otherVoteMatrix[i][j] ==
|
|
|
|
+ voteMatrix[otherI][otherJ];
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (!flag)
|
|
|
|
+ {
|
|
|
|
+ std::cerr << "Other server illicitly changed other value during new user add." << std::endl;
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ previousVoteTallies = otherPreviousVoteTallies;
|
|
|
|
+ currentPseudonyms = otherCurrentPseudonyms;
|
|
|
|
+ currentUserEncryptedTallies = otherCurrentUserEncryptedTallies;
|
|
|
|
+ voteMatrix = otherVoteMatrix;
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+}
|
|
|
|
+
|
|
void PrsonaServer::import_updates(
|
|
void PrsonaServer::import_updates(
|
|
const Proof& pi,
|
|
const Proof& pi,
|
|
const std::vector<TwistBipoint>& otherPreviousVoteTallies,
|
|
const std::vector<TwistBipoint>& otherPreviousVoteTallies,
|