|
@@ -11,14 +11,17 @@
|
|
*/
|
|
*/
|
|
|
|
|
|
// Used to generate the first server; instantiates BGN for the first time
|
|
// Used to generate the first server; instantiates BGN for the first time
|
|
-PrsonaServer::PrsonaServer(size_t numServers)
|
|
|
|
|
|
+PrsonaServer::PrsonaServer(
|
|
|
|
+ size_t numServers)
|
|
: numServers(numServers)
|
|
: numServers(numServers)
|
|
{
|
|
{
|
|
currentSeed.set_random();
|
|
currentSeed.set_random();
|
|
}
|
|
}
|
|
|
|
|
|
// Used for all other servers, so they have the same BGN parameters
|
|
// Used for all other servers, so they have the same BGN parameters
|
|
-PrsonaServer::PrsonaServer(size_t numServers, const BGN& otherBgn)
|
|
|
|
|
|
+PrsonaServer::PrsonaServer(
|
|
|
|
+ size_t numServers,
|
|
|
|
+ const BGN& otherBgn)
|
|
: numServers(numServers), bgnSystem(otherBgn)
|
|
: numServers(numServers), bgnSystem(otherBgn)
|
|
{
|
|
{
|
|
currentSeed.set_random();
|
|
currentSeed.set_random();
|
|
@@ -43,7 +46,8 @@ size_t PrsonaServer::get_num_servers() const
|
|
return numServers;
|
|
return numServers;
|
|
}
|
|
}
|
|
|
|
|
|
-Twistpoint PrsonaServer::get_fresh_generator(std::vector<Proof>& pi) const
|
|
|
|
|
|
+Twistpoint PrsonaServer::get_fresh_generator(
|
|
|
|
+ std::vector<Proof>& pi) const
|
|
{
|
|
{
|
|
pi = currentGeneratorProof;
|
|
pi = currentGeneratorProof;
|
|
return currentFreshGenerator;
|
|
return currentFreshGenerator;
|
|
@@ -84,7 +88,8 @@ Twistpoint PrsonaServer::add_next_seed_to_generator(
|
|
* In practice, this is intended for clients,
|
|
* In practice, this is intended for clients,
|
|
* who need to know their current votes in order to rerandomize them. */
|
|
* who need to know their current votes in order to rerandomize them. */
|
|
std::vector<TwistBipoint> PrsonaServer::get_current_votes_by(
|
|
std::vector<TwistBipoint> PrsonaServer::get_current_votes_by(
|
|
- Proof& pi, const Twistpoint& shortTermPublicKey) const
|
|
|
|
|
|
+ Proof& pi,
|
|
|
|
+ const Twistpoint& shortTermPublicKey) const
|
|
{
|
|
{
|
|
std::vector<TwistBipoint> retval;
|
|
std::vector<TwistBipoint> retval;
|
|
size_t voteSubmitter = binary_search(shortTermPublicKey);
|
|
size_t voteSubmitter = binary_search(shortTermPublicKey);
|
|
@@ -106,7 +111,8 @@ std::vector<std::vector<TwistBipoint>> PrsonaServer::get_all_current_votes(
|
|
* In practice, this is intended for clients, so that the servers vouch
|
|
* In practice, this is intended for clients, so that the servers vouch
|
|
* for their ciphertexts being valid as part of their reputation proofs. */
|
|
* for their ciphertexts being valid as part of their reputation proofs. */
|
|
EGCiphertext PrsonaServer::get_current_user_encrypted_tally(
|
|
EGCiphertext PrsonaServer::get_current_user_encrypted_tally(
|
|
- Proof& pi, const Twistpoint& shortTermPublicKey) const
|
|
|
|
|
|
+ Proof& pi,
|
|
|
|
+ const Twistpoint& shortTermPublicKey) const
|
|
{
|
|
{
|
|
EGCiphertext retval;
|
|
EGCiphertext retval;
|
|
size_t tallyOwner = binary_search(shortTermPublicKey);
|
|
size_t tallyOwner = binary_search(shortTermPublicKey);
|
|
@@ -117,7 +123,8 @@ EGCiphertext PrsonaServer::get_current_user_encrypted_tally(
|
|
}
|
|
}
|
|
|
|
|
|
CurveBipoint PrsonaServer::get_current_server_encrypted_tally(
|
|
CurveBipoint PrsonaServer::get_current_server_encrypted_tally(
|
|
- Proof& pi, const Twistpoint& shortTermPublicKey) const
|
|
|
|
|
|
+ Proof& pi,
|
|
|
|
+ const Twistpoint& shortTermPublicKey) const
|
|
{
|
|
{
|
|
CurveBipoint retval;
|
|
CurveBipoint retval;
|
|
size_t tallyOwner = binary_search(shortTermPublicKey);
|
|
size_t tallyOwner = binary_search(shortTermPublicKey);
|
|
@@ -127,7 +134,8 @@ CurveBipoint PrsonaServer::get_current_server_encrypted_tally(
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
-std::vector<Twistpoint> PrsonaServer::get_current_pseudonyms(Proof& pi) const
|
|
|
|
|
|
+std::vector<Twistpoint> PrsonaServer::get_current_pseudonyms(
|
|
|
|
+ Proof& pi) const
|
|
{
|
|
{
|
|
pi = generate_valid_pseudonyms_proof(currentPseudonyms);
|
|
pi = generate_valid_pseudonyms_proof(currentPseudonyms);
|
|
return currentPseudonyms;
|
|
return currentPseudonyms;
|
|
@@ -142,7 +150,8 @@ std::vector<Twistpoint> PrsonaServer::get_current_pseudonyms() const
|
|
* PROOF COMMITMENT GETTERS
|
|
* PROOF COMMITMENT GETTERS
|
|
*/
|
|
*/
|
|
|
|
|
|
-Proof PrsonaServer::get_vote_row_commitment(const Twistpoint& request) const
|
|
|
|
|
|
+Proof PrsonaServer::get_vote_row_commitment(
|
|
|
|
+ const Twistpoint& request) const
|
|
{
|
|
{
|
|
size_t requestID = binary_search(request);
|
|
size_t requestID = binary_search(request);
|
|
return generate_valid_vote_row_proof(voteMatrix[requestID]);
|
|
return generate_valid_vote_row_proof(voteMatrix[requestID]);
|
|
@@ -153,13 +162,15 @@ Proof PrsonaServer::get_vote_matrix_commitment() const
|
|
return generate_valid_vote_matrix_proof(voteMatrix);
|
|
return generate_valid_vote_matrix_proof(voteMatrix);
|
|
}
|
|
}
|
|
|
|
|
|
-Proof PrsonaServer::get_user_tally_commitment(const Twistpoint& request) const
|
|
|
|
|
|
+Proof PrsonaServer::get_user_tally_commitment(
|
|
|
|
+ const Twistpoint& request) const
|
|
{
|
|
{
|
|
size_t requestID = binary_search(request);
|
|
size_t requestID = binary_search(request);
|
|
return generate_valid_user_tally_proof(currentUserEncryptedTallies[requestID]);
|
|
return generate_valid_user_tally_proof(currentUserEncryptedTallies[requestID]);
|
|
}
|
|
}
|
|
|
|
|
|
-Proof PrsonaServer::get_server_tally_commitment(const Twistpoint& request) const
|
|
|
|
|
|
+Proof PrsonaServer::get_server_tally_commitment(
|
|
|
|
+ const Twistpoint& request) const
|
|
{
|
|
{
|
|
size_t requestID = binary_search(request);
|
|
size_t requestID = binary_search(request);
|
|
return generate_valid_server_tally_proof(previousVoteTallies[requestID]);
|
|
return generate_valid_server_tally_proof(previousVoteTallies[requestID]);
|
|
@@ -203,8 +214,7 @@ void PrsonaServer::add_new_client(
|
|
const Proof& proofOfValidKey,
|
|
const Proof& proofOfValidKey,
|
|
const Twistpoint& shortTermPublicKey)
|
|
const Twistpoint& shortTermPublicKey)
|
|
{
|
|
{
|
|
- if (!verify_ownership_proof(
|
|
|
|
- proofOfValidKey, currentFreshGenerator, shortTermPublicKey))
|
|
|
|
|
|
+ if (!verify_ownership_proof(proofOfValidKey, currentFreshGenerator, shortTermPublicKey))
|
|
{
|
|
{
|
|
std::cerr << "Could not verify proof of valid key." << std::endl;
|
|
std::cerr << "Could not verify proof of valid key." << std::endl;
|
|
return;
|
|
return;
|
|
@@ -215,26 +225,21 @@ void PrsonaServer::add_new_client(
|
|
// The first epoch's score for a new user will be low,
|
|
// The first epoch's score for a new user will be low,
|
|
// but will typically converge on an average score quickly
|
|
// but will typically converge on an average score quickly
|
|
Scalar tallySeed;
|
|
Scalar tallySeed;
|
|
- CurveBipoint encryptedDefaultTally =
|
|
|
|
- bgnSystem.get_public_key().curveEncrypt(tallySeed, DEFAULT_TALLY);
|
|
|
|
|
|
+ CurveBipoint encryptedDefaultTally = bgnSystem.get_public_key().curveEncrypt(tallySeed, DEFAULT_TALLY);
|
|
previousVoteTallies.push_back(encryptedDefaultTally);
|
|
previousVoteTallies.push_back(encryptedDefaultTally);
|
|
|
|
|
|
Scalar seedForUserTally;
|
|
Scalar seedForUserTally;
|
|
seedForUserTally.set_random();
|
|
seedForUserTally.set_random();
|
|
EGCiphertext newUserEncryptedTally;
|
|
EGCiphertext newUserEncryptedTally;
|
|
newUserEncryptedTally.mask = shortTermPublicKey * seedForUserTally;
|
|
newUserEncryptedTally.mask = shortTermPublicKey * seedForUserTally;
|
|
- newUserEncryptedTally.encryptedMessage =
|
|
|
|
- currentFreshGenerator * seedForUserTally +
|
|
|
|
- elGamalBlindGenerator * DEFAULT_TALLY;
|
|
|
|
|
|
+ newUserEncryptedTally.encryptedMessage = currentFreshGenerator * seedForUserTally + elGamalBlindGenerator * DEFAULT_TALLY;
|
|
currentUserEncryptedTallies.push_back(newUserEncryptedTally);
|
|
currentUserEncryptedTallies.push_back(newUserEncryptedTally);
|
|
|
|
|
|
// Users are defaulted to casting a neutral vote for others.
|
|
// Users are defaulted to casting a neutral vote for others.
|
|
TwistBipoint encryptedDefaultVote, encryptedSelfVote;
|
|
TwistBipoint encryptedDefaultVote, encryptedSelfVote;
|
|
Scalar currDefaultSeed, currSelfSeed;
|
|
Scalar currDefaultSeed, currSelfSeed;
|
|
- encryptedDefaultVote =
|
|
|
|
- bgnSystem.get_public_key().twistEncrypt(currDefaultSeed, DEFAULT_VOTE);
|
|
|
|
- encryptedSelfVote =
|
|
|
|
- bgnSystem.get_public_key().twistEncrypt(currSelfSeed, Scalar(MAX_ALLOWED_VOTE));
|
|
|
|
|
|
+ encryptedDefaultVote = bgnSystem.get_public_key().twistEncrypt(currDefaultSeed, DEFAULT_VOTE);
|
|
|
|
+ encryptedSelfVote = bgnSystem.get_public_key().twistEncrypt(currSelfSeed, Scalar(MAX_ALLOWED_VOTE));
|
|
|
|
|
|
std::vector<TwistBipoint> newRow;
|
|
std::vector<TwistBipoint> newRow;
|
|
std::vector<Scalar> userVoteSeeds;
|
|
std::vector<Scalar> userVoteSeeds;
|
|
@@ -280,11 +285,7 @@ void PrsonaServer::add_new_client(
|
|
newOtherVoteSeeds.push_back(otherVoteSeeds[sortOrder[i]]);
|
|
newOtherVoteSeeds.push_back(otherVoteSeeds[sortOrder[i]]);
|
|
}
|
|
}
|
|
|
|
|
|
- proofOfValidAddition = generate_proof_of_added_user(
|
|
|
|
- tallySeed,
|
|
|
|
- seedForUserTally,
|
|
|
|
- newUserVoteSeeds,
|
|
|
|
- newOtherVoteSeeds);
|
|
|
|
|
|
+ proofOfValidAddition = generate_proof_of_added_user(tallySeed, seedForUserTally, newUserVoteSeeds, newOtherVoteSeeds);
|
|
}
|
|
}
|
|
|
|
|
|
// Receive a new vote row from a user (identified by short term public key).
|
|
// Receive a new vote row from a user (identified by short term public key).
|
|
@@ -372,9 +373,7 @@ std::vector<Scalar> PrsonaServer::tally_scores()
|
|
// ZIP
|
|
// ZIP
|
|
for (size_t j = 0; j < previousVoteTallies.size(); j++)
|
|
for (size_t j = 0; j < previousVoteTallies.size(); j++)
|
|
{
|
|
{
|
|
- Quadripoint curr =
|
|
|
|
- bgnSystem.homomorphic_multiplication_no_rerandomize(
|
|
|
|
- previousVoteTallies[j], voteMatrix[j][i]);
|
|
|
|
|
|
+ Quadripoint curr = bgnSystem.homomorphic_multiplication_no_rerandomize(previousVoteTallies[j], voteMatrix[j][i]);
|
|
|
|
|
|
weightedVotes.push_back(curr);
|
|
weightedVotes.push_back(curr);
|
|
}
|
|
}
|
|
@@ -382,11 +381,7 @@ std::vector<Scalar> PrsonaServer::tally_scores()
|
|
// FOLDL
|
|
// FOLDL
|
|
Quadripoint currEncryptedTally = weightedVotes[0];
|
|
Quadripoint currEncryptedTally = weightedVotes[0];
|
|
for (size_t j = 1; j < weightedVotes.size(); j++)
|
|
for (size_t j = 1; j < weightedVotes.size(); j++)
|
|
- {
|
|
|
|
- currEncryptedTally =
|
|
|
|
- bgnSystem.homomorphic_addition_no_rerandomize(
|
|
|
|
- currEncryptedTally, weightedVotes[j]);
|
|
|
|
- }
|
|
|
|
|
|
+ currEncryptedTally = bgnSystem.homomorphic_addition_no_rerandomize(currEncryptedTally, weightedVotes[j]);
|
|
|
|
|
|
// DECRYPT
|
|
// DECRYPT
|
|
decryptedTallies.push_back(bgnSystem.decrypt(currEncryptedTally));
|
|
decryptedTallies.push_back(bgnSystem.decrypt(currEncryptedTally));
|
|
@@ -405,11 +400,7 @@ Scalar PrsonaServer::get_max_possible_score()
|
|
// FOLDL
|
|
// FOLDL
|
|
CurveBipoint currEncryptedVal = previousVoteTallies[0];
|
|
CurveBipoint currEncryptedVal = previousVoteTallies[0];
|
|
for (size_t i = 1; i < previousVoteTallies.size(); i++)
|
|
for (size_t i = 1; i < previousVoteTallies.size(); i++)
|
|
- {
|
|
|
|
- currEncryptedVal =
|
|
|
|
- bgnSystem.homomorphic_addition_no_rerandomize(
|
|
|
|
- currEncryptedVal, previousVoteTallies[i]);
|
|
|
|
- }
|
|
|
|
|
|
+ currEncryptedVal = bgnSystem.homomorphic_addition_no_rerandomize(currEncryptedVal, previousVoteTallies[i]);
|
|
|
|
|
|
// DECRYPT
|
|
// DECRYPT
|
|
Scalar retval = bgnSystem.decrypt(currEncryptedVal);
|
|
Scalar retval = bgnSystem.decrypt(currEncryptedVal);
|
|
@@ -458,19 +449,7 @@ void PrsonaServer::build_up_midway_pseudonyms(
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMaskCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMaskCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMessageCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMessageCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallySeedCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallySeedCommits;
|
|
- pi.push_back(epoch_calculations(
|
|
|
|
- currPermutationCommits,
|
|
|
|
- currFreshPseudonymCommits,
|
|
|
|
- currFreshPseudonymSeedCommits,
|
|
|
|
- currServerTallyCommits,
|
|
|
|
- currPartwayVoteMatrixCommits,
|
|
|
|
- currFinalVoteMatrixCommits,
|
|
|
|
- currUserTallyMaskCommits,
|
|
|
|
- currUserTallyMessageCommits,
|
|
|
|
- currUserTallySeedCommits,
|
|
|
|
- nextSeed,
|
|
|
|
- nextGenerator,
|
|
|
|
- false));
|
|
|
|
|
|
+ pi.push_back(epoch_calculations(currPermutationCommits, currFreshPseudonymCommits, currFreshPseudonymSeedCommits, currServerTallyCommits, currPartwayVoteMatrixCommits, currFinalVoteMatrixCommits, currUserTallyMaskCommits, currUserTallyMessageCommits, currUserTallySeedCommits, nextSeed, nextGenerator, false));
|
|
|
|
|
|
permutationCommits.push_back(currPermutationCommits);
|
|
permutationCommits.push_back(currPermutationCommits);
|
|
freshPseudonymCommits.push_back(currFreshPseudonymCommits);
|
|
freshPseudonymCommits.push_back(currFreshPseudonymCommits);
|
|
@@ -479,8 +458,7 @@ void PrsonaServer::build_up_midway_pseudonyms(
|
|
partwayVoteMatrixCommits.push_back(currPartwayVoteMatrixCommits);
|
|
partwayVoteMatrixCommits.push_back(currPartwayVoteMatrixCommits);
|
|
finalVoteMatrixCommits.push_back(currFinalVoteMatrixCommits);
|
|
finalVoteMatrixCommits.push_back(currFinalVoteMatrixCommits);
|
|
|
|
|
|
- pi[0][0].push_back(
|
|
|
|
- add_to_generator_proof(nextGenerator, nextSeed));
|
|
|
|
|
|
+ pi[0][0].push_back(add_to_generator_proof(nextGenerator, nextSeed));
|
|
nextGenerator = nextGenerator * nextSeed;
|
|
nextGenerator = nextGenerator * nextSeed;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -519,19 +497,7 @@ void PrsonaServer::break_down_midway_pseudonyms(
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMaskCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMaskCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMessageCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallyMessageCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallySeedCommits;
|
|
std::vector<std::vector<Twistpoint>> currUserTallySeedCommits;
|
|
- pi.push_back(epoch_calculations(
|
|
|
|
- currPermutationCommits,
|
|
|
|
- currFreshPseudonymCommits,
|
|
|
|
- currFreshPseudonymSeedCommits,
|
|
|
|
- currServerTallyCommits,
|
|
|
|
- currPartwayVoteMatrixCommits,
|
|
|
|
- currFinalVoteMatrixCommits,
|
|
|
|
- currUserTallyMaskCommits,
|
|
|
|
- currUserTallyMessageCommits,
|
|
|
|
- currUserTallySeedCommits,
|
|
|
|
- inverseSeed,
|
|
|
|
- nextGenerator,
|
|
|
|
- true));
|
|
|
|
|
|
+ pi.push_back(epoch_calculations(currPermutationCommits, currFreshPseudonymCommits, currFreshPseudonymSeedCommits, currServerTallyCommits, currPartwayVoteMatrixCommits, currFinalVoteMatrixCommits, currUserTallyMaskCommits, currUserTallyMessageCommits, currUserTallySeedCommits, inverseSeed, nextGenerator, true));
|
|
|
|
|
|
permutationCommits.push_back(currPermutationCommits);
|
|
permutationCommits.push_back(currPermutationCommits);
|
|
freshPseudonymCommits.push_back(currFreshPseudonymCommits);
|
|
freshPseudonymCommits.push_back(currFreshPseudonymCommits);
|
|
@@ -566,94 +532,40 @@ std::vector<std::vector<Proof>> PrsonaServer::epoch_calculations(
|
|
{
|
|
{
|
|
std::vector<std::vector<Proof>> retval;
|
|
std::vector<std::vector<Proof>> retval;
|
|
|
|
|
|
- std::vector<std::vector<Scalar>> permutations =
|
|
|
|
- generate_permutation_matrix(power);
|
|
|
|
|
|
+ std::vector<std::vector<Scalar>> permutations = generate_permutation_matrix(power);
|
|
|
|
|
|
std::vector<std::vector<Scalar>> permutationSeeds;
|
|
std::vector<std::vector<Scalar>> permutationSeeds;
|
|
permutationCommits.clear();
|
|
permutationCommits.clear();
|
|
- permutationCommits =
|
|
|
|
- generate_commitment_matrix(permutations, permutationSeeds);
|
|
|
|
|
|
+ permutationCommits = generate_commitment_matrix(permutations, permutationSeeds);
|
|
|
|
|
|
- retval.push_back(generate_valid_permutation_proof(
|
|
|
|
- permutations, permutationSeeds, permutationCommits));
|
|
|
|
|
|
+ retval.push_back(generate_valid_permutation_proof(permutations, permutationSeeds, permutationCommits));
|
|
|
|
|
|
std::vector<std::vector<Scalar>> freshPseudonymSeeds;
|
|
std::vector<std::vector<Scalar>> freshPseudonymSeeds;
|
|
freshPseudonymSeedCommits.clear();
|
|
freshPseudonymSeedCommits.clear();
|
|
freshPseudonymCommits.clear();
|
|
freshPseudonymCommits.clear();
|
|
- freshPseudonymCommits =
|
|
|
|
- generate_pseudonym_matrix(
|
|
|
|
- permutations,
|
|
|
|
- power,
|
|
|
|
- freshPseudonymSeeds,
|
|
|
|
- freshPseudonymSeedCommits);
|
|
|
|
-
|
|
|
|
- retval.push_back(
|
|
|
|
- generate_proof_of_reordering_plus_power(
|
|
|
|
- permutations,
|
|
|
|
- power,
|
|
|
|
- permutationSeeds,
|
|
|
|
- freshPseudonymSeeds,
|
|
|
|
- currentPseudonyms,
|
|
|
|
- permutationCommits,
|
|
|
|
- freshPseudonymCommits,
|
|
|
|
- freshPseudonymSeedCommits));
|
|
|
|
|
|
+ freshPseudonymCommits = generate_pseudonym_matrix(permutations, power, freshPseudonymSeeds, freshPseudonymSeedCommits);
|
|
|
|
+
|
|
|
|
+ retval.push_back(generate_proof_of_reordering_plus_power(permutations, power, permutationSeeds, freshPseudonymSeeds, currentPseudonyms, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits));
|
|
|
|
|
|
std::vector<std::vector<Scalar>> serverTallySeeds;
|
|
std::vector<std::vector<Scalar>> serverTallySeeds;
|
|
serverTallyCommits.clear();
|
|
serverTallyCommits.clear();
|
|
- serverTallyCommits =
|
|
|
|
- generate_server_tally_matrix(
|
|
|
|
- permutations,
|
|
|
|
- serverTallySeeds);
|
|
|
|
-
|
|
|
|
- retval.push_back(
|
|
|
|
- generate_proof_of_reordering<CurveBipoint>(
|
|
|
|
- permutations,
|
|
|
|
- permutationSeeds,
|
|
|
|
- serverTallySeeds,
|
|
|
|
- previousVoteTallies,
|
|
|
|
- permutationCommits,
|
|
|
|
- serverTallyCommits,
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curvegen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen()));
|
|
|
|
|
|
+ serverTallyCommits = generate_server_tally_matrix(permutations, serverTallySeeds);
|
|
|
|
+
|
|
|
|
+ retval.push_back(generate_proof_of_reordering<CurveBipoint>(permutations, permutationSeeds, serverTallySeeds, previousVoteTallies, permutationCommits, serverTallyCommits, bgnSystem.get_public_key().get_bipoint_curvegen(), bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen()));
|
|
|
|
|
|
std::vector<std::vector<std::vector<Scalar>>> partwayVoteMatrixSeeds;
|
|
std::vector<std::vector<std::vector<Scalar>>> partwayVoteMatrixSeeds;
|
|
std::vector<std::vector<std::vector<Scalar>>> finalVoteMatrixSeeds;
|
|
std::vector<std::vector<std::vector<Scalar>>> finalVoteMatrixSeeds;
|
|
partwayVoteMatrixCommits.clear();
|
|
partwayVoteMatrixCommits.clear();
|
|
- partwayVoteMatrixCommits = generate_vote_tensor(
|
|
|
|
- permutations,
|
|
|
|
- voteMatrix,
|
|
|
|
- partwayVoteMatrixSeeds,
|
|
|
|
- false);
|
|
|
|
|
|
+ partwayVoteMatrixCommits = generate_vote_tensor(permutations, voteMatrix, partwayVoteMatrixSeeds, false);
|
|
|
|
|
|
- std::vector<std::vector<TwistBipoint>> partialVoteMatrix =
|
|
|
|
- calculate_next_vote_matrix(partwayVoteMatrixCommits);
|
|
|
|
|
|
+ std::vector<std::vector<TwistBipoint>> partialVoteMatrix = calculate_next_vote_matrix(partwayVoteMatrixCommits);
|
|
|
|
|
|
finalVoteMatrixCommits.clear();
|
|
finalVoteMatrixCommits.clear();
|
|
- finalVoteMatrixCommits = generate_vote_tensor(
|
|
|
|
- permutations,
|
|
|
|
- partialVoteMatrix,
|
|
|
|
- finalVoteMatrixSeeds,
|
|
|
|
- true);
|
|
|
|
-
|
|
|
|
- generate_vote_tensor_proofs(
|
|
|
|
- retval,
|
|
|
|
- permutations,
|
|
|
|
- permutationSeeds,
|
|
|
|
- partwayVoteMatrixSeeds,
|
|
|
|
- voteMatrix,
|
|
|
|
- permutationCommits,
|
|
|
|
- partwayVoteMatrixCommits,
|
|
|
|
- false);
|
|
|
|
-
|
|
|
|
- generate_vote_tensor_proofs(
|
|
|
|
- retval,
|
|
|
|
- permutations,
|
|
|
|
- permutationSeeds,
|
|
|
|
- finalVoteMatrixSeeds,
|
|
|
|
- partialVoteMatrix,
|
|
|
|
- permutationCommits,
|
|
|
|
- finalVoteMatrixCommits,
|
|
|
|
- true);
|
|
|
|
|
|
+ finalVoteMatrixCommits = generate_vote_tensor(permutations, partialVoteMatrix, finalVoteMatrixSeeds, true);
|
|
|
|
+
|
|
|
|
+ generate_vote_tensor_proofs(retval, permutations, permutationSeeds, partwayVoteMatrixSeeds, voteMatrix, permutationCommits, partwayVoteMatrixCommits, false);
|
|
|
|
+
|
|
|
|
+ generate_vote_tensor_proofs(retval, permutations, permutationSeeds, finalVoteMatrixSeeds, partialVoteMatrix, permutationCommits, finalVoteMatrixCommits, true);
|
|
|
|
|
|
if (doUserTallies)
|
|
if (doUserTallies)
|
|
{
|
|
{
|
|
@@ -663,41 +575,13 @@ std::vector<std::vector<Proof>> PrsonaServer::epoch_calculations(
|
|
userTallyMaskCommits.clear();
|
|
userTallyMaskCommits.clear();
|
|
userTallyMessageCommits.clear();
|
|
userTallyMessageCommits.clear();
|
|
userTallySeedCommits.clear();
|
|
userTallySeedCommits.clear();
|
|
- generate_user_tally_matrix(
|
|
|
|
- permutations,
|
|
|
|
- power,
|
|
|
|
- nextGenerator,
|
|
|
|
- currentPseudonyms,
|
|
|
|
- userTallyMasks,
|
|
|
|
- userTallyMaskCommits,
|
|
|
|
- userTallyMessages,
|
|
|
|
- userTallyMessageCommits,
|
|
|
|
- userTallySeeds,
|
|
|
|
- userTallySeedCommits);
|
|
|
|
-
|
|
|
|
- retval.push_back(
|
|
|
|
- generate_user_tally_proofs(
|
|
|
|
- permutations,
|
|
|
|
- power,
|
|
|
|
- nextGenerator,
|
|
|
|
- permutationSeeds,
|
|
|
|
- userTallySeeds,
|
|
|
|
- currentPseudonyms,
|
|
|
|
- userTallyMasks,
|
|
|
|
- userTallyMessages,
|
|
|
|
- permutationCommits,
|
|
|
|
- userTallyMaskCommits,
|
|
|
|
- userTallyMessageCommits,
|
|
|
|
- userTallySeedCommits));
|
|
|
|
|
|
+ generate_user_tally_matrix(permutations, power, nextGenerator, currentPseudonyms, userTallyMasks, userTallyMaskCommits, userTallyMessages, userTallyMessageCommits, userTallySeeds, userTallySeedCommits);
|
|
|
|
+
|
|
|
|
+ retval.push_back(generate_user_tally_proofs(permutations, power, nextGenerator, permutationSeeds, userTallySeeds, currentPseudonyms, userTallyMasks, userTallyMessages, permutationCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits));
|
|
}
|
|
}
|
|
|
|
|
|
// Replace internal values
|
|
// Replace internal values
|
|
- update_data(
|
|
|
|
- freshPseudonymCommits,
|
|
|
|
- serverTallyCommits,
|
|
|
|
- finalVoteMatrixCommits,
|
|
|
|
- userTallyMaskCommits,
|
|
|
|
- userTallyMessageCommits);
|
|
|
|
|
|
+ update_data(freshPseudonymCommits, serverTallyCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits);
|
|
|
|
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
@@ -729,8 +613,7 @@ bool PrsonaServer::accept_epoch_updates(
|
|
|
|
|
|
size_t currOffset = 0;
|
|
size_t currOffset = 0;
|
|
|
|
|
|
- verification =
|
|
|
|
- verify_valid_permutation_proof(pi[currOffset], permutationCommits);
|
|
|
|
|
|
+ verification = verify_valid_permutation_proof(pi[currOffset], permutationCommits);
|
|
currOffset++;
|
|
currOffset++;
|
|
if (!verification)
|
|
if (!verification)
|
|
{
|
|
{
|
|
@@ -738,13 +621,7 @@ bool PrsonaServer::accept_epoch_updates(
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- verification =
|
|
|
|
- verify_proof_of_reordering_plus_power(
|
|
|
|
- pi[currOffset],
|
|
|
|
- currentPseudonyms,
|
|
|
|
- permutationCommits,
|
|
|
|
- freshPseudonymCommits,
|
|
|
|
- freshPseudonymSeedCommits);
|
|
|
|
|
|
+ verification = verify_proof_of_reordering_plus_power(pi[currOffset], currentPseudonyms, permutationCommits, freshPseudonymCommits, freshPseudonymSeedCommits);
|
|
currOffset++;
|
|
currOffset++;
|
|
if (!verification)
|
|
if (!verification)
|
|
{
|
|
{
|
|
@@ -752,14 +629,7 @@ bool PrsonaServer::accept_epoch_updates(
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- verification =
|
|
|
|
- verify_proof_of_reordering<CurveBipoint>(
|
|
|
|
- pi[currOffset],
|
|
|
|
- previousVoteTallies,
|
|
|
|
- permutationCommits,
|
|
|
|
- serverTallyCommits,
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curvegen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen());
|
|
|
|
|
|
+ verification = verify_proof_of_reordering<CurveBipoint>( pi[currOffset], previousVoteTallies, permutationCommits, serverTallyCommits, bgnSystem.get_public_key().get_bipoint_curvegen(), bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen());
|
|
currOffset++;
|
|
currOffset++;
|
|
if (!verification)
|
|
if (!verification)
|
|
{
|
|
{
|
|
@@ -767,13 +637,7 @@ bool PrsonaServer::accept_epoch_updates(
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- verification = verify_vote_tensor_proofs(
|
|
|
|
- pi,
|
|
|
|
- currOffset,
|
|
|
|
- voteMatrix,
|
|
|
|
- permutationCommits,
|
|
|
|
- partwayVoteMatrixCommits,
|
|
|
|
- false);
|
|
|
|
|
|
+ verification = verify_vote_tensor_proofs(pi, currOffset, voteMatrix, permutationCommits, partwayVoteMatrixCommits, false);
|
|
currOffset += voteMatrix.size();
|
|
currOffset += voteMatrix.size();
|
|
if (!verification)
|
|
if (!verification)
|
|
{
|
|
{
|
|
@@ -781,15 +645,8 @@ bool PrsonaServer::accept_epoch_updates(
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
|
|
|
|
- std::vector<std::vector<TwistBipoint>> partialVoteMatrix =
|
|
|
|
- calculate_next_vote_matrix(partwayVoteMatrixCommits);
|
|
|
|
- verification = verify_vote_tensor_proofs(
|
|
|
|
- pi,
|
|
|
|
- currOffset,
|
|
|
|
- partialVoteMatrix,
|
|
|
|
- permutationCommits,
|
|
|
|
- finalVoteMatrixCommits,
|
|
|
|
- true);
|
|
|
|
|
|
+ std::vector<std::vector<TwistBipoint>> partialVoteMatrix = calculate_next_vote_matrix(partwayVoteMatrixCommits);
|
|
|
|
+ verification = verify_vote_tensor_proofs(pi, currOffset, partialVoteMatrix, permutationCommits, finalVoteMatrixCommits, true);
|
|
currOffset += voteMatrix.size();
|
|
currOffset += voteMatrix.size();
|
|
if (!verification)
|
|
if (!verification)
|
|
{
|
|
{
|
|
@@ -807,16 +664,7 @@ bool PrsonaServer::accept_epoch_updates(
|
|
userTallyMessages.push_back(currentUserEncryptedTallies[i].encryptedMessage);
|
|
userTallyMessages.push_back(currentUserEncryptedTallies[i].encryptedMessage);
|
|
}
|
|
}
|
|
|
|
|
|
- verification = verify_user_tally_proofs(
|
|
|
|
- pi[currOffset],
|
|
|
|
- nextGenerator,
|
|
|
|
- currentPseudonyms,
|
|
|
|
- userTallyMasks,
|
|
|
|
- userTallyMessages,
|
|
|
|
- permutationCommits,
|
|
|
|
- userTallyMaskCommits,
|
|
|
|
- userTallyMessageCommits,
|
|
|
|
- userTallySeedCommits);
|
|
|
|
|
|
+ verification = verify_user_tally_proofs(pi[currOffset], nextGenerator, currentPseudonyms, userTallyMasks, userTallyMessages, permutationCommits, userTallyMaskCommits, userTallyMessageCommits, userTallySeedCommits);
|
|
currOffset++;
|
|
currOffset++;
|
|
if (!verification)
|
|
if (!verification)
|
|
{
|
|
{
|
|
@@ -825,12 +673,7 @@ bool PrsonaServer::accept_epoch_updates(
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- verification = update_data(
|
|
|
|
- freshPseudonymCommits,
|
|
|
|
- serverTallyCommits,
|
|
|
|
- finalVoteMatrixCommits,
|
|
|
|
- userTallyMaskCommits,
|
|
|
|
- userTallyMessageCommits);
|
|
|
|
|
|
+ verification = update_data(freshPseudonymCommits, serverTallyCommits, finalVoteMatrixCommits, userTallyMaskCommits, userTallyMessageCommits);
|
|
|
|
|
|
return verification;
|
|
return verification;
|
|
}
|
|
}
|
|
@@ -910,25 +753,14 @@ std::vector<std::vector<Twistpoint>> PrsonaServer::generate_pseudonym_matrix(
|
|
std::vector<std::vector<Scalar>>& seeds,
|
|
std::vector<std::vector<Scalar>>& seeds,
|
|
std::vector<std::vector<Twistpoint>>& seedCommits) const
|
|
std::vector<std::vector<Twistpoint>>& seedCommits) const
|
|
{
|
|
{
|
|
- return generate_reordered_plus_power_matrix<Twistpoint>(
|
|
|
|
- permutations,
|
|
|
|
- power,
|
|
|
|
- currentPseudonyms,
|
|
|
|
- seeds,
|
|
|
|
- seedCommits,
|
|
|
|
- elGamalBlindGenerator);
|
|
|
|
|
|
+ return generate_reordered_plus_power_matrix<Twistpoint>(permutations, power, currentPseudonyms, seeds, seedCommits, elGamalBlindGenerator);
|
|
}
|
|
}
|
|
|
|
|
|
std::vector<std::vector<CurveBipoint>> PrsonaServer::generate_server_tally_matrix(
|
|
std::vector<std::vector<CurveBipoint>> PrsonaServer::generate_server_tally_matrix(
|
|
const std::vector<std::vector<Scalar>>& permutations,
|
|
const std::vector<std::vector<Scalar>>& permutations,
|
|
std::vector<std::vector<Scalar>>& seeds) const
|
|
std::vector<std::vector<Scalar>>& seeds) const
|
|
{
|
|
{
|
|
- return generate_reordered_matrix<CurveBipoint>(
|
|
|
|
- permutations,
|
|
|
|
- previousVoteTallies,
|
|
|
|
- seeds,
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen(),
|
|
|
|
- false);
|
|
|
|
|
|
+ return generate_reordered_matrix<CurveBipoint>(permutations, previousVoteTallies, seeds, bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen(), false);
|
|
}
|
|
}
|
|
|
|
|
|
std::vector<std::vector<std::vector<TwistBipoint>>> PrsonaServer::generate_vote_tensor(
|
|
std::vector<std::vector<std::vector<TwistBipoint>>> PrsonaServer::generate_vote_tensor(
|
|
@@ -954,12 +786,7 @@ std::vector<std::vector<std::vector<TwistBipoint>>> PrsonaServer::generate_vote_
|
|
inputRow = currVoteMatrix[i];
|
|
inputRow = currVoteMatrix[i];
|
|
}
|
|
}
|
|
|
|
|
|
- retval.push_back(generate_reordered_matrix<TwistBipoint>(
|
|
|
|
- permutations,
|
|
|
|
- inputRow,
|
|
|
|
- currSeeds,
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen(),
|
|
|
|
- false));
|
|
|
|
|
|
+ retval.push_back(generate_reordered_matrix<TwistBipoint>(permutations, inputRow, currSeeds, bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen(), false));
|
|
|
|
|
|
seeds.push_back(currSeeds);
|
|
seeds.push_back(currSeeds);
|
|
}
|
|
}
|
|
@@ -1013,15 +840,7 @@ void PrsonaServer::generate_vote_tensor_proofs(
|
|
inputRow = currMatrix[i];
|
|
inputRow = currMatrix[i];
|
|
}
|
|
}
|
|
|
|
|
|
- pi.push_back(generate_proof_of_reordering<TwistBipoint>(
|
|
|
|
- permutations,
|
|
|
|
- permutationSeeds,
|
|
|
|
- matrixSeeds[i],
|
|
|
|
- inputRow,
|
|
|
|
- permutationCommits,
|
|
|
|
- matrixCommits[i],
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twistgen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen()));
|
|
|
|
|
|
+ pi.push_back(generate_proof_of_reordering<TwistBipoint>(permutations, permutationSeeds, matrixSeeds[i], inputRow, permutationCommits, matrixCommits[i], bgnSystem.get_public_key().get_bipoint_twistgen(), bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen()));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1049,13 +868,7 @@ bool PrsonaServer::verify_vote_tensor_proofs(
|
|
}
|
|
}
|
|
|
|
|
|
size_t whichProof = i + start_offset;
|
|
size_t whichProof = i + start_offset;
|
|
- retval = retval && verify_proof_of_reordering<TwistBipoint>(
|
|
|
|
- pi[whichProof],
|
|
|
|
- inputRow,
|
|
|
|
- permutationCommits,
|
|
|
|
- matrixCommits[i],
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twistgen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen());
|
|
|
|
|
|
+ retval = retval && verify_proof_of_reordering<TwistBipoint>(pi[whichProof], inputRow, permutationCommits, matrixCommits[i], bgnSystem.get_public_key().get_bipoint_twistgen(), bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen());
|
|
}
|
|
}
|
|
|
|
|
|
return retval;
|
|
return retval;
|
|
@@ -1109,23 +922,18 @@ void PrsonaServer::generate_user_tally_matrix(
|
|
if (j != last)
|
|
if (j != last)
|
|
{
|
|
{
|
|
userTallySeeds[i][j].set_random();
|
|
userTallySeeds[i][j].set_random();
|
|
- userTallySeeds[i][last] =
|
|
|
|
- userTallySeeds[i][last] -
|
|
|
|
- userTallySeeds[i][j];
|
|
|
|
|
|
+ userTallySeeds[i][last] = userTallySeeds[i][last] - userTallySeeds[i][j];
|
|
}
|
|
}
|
|
|
|
|
|
- maskCommits[i][j] =
|
|
|
|
- masks[j] * permutations[j][i] * power +
|
|
|
|
|
|
+ maskCommits[i][j] = masks[j] * permutations[j][i] * power +
|
|
currPseudonyms[j] * power * permutations[j][i] * userTallySeeds[i][j] +
|
|
currPseudonyms[j] * power * permutations[j][i] * userTallySeeds[i][j] +
|
|
elGamalBlindGenerator * userTallySeeds[i][j];
|
|
elGamalBlindGenerator * userTallySeeds[i][j];
|
|
|
|
|
|
- messageCommits[i][j] =
|
|
|
|
- messages[j] * permutations[j][i] +
|
|
|
|
|
|
+ messageCommits[i][j] = messages[j] * permutations[j][i] +
|
|
nextGenerator * permutations[j][i] * userTallySeeds[i][j] +
|
|
nextGenerator * permutations[j][i] * userTallySeeds[i][j] +
|
|
elGamalBlindGenerator * userTallySeeds[i][j];
|
|
elGamalBlindGenerator * userTallySeeds[i][j];
|
|
|
|
|
|
- userTallySeedCommits[i][j] =
|
|
|
|
- EL_GAMAL_GENERATOR * userTallySeeds[i][j];
|
|
|
|
|
|
+ userTallySeedCommits[i][j] = EL_GAMAL_GENERATOR * userTallySeeds[i][j];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1155,13 +963,7 @@ std::vector<std::vector<T>> PrsonaServer::generate_reordered_plus_power_matrix(
|
|
seedCommits.push_back(currSeedCommits);
|
|
seedCommits.push_back(currSeedCommits);
|
|
}
|
|
}
|
|
|
|
|
|
- std::vector<std::vector<T>> retval =
|
|
|
|
- generate_reordered_matrix<T>(
|
|
|
|
- permutation_plus_power,
|
|
|
|
- oldValues,
|
|
|
|
- seeds,
|
|
|
|
- h,
|
|
|
|
- true);
|
|
|
|
|
|
+ std::vector<std::vector<T>> retval = generate_reordered_matrix<T>(permutation_plus_power, oldValues, seeds, h, true);
|
|
|
|
|
|
for (size_t i = 0; i < permutations.size(); i++)
|
|
for (size_t i = 0; i < permutations.size(); i++)
|
|
for (size_t j = 0; j < permutations[i].size(); j++)
|
|
for (size_t j = 0; j < permutations[i].size(); j++)
|
|
@@ -1216,7 +1018,8 @@ std::vector<std::vector<T>> PrsonaServer::generate_reordered_matrix(
|
|
return retval;
|
|
return retval;
|
|
}
|
|
}
|
|
|
|
|
|
-std::vector<size_t> PrsonaServer::sort_data(const std::vector<Twistpoint>& inputs) const
|
|
|
|
|
|
+std::vector<size_t> PrsonaServer::sort_data(
|
|
|
|
+ const std::vector<Twistpoint>& inputs) const
|
|
{
|
|
{
|
|
std::vector<size_t> retval;
|
|
std::vector<size_t> retval;
|
|
|
|
|
|
@@ -1269,10 +1072,8 @@ bool PrsonaServer::update_data(
|
|
|
|
|
|
if (!userTallyMaskCommits.empty())
|
|
if (!userTallyMaskCommits.empty())
|
|
{
|
|
{
|
|
- userTallyMask = userTallyMask +
|
|
|
|
- userTallyMaskCommits[i][j];
|
|
|
|
- userTallyMessage = userTallyMessage +
|
|
|
|
- userTallyMessageCommits[i][j];
|
|
|
|
|
|
+ userTallyMask = userTallyMask + userTallyMaskCommits[i][j];
|
|
|
|
+ userTallyMessage = userTallyMessage + userTallyMessageCommits[i][j];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1280,10 +1081,7 @@ bool PrsonaServer::update_data(
|
|
newVoteTallies.push_back(voteTallySum);
|
|
newVoteTallies.push_back(voteTallySum);
|
|
|
|
|
|
if (!userTallyMaskCommits.empty())
|
|
if (!userTallyMaskCommits.empty())
|
|
- {
|
|
|
|
- newUserTallies.push_back(
|
|
|
|
- EGCiphertext(userTallyMask, userTallyMessage));
|
|
|
|
- }
|
|
|
|
|
|
+ newUserTallies.push_back(EGCiphertext(userTallyMask, userTallyMessage));
|
|
}
|
|
}
|
|
|
|
|
|
if (!pseudonyms_sorted(newPseudonyms))
|
|
if (!pseudonyms_sorted(newPseudonyms))
|
|
@@ -1341,18 +1139,7 @@ bool PrsonaServer::import_new_user_update(
|
|
|
|
|
|
Twistpoint shortTermPublicKey = otherCurrentPseudonyms[newIndex];
|
|
Twistpoint shortTermPublicKey = otherCurrentPseudonyms[newIndex];
|
|
|
|
|
|
- bool flag = verify_proof_of_added_user(
|
|
|
|
- pi,
|
|
|
|
- currentFreshGenerator,
|
|
|
|
- shortTermPublicKey,
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twistgen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curvegen(),
|
|
|
|
- bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen(),
|
|
|
|
- newIndex,
|
|
|
|
- otherCurrentUserEncryptedTallies[newIndex],
|
|
|
|
- otherPreviousVoteTallies[newIndex],
|
|
|
|
- otherVoteMatrix);
|
|
|
|
|
|
+ bool flag = verify_proof_of_added_user(pi, currentFreshGenerator, shortTermPublicKey, bgnSystem.get_public_key().get_bipoint_twistgen(), bgnSystem.get_public_key().get_bipoint_twist_subgroup_gen(), bgnSystem.get_public_key().get_bipoint_curvegen(), bgnSystem.get_public_key().get_bipoint_curve_subgroup_gen(), newIndex, otherCurrentUserEncryptedTallies[newIndex], otherPreviousVoteTallies[newIndex], otherVoteMatrix);
|
|
|
|
|
|
if (!flag)
|
|
if (!flag)
|
|
{
|
|
{
|
|
@@ -1367,12 +1154,9 @@ bool PrsonaServer::import_new_user_update(
|
|
|
|
|
|
size_t otherI = (i > newIndex ? i - 1 : i);
|
|
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];
|
|
|
|
|
|
+ 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++)
|
|
for (size_t j = 0; j < otherCurrentPseudonyms.size(); j++)
|
|
{
|
|
{
|
|
@@ -1380,8 +1164,7 @@ bool PrsonaServer::import_new_user_update(
|
|
continue;
|
|
continue;
|
|
|
|
|
|
size_t otherJ = (j > newIndex ? j - 1 : j);
|
|
size_t otherJ = (j > newIndex ? j - 1 : j);
|
|
- flag = flag && otherVoteMatrix[i][j] ==
|
|
|
|
- voteMatrix[otherI][otherJ];
|
|
|
|
|
|
+ flag = flag && otherVoteMatrix[i][j] == voteMatrix[otherI][otherJ];
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1423,17 +1206,11 @@ std::vector<size_t> PrsonaServer::order_data()
|
|
newVoteTallies.push_back(previousVoteTallies[retval[i]]);
|
|
newVoteTallies.push_back(previousVoteTallies[retval[i]]);
|
|
|
|
|
|
if (!currentUserEncryptedTallies.empty())
|
|
if (!currentUserEncryptedTallies.empty())
|
|
- {
|
|
|
|
- newUserEncryptedTallies.push_back(
|
|
|
|
- currentUserEncryptedTallies[retval[i]]);
|
|
|
|
- }
|
|
|
|
|
|
+ newUserEncryptedTallies.push_back(currentUserEncryptedTallies[retval[i]]);
|
|
|
|
|
|
std::vector<TwistBipoint> currNewRow;
|
|
std::vector<TwistBipoint> currNewRow;
|
|
for (size_t j = 0; j < currentPseudonyms.size(); j++)
|
|
for (size_t j = 0; j < currentPseudonyms.size(); j++)
|
|
- {
|
|
|
|
- currNewRow.push_back(
|
|
|
|
- voteMatrix[retval[i]][retval[j]]);
|
|
|
|
- }
|
|
|
|
|
|
+ currNewRow.push_back(voteMatrix[retval[i]][retval[j]]);
|
|
newVoteMatrix.push_back(currNewRow);
|
|
newVoteMatrix.push_back(currNewRow);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -1450,7 +1227,8 @@ std::vector<size_t> PrsonaServer::order_data()
|
|
*/
|
|
*/
|
|
|
|
|
|
// Completely normal binary search
|
|
// Completely normal binary search
|
|
-size_t PrsonaServer::binary_search(const Twistpoint& index) const
|
|
|
|
|
|
+size_t PrsonaServer::binary_search(
|
|
|
|
+ const Twistpoint& index) const
|
|
{
|
|
{
|
|
return PrsonaBase::binary_search(currentPseudonyms, index);
|
|
return PrsonaBase::binary_search(currentPseudonyms, index);
|
|
}
|
|
}
|
|
@@ -1466,23 +1244,15 @@ bool PrsonaServer::verify_vote_proof(
|
|
const Twistpoint& shortTermPublicKey) const
|
|
const Twistpoint& shortTermPublicKey) const
|
|
{
|
|
{
|
|
const BGNPublicKey& pubKey = bgnSystem.get_public_key();
|
|
const BGNPublicKey& pubKey = bgnSystem.get_public_key();
|
|
- return PrsonaBase::verify_vote_proof(
|
|
|
|
- pubKey.get_bipoint_twistgen(),
|
|
|
|
- pubKey.get_bipoint_twist_subgroup_gen(),
|
|
|
|
- pi,
|
|
|
|
- oldVotes,
|
|
|
|
- newVotes,
|
|
|
|
- currentFreshGenerator,
|
|
|
|
- shortTermPublicKey);
|
|
|
|
|
|
+
|
|
|
|
+ return PrsonaBase::verify_vote_proof(pubKey.get_bipoint_twistgen(), pubKey.get_bipoint_twist_subgroup_gen(), pi, oldVotes, newVotes, currentFreshGenerator, shortTermPublicKey);
|
|
}
|
|
}
|
|
|
|
|
|
-void PrsonaServer::print_scores(const std::vector<CurveBipoint>& scores)
|
|
|
|
|
|
+void PrsonaServer::print_scores(
|
|
|
|
+ const std::vector<CurveBipoint>& scores)
|
|
{
|
|
{
|
|
std::cout << "[";
|
|
std::cout << "[";
|
|
for (size_t i = 0; i < scores.size(); i++)
|
|
for (size_t i = 0; i < scores.size(); i++)
|
|
- {
|
|
|
|
- std::cout << bgnSystem.decrypt(scores[i])
|
|
|
|
- << (i == scores.size() - 1 ? "]" : " ");
|
|
|
|
- }
|
|
|
|
|
|
+ std::cout << bgnSystem.decrypt(scores[i]) << (i == scores.size() - 1 ? "]" : " ");
|
|
std::cout << std::endl;
|
|
std::cout << std::endl;
|
|
}
|
|
}
|