|
@@ -62,18 +62,21 @@ vector<double> make_votes(
|
|
shuffle(replaces.begin(), replaces.end(), generator);
|
|
shuffle(replaces.begin(), replaces.end(), generator);
|
|
|
|
|
|
|
|
|
|
- Proof ownerProof;
|
|
|
|
|
|
+ Proof baseProof;
|
|
|
|
+ vector<Proof> fullProof;
|
|
Curvepoint shortTermPublicKey =
|
|
Curvepoint shortTermPublicKey =
|
|
- users[i].get_short_term_public_key(ownerProof);
|
|
|
|
|
|
+ users[i].get_short_term_public_key();
|
|
vector<CurveBipoint> currEncryptedVotes =
|
|
vector<CurveBipoint> currEncryptedVotes =
|
|
- servers.get_current_votes_by(ownerProof, shortTermPublicKey);
|
|
|
|
- vector<Proof> currVoteProof;
|
|
|
|
|
|
+ servers.get_current_votes_by(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_vote_row_commitments(fullProof, shortTermPublicKey);
|
|
|
|
|
|
|
|
+ vector<Proof> currVoteProof;
|
|
chrono::high_resolution_clock::time_point t0 =
|
|
chrono::high_resolution_clock::time_point t0 =
|
|
chrono::high_resolution_clock::now();
|
|
chrono::high_resolution_clock::now();
|
|
currEncryptedVotes = users[i].make_votes(
|
|
currEncryptedVotes = users[i].make_votes(
|
|
currVoteProof,
|
|
currVoteProof,
|
|
- ownerProof,
|
|
|
|
|
|
+ fullProof,
|
|
currEncryptedVotes,
|
|
currEncryptedVotes,
|
|
votes,
|
|
votes,
|
|
replaces);
|
|
replaces);
|
|
@@ -172,6 +175,7 @@ vector<double> transmit_epoch_updates(
|
|
// Test if the proof of reputation level is working as expected
|
|
// Test if the proof of reputation level is working as expected
|
|
void test_reputation_proof(
|
|
void test_reputation_proof(
|
|
default_random_engine& generator,
|
|
default_random_engine& generator,
|
|
|
|
+ const PrsonaServerEntity& servers,
|
|
const PrsonaClient& a,
|
|
const PrsonaClient& a,
|
|
const PrsonaClient& b)
|
|
const PrsonaClient& b)
|
|
{
|
|
{
|
|
@@ -185,18 +189,43 @@ void test_reputation_proof(
|
|
Scalar goodThreshold(thresholdDistribution(generator));
|
|
Scalar goodThreshold(thresholdDistribution(generator));
|
|
Scalar badThreshold(aScore + 1);
|
|
Scalar badThreshold(aScore + 1);
|
|
|
|
|
|
- Proof pi;
|
|
|
|
- Curvepoint shortTermPublicKey = a.get_short_term_public_key(pi);
|
|
|
|
- vector<Proof> goodRepProof = a.generate_reputation_proof(goodThreshold);
|
|
|
|
|
|
+ Curvepoint shortTermPublicKey = a.get_short_term_public_key();
|
|
|
|
+ vector<Proof> goodRepProof =
|
|
|
|
+ a.generate_reputation_proof(goodThreshold, servers.get_num_clients());
|
|
|
|
+
|
|
|
|
+ Proof baseProof;
|
|
|
|
+ vector<Proof> fullProof;
|
|
|
|
+ EGCiphertext currEncryptedScore =
|
|
|
|
+ servers.get_current_user_encrypted_tally(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_user_tally_commitments(fullProof, shortTermPublicKey);
|
|
|
|
+
|
|
flag = b.verify_reputation_proof(
|
|
flag = b.verify_reputation_proof(
|
|
- goodRepProof, shortTermPublicKey, goodThreshold);
|
|
|
|
|
|
+ goodRepProof,
|
|
|
|
+ shortTermPublicKey,
|
|
|
|
+ goodThreshold,
|
|
|
|
+ fullProof,
|
|
|
|
+ currEncryptedScore);
|
|
cout << "TEST VALID REPUTATION PROOF: "
|
|
cout << "TEST VALID REPUTATION PROOF: "
|
|
<< (flag ? "PASSED (Proof verified)" : "FAILED (Proof not verified)" )
|
|
<< (flag ? "PASSED (Proof verified)" : "FAILED (Proof not verified)" )
|
|
<< endl;
|
|
<< endl;
|
|
|
|
|
|
- vector<Proof> badRepProof = a.generate_reputation_proof(badThreshold);
|
|
|
|
|
|
+ vector<Proof> badRepProof =
|
|
|
|
+ a.generate_reputation_proof(badThreshold, servers.get_num_clients());
|
|
|
|
+
|
|
|
|
+ baseProof.clear();
|
|
|
|
+ fullProof.clear();
|
|
|
|
+ currEncryptedScore =
|
|
|
|
+ servers.get_current_user_encrypted_tally(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_user_tally_commitments(fullProof, shortTermPublicKey);
|
|
|
|
+
|
|
flag = b.verify_reputation_proof(
|
|
flag = b.verify_reputation_proof(
|
|
- badRepProof, shortTermPublicKey, badThreshold);
|
|
|
|
|
|
+ badRepProof,
|
|
|
|
+ shortTermPublicKey,
|
|
|
|
+ goodThreshold,
|
|
|
|
+ fullProof,
|
|
|
|
+ currEncryptedScore);
|
|
cout << "TEST INVALID REPUTATION PROOF: "
|
|
cout << "TEST INVALID REPUTATION PROOF: "
|
|
<< (flag ? "FAILED (Proof verified)" : "PASSED (Proof not verified)" )
|
|
<< (flag ? "FAILED (Proof verified)" : "PASSED (Proof not verified)" )
|
|
<< endl << endl;
|
|
<< endl << endl;
|
|
@@ -220,14 +249,22 @@ void test_vote_proof(
|
|
}
|
|
}
|
|
|
|
|
|
vector<Proof> validVoteProof;
|
|
vector<Proof> validVoteProof;
|
|
- Proof ownerProof;
|
|
|
|
|
|
+
|
|
|
|
+ Proof baseProof;
|
|
|
|
+ vector<Proof> fullProof;
|
|
Curvepoint shortTermPublicKey =
|
|
Curvepoint shortTermPublicKey =
|
|
- user.get_short_term_public_key(ownerProof);
|
|
|
|
|
|
+ user.get_short_term_public_key();
|
|
vector<CurveBipoint> encryptedVotes =
|
|
vector<CurveBipoint> encryptedVotes =
|
|
- servers.get_current_votes_by(ownerProof, shortTermPublicKey);
|
|
|
|
- encryptedVotes =
|
|
|
|
- user.make_votes(
|
|
|
|
- validVoteProof, ownerProof, encryptedVotes, votes, replaces);
|
|
|
|
|
|
+ servers.get_current_votes_by(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_vote_row_commitments(fullProof, shortTermPublicKey);
|
|
|
|
+
|
|
|
|
+ encryptedVotes = user.make_votes(
|
|
|
|
+ validVoteProof,
|
|
|
|
+ fullProof,
|
|
|
|
+ encryptedVotes,
|
|
|
|
+ votes,
|
|
|
|
+ replaces);
|
|
|
|
|
|
flag = servers.receive_vote(
|
|
flag = servers.receive_vote(
|
|
validVoteProof, encryptedVotes, shortTermPublicKey);
|
|
validVoteProof, encryptedVotes, shortTermPublicKey);
|
|
@@ -236,16 +273,20 @@ void test_vote_proof(
|
|
<< endl;
|
|
<< endl;
|
|
|
|
|
|
for (size_t i = 0; i < numUsers; i++)
|
|
for (size_t i = 0; i < numUsers; i++)
|
|
- {
|
|
|
|
replaces[i] = false;
|
|
replaces[i] = false;
|
|
- }
|
|
|
|
|
|
|
|
- shortTermPublicKey = user.get_short_term_public_key(ownerProof);
|
|
|
|
- encryptedVotes =
|
|
|
|
- servers.get_current_votes_by(ownerProof, shortTermPublicKey);
|
|
|
|
|
|
+ baseProof.clear();
|
|
|
|
+ fullProof.clear();
|
|
encryptedVotes =
|
|
encryptedVotes =
|
|
- user.make_votes(
|
|
|
|
- validVoteProof, ownerProof, encryptedVotes, votes, replaces);
|
|
|
|
|
|
+ servers.get_current_votes_by(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_vote_row_commitments(fullProof, shortTermPublicKey);
|
|
|
|
+ encryptedVotes = user.make_votes(
|
|
|
|
+ validVoteProof,
|
|
|
|
+ fullProof,
|
|
|
|
+ encryptedVotes,
|
|
|
|
+ votes,
|
|
|
|
+ replaces);
|
|
|
|
|
|
flag = servers.receive_vote(
|
|
flag = servers.receive_vote(
|
|
validVoteProof, encryptedVotes, shortTermPublicKey);
|
|
validVoteProof, encryptedVotes, shortTermPublicKey);
|
|
@@ -259,12 +300,18 @@ void test_vote_proof(
|
|
replaces[i] = true;
|
|
replaces[i] = true;
|
|
}
|
|
}
|
|
|
|
|
|
- shortTermPublicKey = user.get_short_term_public_key(ownerProof);
|
|
|
|
- encryptedVotes =
|
|
|
|
- servers.get_current_votes_by(ownerProof, shortTermPublicKey);
|
|
|
|
|
|
+ baseProof.clear();
|
|
|
|
+ fullProof.clear();
|
|
encryptedVotes =
|
|
encryptedVotes =
|
|
- user.make_votes(
|
|
|
|
- validVoteProof, ownerProof, encryptedVotes, votes, replaces);
|
|
|
|
|
|
+ servers.get_current_votes_by(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_vote_row_commitments(fullProof, shortTermPublicKey);
|
|
|
|
+ encryptedVotes = user.make_votes(
|
|
|
|
+ validVoteProof,
|
|
|
|
+ fullProof,
|
|
|
|
+ encryptedVotes,
|
|
|
|
+ votes,
|
|
|
|
+ replaces);
|
|
|
|
|
|
flag = servers.receive_vote(
|
|
flag = servers.receive_vote(
|
|
validVoteProof, encryptedVotes, shortTermPublicKey);
|
|
validVoteProof, encryptedVotes, shortTermPublicKey);
|
|
@@ -296,7 +343,7 @@ void check_vote_matrix_updates()
|
|
elGamalBlindGeneratorProof,
|
|
elGamalBlindGeneratorProof,
|
|
elGamalBlindGenerator,
|
|
elGamalBlindGenerator,
|
|
bgnPublicKey,
|
|
bgnPublicKey,
|
|
- &servers);
|
|
|
|
|
|
+ numServers);
|
|
users.push_back(currUser);
|
|
users.push_back(currUser);
|
|
servers.add_new_client(users[i]);
|
|
servers.add_new_client(users[i]);
|
|
}
|
|
}
|
|
@@ -309,9 +356,8 @@ void check_vote_matrix_updates()
|
|
|
|
|
|
for (size_t i = 0; i < numUsers; i++)
|
|
for (size_t i = 0; i < numUsers; i++)
|
|
{
|
|
{
|
|
- Proof ownerProof;
|
|
|
|
Curvepoint shortTermPublicKey =
|
|
Curvepoint shortTermPublicKey =
|
|
- users[i].get_short_term_public_key(ownerProof);
|
|
|
|
|
|
+ users[i].get_short_term_public_key();
|
|
|
|
|
|
size_t myIndex =
|
|
size_t myIndex =
|
|
users[i].binary_search(currentPseudonyms, shortTermPublicKey);
|
|
users[i].binary_search(currentPseudonyms, shortTermPublicKey);
|
|
@@ -331,13 +377,17 @@ void check_vote_matrix_updates()
|
|
replaces.push_back(true);
|
|
replaces.push_back(true);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ Proof baseProof;
|
|
|
|
+ vector<Proof> fullProof;
|
|
vector<CurveBipoint> currEncryptedVotes =
|
|
vector<CurveBipoint> currEncryptedVotes =
|
|
- servers.get_current_votes_by(ownerProof, shortTermPublicKey);
|
|
|
|
|
|
+ servers.get_current_votes_by(baseProof, shortTermPublicKey);
|
|
|
|
+ fullProof.push_back(baseProof);
|
|
|
|
+ servers.get_other_vote_row_commitments(fullProof, shortTermPublicKey);
|
|
|
|
+
|
|
vector<Proof> currVoteProof;
|
|
vector<Proof> currVoteProof;
|
|
-
|
|
|
|
currEncryptedVotes = users[i].make_votes(
|
|
currEncryptedVotes = users[i].make_votes(
|
|
currVoteProof,
|
|
currVoteProof,
|
|
- ownerProof,
|
|
|
|
|
|
+ fullProof,
|
|
currEncryptedVotes,
|
|
currEncryptedVotes,
|
|
votes,
|
|
votes,
|
|
replaces);
|
|
replaces);
|
|
@@ -395,13 +445,28 @@ int main(int argc, char *argv[])
|
|
numRounds = atoi(argv[3]);
|
|
numRounds = atoi(argv[3]);
|
|
if (argc > 4)
|
|
if (argc > 4)
|
|
numVotesPerRound = atoi(argv[4]);
|
|
numVotesPerRound = atoi(argv[4]);
|
|
|
|
+ if (argc > 5)
|
|
|
|
+ {
|
|
|
|
+ bool setting = argv[5][0] == 't' || argv[5][0] == 'T';
|
|
|
|
+ maliciousServers = setting;
|
|
|
|
+ }
|
|
|
|
+ if (argc > 6)
|
|
|
|
+ {
|
|
|
|
+ bool setting = argv[6][0] == 't' || argv[6][0] == 'T';
|
|
|
|
+ maliciousClients = setting;
|
|
|
|
+ }
|
|
|
|
+ if (argc > 7)
|
|
|
|
+ seedStr = argv[7];
|
|
|
|
|
|
cout << "Running the protocol with the following parameters: " << endl;
|
|
cout << "Running the protocol with the following parameters: " << endl;
|
|
cout << numServers << " PRSONA servers" << endl;
|
|
cout << numServers << " PRSONA servers" << endl;
|
|
cout << numUsers << " participants (voters/votees)" << endl;
|
|
cout << numUsers << " participants (voters/votees)" << endl;
|
|
cout << numRounds << " epochs" << endl;
|
|
cout << numRounds << " epochs" << endl;
|
|
- cout << numVotesPerRound << " new (random) votes by each user per epoch"
|
|
|
|
- << endl << endl;
|
|
|
|
|
|
+ cout << numVotesPerRound << " new (random) votes by each user per epoch" << endl;
|
|
|
|
+ cout << "Servers are set to " << (maliciousServers ? "MALICIOUS" : "HBC") << " security" << endl;
|
|
|
|
+ cout << "Clients are set to " << (maliciousClients ? "MALICIOUS" : "HBC") << " security" << endl;
|
|
|
|
+ cout << "Current randomness seed: \"" << seedStr << "\"" << endl;
|
|
|
|
+ cout << endl;
|
|
|
|
|
|
// Set malicious flags where necessary
|
|
// Set malicious flags where necessary
|
|
if (maliciousServers)
|
|
if (maliciousServers)
|
|
@@ -424,7 +489,7 @@ int main(int argc, char *argv[])
|
|
elGamalBlindGeneratorProof,
|
|
elGamalBlindGeneratorProof,
|
|
elGamalBlindGenerator,
|
|
elGamalBlindGenerator,
|
|
bgnPublicKey,
|
|
bgnPublicKey,
|
|
- &servers);
|
|
|
|
|
|
+ numServers);
|
|
users.push_back(currUser);
|
|
users.push_back(currUser);
|
|
servers.add_new_client(users[i]);
|
|
servers.add_new_client(users[i]);
|
|
}
|
|
}
|
|
@@ -479,7 +544,7 @@ int main(int argc, char *argv[])
|
|
while (user_b == user_a)
|
|
while (user_b == user_a)
|
|
user_b = userDistribution(generator);
|
|
user_b = userDistribution(generator);
|
|
|
|
|
|
- test_reputation_proof(generator, users[user_a], users[user_b]);
|
|
|
|
|
|
+ test_reputation_proof(generator, servers, users[user_a], users[user_b]);
|
|
test_vote_proof(generator, users[user_a], servers);
|
|
test_vote_proof(generator, users[user_a], servers);
|
|
|
|
|
|
return 0;
|
|
return 0;
|