Browse Source

Added the server consensus 'proofs'

tristangurtler 3 years ago
parent
commit
813ea4bc56

+ 2 - 0
prsona/inc/EGCiphertext.hpp

@@ -9,6 +9,8 @@ class EGCiphertext {
         Curvepoint encryptedMessage;
 
         bool operator==(const EGCiphertext& other) const;
+        friend std::ostream& operator<<(std::ostream& os, const EGCiphertext& output);
+        friend std::istream& operator>>(std::istream& is, EGCiphertext& input);
 };
 
 #endif

+ 30 - 11
prsona/inc/base.hpp

@@ -158,18 +158,37 @@ class PrsonaBase {
         bool verify_update_proof(const Proof& pi) const;
 
         // SERVER AGREEMENT PROOFS
-        Proof generate_valid_user_tally_proof() const;
-        Proof generate_valid_server_tally_proof() const;
-        Proof generate_valid_vote_row_proof() const;
-        Proof generate_valid_vote_matrix_proof() const;
-        Proof generate_valid_pseudonyms_proof() const;
+        Proof generate_valid_vote_row_proof(
+            const std::vector<CurveBipoint>& commitment) const;
+        Proof generate_valid_vote_matrix_proof(
+            const std::vector<std::vector<CurveBipoint>>& commitment) const;
+        Proof generate_valid_user_tally_proof(
+            const EGCiphertext& commitment) const;
+        Proof generate_valid_server_tally_proof(
+            const TwistBipoint& commitment) const;
+        Proof generate_valid_pseudonyms_proof(
+            const std::vector<Curvepoint>& commitment) const;
         
-        bool verify_valid_user_tally_proof(const Proof& pi) const;
-        bool verify_valid_server_tally_proof(const Proof& pi) const;
-        bool verify_valid_vote_row_proof(const Proof& pi) const;
-        bool verify_valid_vote_matrix_proof(const Proof& pi) const;
-        bool verify_valid_pseudonyms_proof(const Proof& pi) const;
-
+        bool verify_valid_vote_row_proof(
+            const std::vector<Proof>& pi,
+            const std::vector<CurveBipoint>& commitment
+        ) const;
+        bool verify_valid_vote_matrix_proof(
+            const std::vector<Proof>& pi,
+            const std::vector<std::vector<CurveBipoint>>& commitment
+        ) const;
+        bool verify_valid_user_tally_proof(
+            const std::vector<Proof>& pi,
+            const EGCiphertext& commitment
+        ) const;
+        bool verify_valid_server_tally_proof(
+            const std::vector<Proof>& pi,
+            const TwistBipoint& commitment
+        ) const;
+        bool verify_valid_pseudonyms_proof(
+            const std::vector<Proof>& pi,
+            const std::vector<Curvepoint>& commitment
+        ) const;
 };
 
 #endif

+ 26 - 2
prsona/inc/client.hpp

@@ -27,7 +27,6 @@ class PrsonaClient : public PrsonaBase {
 
         // BASIC PUBLIC SYSTEM INFO GETTERS
         Curvepoint get_short_term_public_key() const;
-        Curvepoint get_short_term_public_key(bool unused) const;
         Curvepoint get_short_term_public_key(Proof &pi) const;
 
         // SERVER INTERACTIONS
@@ -94,7 +93,32 @@ class PrsonaClient : public PrsonaBase {
             const std::vector<CurveBipoint>& newEncryptedVotes,
             const std::vector<Scalar>& seeds,
             const std::vector<Scalar>& votes
-        ) const;        
+        ) const;     
+
+        // SERVER AGREEMENT PROOFS
+        bool verify_valid_vote_row_proof(
+            const Proof& pi,
+            const Curvepoint& shortTermPublicKey,
+            const std::vector<CurveBipoint>& commitment
+        ) const;
+        bool verify_valid_vote_matrix_proof(
+            const Proof& pi,
+            const std::vector<std::vector<CurveBipoint>>& commitment
+        ) const;
+        bool verify_valid_user_tally_proof(
+            const Proof& pi,
+            const Curvepoint& shortTermPublicKey,
+            const EGCiphertext& commitment
+        ) const;
+        bool verify_valid_server_tally_proof(
+            const Proof& pi,
+            const Curvepoint& shortTermPublicKey,
+            const TwistBipoint& commitment
+        ) const;
+        bool verify_valid_pseudonyms_proof(
+            const Proof& pi,
+            const std::vector<Curvepoint>& commitment
+        ) const;
 }; 
 
 #endif

+ 7 - 0
prsona/inc/server.hpp

@@ -41,6 +41,13 @@ class PrsonaServer : public PrsonaBase {
             Proof& pi, const Curvepoint& shortTermPublicKey) const;
         std::vector<Curvepoint> get_current_pseudonyms(Proof& pi) const;
 
+        // PROOF COMMITMENT GETTERS
+        Proof get_vote_row_commitment(const Curvepoint& request) const;
+        Proof get_vote_matrix_commitment() const;
+        Proof get_user_tally_commitment(const Curvepoint& request) const;
+        Proof get_server_tally_commitment(const Curvepoint& request) const;
+        Proof get_pseudonyms_commitment() const;
+
         // CLIENT INTERACTIONS
         void add_new_client(
             std::vector<Proof>& proofOfValidAddition,

+ 31 - 0
prsona/inc/serverEntity.hpp

@@ -52,6 +52,37 @@ class PrsonaServerEntity {
         std::vector<Curvepoint> get_current_pseudonyms(
             Proof& pi, size_t which) const;
 
+        // PROOF COMMITMENT GETTERS
+        void get_other_vote_row_commitments(
+            std::vector<Proof>& pi, const Curvepoint& request) const;
+        void get_other_vote_row_commitments(
+            std::vector<Proof>& pi,
+            const Curvepoint& request,
+            size_t whichNot
+        ) const;
+        void get_other_vote_matrix_commitments(
+            std::vector<Proof>& pi) const;
+        void get_other_vote_matrix_commitments(
+            std::vector<Proof>& pi, size_t whichNot) const;
+        void get_other_user_tally_commitments(
+            std::vector<Proof>& pi, const Curvepoint& request) const;
+        void get_other_user_tally_commitments(
+            std::vector<Proof>& pi,
+            const Curvepoint& request,
+            size_t whichNot
+        ) const;
+        void get_other_server_tally_commitments(
+            std::vector<Proof>& pi, const Curvepoint& request) const;
+        void get_other_server_tally_commitments(
+            std::vector<Proof>& pi,
+            const Curvepoint& request,
+            size_t whichNot)
+        const;
+        void get_other_pseudonyms_commitments(
+            std::vector<Proof>& pi) const;
+        void get_other_pseudonyms_commitments(
+            std::vector<Proof>& pi, size_t whichNot) const;
+
         // CLIENT INTERACTIONS
         void add_new_client(PrsonaClient& newUser);
         void add_new_client(PrsonaClient& newUser, size_t which);

+ 14 - 0
prsona/src/EGCiphertext.cpp

@@ -4,3 +4,17 @@ bool EGCiphertext::operator==(const EGCiphertext& other) const
 {
     return mask == other.mask && encryptedMessage == other.encryptedMessage;
 }
+
+std::ostream& operator<<(std::ostream& os, const EGCiphertext& output)
+{
+    os << output.mask << output.encryptedMessage;
+
+    return os;
+}
+
+std::istream& operator>>(std::istream& is, EGCiphertext& input)
+{
+    is >> input.mask >> input.encryptedMessage;
+
+    return is;
+}

+ 168 - 25
prsona/src/base.cpp

@@ -862,7 +862,8 @@ bool PrsonaBase::verify_update_proof(
  * SERVER AGREEMENT PROOFS
  */
 
-Proof PrsonaBase::generate_valid_user_tally_proof() const
+Proof PrsonaBase::generate_valid_vote_row_proof(
+    const std::vector<CurveBipoint>& commitment) const
 {
     Proof retval;
 
@@ -872,11 +873,18 @@ Proof PrsonaBase::generate_valid_user_tally_proof() const
         return retval;
     }
 
-    retval.hbc = "PROOF";
+    std::stringstream oracleInput;
+    for (size_t i = 0; i < commitment.size(); i++)
+        oracleInput << commitment[i];
+
+    Scalar val = oracle(oracleInput.str());
+
+    retval.responseParts.push_back(val);
     return retval;
 }
 
-Proof PrsonaBase::generate_valid_server_tally_proof() const
+Proof PrsonaBase::generate_valid_vote_matrix_proof(
+    const std::vector<std::vector<CurveBipoint>>& commitment) const
 {
     Proof retval;
 
@@ -886,11 +894,19 @@ Proof PrsonaBase::generate_valid_server_tally_proof() const
         return retval;
     }
 
-    retval.hbc = "PROOF";
+    std::stringstream oracleInput;
+    for (size_t i = 0; i < commitment.size(); i++)
+        for (size_t j = 0; j < commitment[i].size(); j++)
+            oracleInput << commitment[i][j];
+
+    Scalar val = oracle(oracleInput.str());
+
+    retval.responseParts.push_back(val);
     return retval;
 }
 
-Proof PrsonaBase::generate_valid_vote_row_proof() const
+Proof PrsonaBase::generate_valid_user_tally_proof(
+    const EGCiphertext& commitment) const
 {
     Proof retval;
 
@@ -900,11 +916,17 @@ Proof PrsonaBase::generate_valid_vote_row_proof() const
         return retval;
     }
 
-    retval.hbc = "PROOF";
+    std::stringstream oracleInput;
+    oracleInput << commitment;
+
+    Scalar val = oracle(oracleInput.str());
+
+    retval.responseParts.push_back(val);
     return retval;
 }
 
-Proof PrsonaBase::generate_valid_vote_matrix_proof() const
+Proof PrsonaBase::generate_valid_server_tally_proof(
+    const TwistBipoint& commitment) const
 {
     Proof retval;
 
@@ -914,11 +936,17 @@ Proof PrsonaBase::generate_valid_vote_matrix_proof() const
         return retval;
     }
 
-    retval.hbc = "PROOF";
+    std::stringstream oracleInput;
+    oracleInput << commitment;
+
+    Scalar val = oracle(oracleInput.str());
+
+    retval.responseParts.push_back(val);
     return retval;
 }
 
-Proof PrsonaBase::generate_valid_pseudonyms_proof() const
+Proof PrsonaBase::generate_valid_pseudonyms_proof(
+    const std::vector<Curvepoint>& commitment) const
 {
     Proof retval;
 
@@ -928,46 +956,161 @@ Proof PrsonaBase::generate_valid_pseudonyms_proof() const
         return retval;
     }
 
-    retval.hbc = "PROOF";
+    std::stringstream oracleInput;
+    for (size_t i = 0; i < commitment.size(); i++)
+        oracleInput << commitment[i];
+
+    Scalar val = oracle(oracleInput.str());
+
+    retval.responseParts.push_back(val);
     return retval;
 }
 
-bool PrsonaBase::verify_valid_user_tally_proof(const Proof& pi) const
+bool PrsonaBase::verify_valid_vote_row_proof(
+    const std::vector<Proof>& pi,
+    const std::vector<CurveBipoint>& commitment) const
 {
+    if (pi.empty())
+        return false;
+
     if (!SERVER_IS_MALICIOUS)
-        return pi.hbc == "PROOF";
+        return pi[0].hbc == "PROOF";
 
-    return pi.hbc == "PROOF";
+    Scalar comparison = pi[0].responseParts[0];
+
+    std::stringstream oracleInput;
+    for (size_t i = 0; i < commitment.size(); i++)
+        oracleInput << commitment[i];
+
+    if (oracle(oracleInput.str()) != comparison)
+    {
+        std::cerr << "Server's claimed value doesn't match their own commitment." << std::endl;
+        return false;
+    }
+
+    size_t agreement = 1;
+    for (size_t i = 1; i < pi.size(); i++)
+        if (comparison == pi[i].responseParts[0])
+            agreement++;
+
+    return agreement * 2 > pi.size();
 }
 
-bool PrsonaBase::verify_valid_server_tally_proof(const Proof& pi) const
+bool PrsonaBase::verify_valid_vote_matrix_proof(
+    const std::vector<Proof>& pi,
+    const std::vector<std::vector<CurveBipoint>>& commitment) const
 {
+    if (pi.empty())
+        return false;
+
     if (!SERVER_IS_MALICIOUS)
-        return pi.hbc == "PROOF";
+        return pi[0].hbc == "PROOF";
 
-    return pi.hbc == "PROOF";
+    Scalar comparison = pi[0].responseParts[0];
+
+    std::stringstream oracleInput;
+    for (size_t i = 0; i < commitment.size(); i++)
+        for (size_t j = 0; j < commitment[i].size(); j++)
+            oracleInput << commitment[i][j];
+
+    if (oracle(oracleInput.str()) != comparison)
+    {
+        std::cerr << "Server's claimed value doesn't match their own commitment." << std::endl;
+        return false;
+    }
+
+    size_t agreement = 1;
+    for (size_t i = 1; i < pi.size(); i++)
+        if (comparison == pi[i].responseParts[0])
+            agreement++;
+
+    return agreement * 2 > pi.size();
 }
 
-bool PrsonaBase::verify_valid_vote_row_proof(const Proof& pi) const
+bool PrsonaBase::verify_valid_user_tally_proof(
+    const std::vector<Proof>& pi,
+    const EGCiphertext& commitment) const
 {
+    if (pi.empty())
+        return false;
+
     if (!SERVER_IS_MALICIOUS)
-        return pi.hbc == "PROOF";
+        return pi[0].hbc == "PROOF";
 
-    return pi.hbc == "PROOF";
+    Scalar comparison = pi[0].responseParts[0];
+
+    std::stringstream oracleInput;
+    oracleInput << commitment;
+
+    if (oracle(oracleInput.str()) != comparison)
+    {
+        std::cerr << "Server's claimed value doesn't match their own commitment." << std::endl;
+        return false;
+    }
+
+    size_t agreement = 1;
+    for (size_t i = 1; i < pi.size(); i++)
+        if (comparison == pi[i].responseParts[0])
+            agreement++;
+
+    return agreement * 2 > pi.size();
 }
 
-bool PrsonaBase::verify_valid_vote_matrix_proof(const Proof& pi) const
+bool PrsonaBase::verify_valid_server_tally_proof(
+    const std::vector<Proof>& pi,
+    const TwistBipoint& commitment) const
 {
+    if (pi.empty())
+        return false;
+
     if (!SERVER_IS_MALICIOUS)
-        return pi.hbc == "PROOF";
+        return pi[0].hbc == "PROOF";
 
-    return pi.hbc == "PROOF";
+    Scalar comparison = pi[0].responseParts[0];
+
+    std::stringstream oracleInput;
+    oracleInput << commitment;
+
+    if (oracle(oracleInput.str()) != comparison)
+    {
+        std::cerr << "Server's claimed value doesn't match their own commitment." << std::endl;
+        return false;
+    }
+
+    size_t agreement = 1;
+    for (size_t i = 1; i < pi.size(); i++)
+        if (comparison == pi[i].responseParts[0])
+            agreement++;
+
+    return agreement * 2 > pi.size();
 }
 
-bool PrsonaBase::verify_valid_pseudonyms_proof(const Proof& pi) const
+bool PrsonaBase::verify_valid_pseudonyms_proof(
+    const std::vector<Proof>& pi,
+    const std::vector<Curvepoint>& commitment) const
 {
+    if (pi.empty())
+        return false;
+
     if (!SERVER_IS_MALICIOUS)
-        return pi.hbc == "PROOF";
+        return pi[0].hbc == "PROOF";
 
-    return pi.hbc == "PROOF";
+    Scalar comparison = pi[0].responseParts[0];
+
+    std::stringstream oracleInput;
+    for (size_t i = 0; i < commitment.size(); i++)
+        oracleInput << commitment[i];
+
+    if (oracle(oracleInput.str()) != comparison)
+    {
+        std::cerr << "Server's claimed value doesn't match their own commitment." << std::endl;
+        return false;
+    }
+
+    size_t agreement = 1;
+    for (size_t i = 1; i < pi.size(); i++)
+        if (comparison == pi[i].responseParts[0])
+            agreement++;
+
+    return agreement * 2 > pi.size();
 }

+ 86 - 26
prsona/src/client.cpp

@@ -38,15 +38,6 @@ Curvepoint PrsonaClient::get_short_term_public_key() const
     return currentFreshGenerator * longTermPrivateKey;
 }
 
-Curvepoint PrsonaClient::get_short_term_public_key(bool unused) const
-{
-    std::cout << "g^r: " << std::hex << currentFreshGenerator << std::dec << std::endl;
-    std::cout << "ltsk: " << longTermPrivateKey << std::endl;
-    std::cout << "stpk: " << std::hex << currentFreshGenerator * longTermPrivateKey << std::dec << std::endl;
-
-    return currentFreshGenerator * longTermPrivateKey;
-}
-
 Curvepoint PrsonaClient::get_short_term_public_key(Proof &pi) const
 {
     pi = generate_ownership_proof();
@@ -69,15 +60,17 @@ std::vector<CurveBipoint> PrsonaClient::make_votes(
     const std::vector<Scalar>& votes,
     const std::vector<bool>& replaces) const
 {
-    std::vector<Scalar> seeds(oldEncryptedVotes.size());
-    std::vector<CurveBipoint> newEncryptedVotes(oldEncryptedVotes.size());
+    Curvepoint shortTermPublicKey = get_short_term_public_key();
 
-    if (!verify_valid_vote_row_proof(serverProof))
+    if (!verify_valid_vote_row_proof(serverProof, shortTermPublicKey, oldEncryptedVotes))
     {
         std::cerr << "Could not verify proof of valid votes." << std::endl;
-        return newEncryptedVotes;
+        return oldEncryptedVotes;
     }
 
+    std::vector<Scalar> seeds(oldEncryptedVotes.size());
+    std::vector<CurveBipoint> newEncryptedVotes(oldEncryptedVotes.size());
+
     for (size_t i = 0; i < votes.size(); i++)
     {
         if (replaces[i])
@@ -119,7 +112,7 @@ bool PrsonaClient::receive_vote_tally()
     EGCiphertext score =
         servers->get_current_user_encrypted_tally(pi, shortTermPublicKey);
 
-    if (!verify_valid_user_tally_proof(pi))
+    if (!verify_valid_user_tally_proof(pi, shortTermPublicKey, score))
     {
         std::cerr << "Could not verify proof of valid tally." << std::endl;
         return false;
@@ -134,26 +127,26 @@ bool PrsonaClient::receive_new_user_data(const std::vector<Proof>& mainProof)
 {
     Proof currProof;
     Curvepoint shortTermPublicKey = get_short_term_public_key();
-    
-    EGCiphertext userEncryptedScore =
-        servers->get_current_user_encrypted_tally(currProof, shortTermPublicKey);
-    if (!verify_valid_user_tally_proof(currProof))
-    {
-        std::cerr << "Could not verify preliminary proof of user encrypted tally." << std::endl;
-        return false;
-    }
 
     TwistBipoint serverEncryptedScore =
         servers->get_current_server_encrypted_tally(currProof, shortTermPublicKey);
-    if (!verify_valid_server_tally_proof(currProof))
+    if (!verify_valid_server_tally_proof(currProof, shortTermPublicKey, serverEncryptedScore))
     {
         std::cerr << "Could not verify preliminary proof of server encrypted tally." << std::endl;
         return false;
     }
 
+    EGCiphertext userEncryptedScore =
+        servers->get_current_user_encrypted_tally(currProof, shortTermPublicKey);
+    if (!verify_valid_user_tally_proof(currProof, shortTermPublicKey, userEncryptedScore))
+    {
+        std::cerr << "Could not verify preliminary proof of user encrypted tally." << std::endl;
+        return false;
+    }
+
     std::vector<std::vector<CurveBipoint>> encryptedVoteMatrix = 
         servers->get_all_current_votes(currProof);
-    if (!verify_valid_vote_matrix_proof(currProof))
+    if (!verify_valid_vote_matrix_proof(currProof, encryptedVoteMatrix))
     {
         std::cerr << "Could not verify preliminary proof of encrypted votes." << std::endl;
         return false;
@@ -161,7 +154,7 @@ bool PrsonaClient::receive_new_user_data(const std::vector<Proof>& mainProof)
 
     std::vector<Curvepoint> currentPseudonyms = 
         servers->get_current_pseudonyms(currProof);
-    if (!verify_valid_pseudonyms_proof(currProof))
+    if (!verify_valid_pseudonyms_proof(currProof, currentPseudonyms))
     {
         std::cerr << "Could not verify preliminary proof of pseudonyms." << std::endl;
         return false;
@@ -230,7 +223,7 @@ bool PrsonaClient::verify_reputation_proof(
     EGCiphertext encryptedScore =
         servers->get_current_user_encrypted_tally(serverProof, shortTermPublicKey);
 
-    if (!verify_valid_user_tally_proof(serverProof))
+    if (!verify_valid_user_tally_proof(serverProof, shortTermPublicKey, encryptedScore))
     {
         std::cerr << "Error getting score from server, aborting." << std::endl;
         return false;
@@ -319,3 +312,70 @@ std::vector<Proof> PrsonaClient::generate_vote_proof(
         seeds,
         votes);
 }
+
+/*
+ * SERVER AGREEMENT PROOFS
+ */
+
+bool PrsonaClient::verify_valid_vote_row_proof(
+    const Proof& pi,
+    const Curvepoint& shortTermPublicKey,
+    const std::vector<CurveBipoint>& commitment) const
+{
+    std::vector<Proof> fullProof;
+    fullProof.push_back(pi);
+
+    servers->get_other_vote_row_commitments(fullProof, shortTermPublicKey);
+
+    return PrsonaBase::verify_valid_vote_row_proof(fullProof, commitment);
+}
+
+bool PrsonaClient::verify_valid_vote_matrix_proof(
+    const Proof& pi,
+    const std::vector<std::vector<CurveBipoint>>& commitment) const
+{
+    std::vector<Proof> fullProof;
+    fullProof.push_back(pi);
+
+    servers->get_other_vote_matrix_commitments(fullProof);
+
+    return PrsonaBase::verify_valid_vote_matrix_proof(fullProof, commitment);
+}
+
+bool PrsonaClient::verify_valid_user_tally_proof(
+    const Proof& pi,
+    const Curvepoint& shortTermPublicKey,
+    const EGCiphertext& commitment) const
+{
+    std::vector<Proof> fullProof;
+    fullProof.push_back(pi);
+
+    servers->get_other_user_tally_commitments(fullProof, shortTermPublicKey);
+
+    return PrsonaBase::verify_valid_user_tally_proof(fullProof, commitment);
+}
+
+bool PrsonaClient::verify_valid_server_tally_proof(
+    const Proof& pi,
+    const Curvepoint& shortTermPublicKey,
+    const TwistBipoint& commitment) const
+{
+    std::vector<Proof> fullProof;
+    fullProof.push_back(pi);
+
+    servers->get_other_server_tally_commitments(fullProof, shortTermPublicKey);
+
+    return PrsonaBase::verify_valid_server_tally_proof(fullProof, commitment);
+}
+
+bool PrsonaClient::verify_valid_pseudonyms_proof(
+    const Proof& pi,
+    const std::vector<Curvepoint>& commitment) const
+{
+    std::vector<Proof> fullProof;
+    fullProof.push_back(pi);
+
+    servers->get_other_pseudonyms_commitments(fullProof);
+
+    return PrsonaBase::verify_valid_pseudonyms_proof(fullProof, commitment);
+}

+ 37 - 14
prsona/src/server.cpp

@@ -84,23 +84,14 @@ std::vector<CurveBipoint> PrsonaServer::get_current_votes_by(
     size_t voteSubmitter = binary_search(shortTermPublicKey);
     retval = voteMatrix[voteSubmitter];
 
-    // if (currentPseudonyms[voteSubmitter] != shortTermPublicKey)
-    // {
-    //     std::cout << "Query user: " << std::hex
-    //         << shortTermPublicKey << std::dec << std::endl;
-    //     for (size_t i = 0; i < currentPseudonyms.size(); i++)
-    //         std::cout << "User " << i + 1 << " of " << currentPseudonyms.size()
-    //             << ": " << std::hex << currentPseudonyms[i] << std::dec << std::endl;
-    // }
-
-    pi = generate_valid_vote_row_proof();
+    pi = generate_valid_vote_row_proof(retval);
     return retval;
 }
 
 std::vector<std::vector<CurveBipoint>> PrsonaServer::get_all_current_votes(
     Proof& pi) const
 {
-    pi = generate_valid_vote_matrix_proof();
+    pi = generate_valid_vote_matrix_proof(voteMatrix);
     return voteMatrix;
 }
 
@@ -115,7 +106,7 @@ EGCiphertext PrsonaServer::get_current_user_encrypted_tally(
     size_t tallyOwner = binary_search(shortTermPublicKey);
     retval = currentUserEncryptedTallies[tallyOwner];
     
-    pi = generate_valid_user_tally_proof();
+    pi = generate_valid_user_tally_proof(retval);
     return retval;
 }
 
@@ -126,16 +117,48 @@ TwistBipoint PrsonaServer::get_current_server_encrypted_tally(
     size_t tallyOwner = binary_search(shortTermPublicKey);
     retval = previousVoteTallies[tallyOwner];
     
-    pi = generate_valid_server_tally_proof();
+    pi = generate_valid_server_tally_proof(retval);
     return retval;
 }
 
 std::vector<Curvepoint> PrsonaServer::get_current_pseudonyms(Proof& pi) const
 {    
-    pi = generate_valid_pseudonyms_proof();
+    pi = generate_valid_pseudonyms_proof(currentPseudonyms);
     return currentPseudonyms;
 }
 
+/*
+ * PROOF COMMITMENT GETTERS
+ */
+
+Proof PrsonaServer::get_vote_row_commitment(const Curvepoint& request) const
+{
+    size_t requestID = binary_search(request);
+    return generate_valid_vote_row_proof(voteMatrix[requestID]);
+}
+
+Proof PrsonaServer::get_vote_matrix_commitment() const
+{
+    return generate_valid_vote_matrix_proof(voteMatrix);
+}
+
+Proof PrsonaServer::get_user_tally_commitment(const Curvepoint& request) const
+{
+    size_t requestID = binary_search(request);
+    return generate_valid_user_tally_proof(currentUserEncryptedTallies[requestID]);
+}
+
+Proof PrsonaServer::get_server_tally_commitment(const Curvepoint& request) const
+{
+    size_t requestID = binary_search(request);
+    return generate_valid_server_tally_proof(previousVoteTallies[requestID]);
+}
+
+Proof PrsonaServer::get_pseudonyms_commitment() const
+{
+    return generate_valid_pseudonyms_proof(currentPseudonyms);
+}
+
 /*
  * CLIENT INTERACTIONS
  */

+ 94 - 0
prsona/src/serverEntity.cpp

@@ -225,6 +225,100 @@ std::vector<Curvepoint> PrsonaServerEntity::get_current_pseudonyms(
     return servers[which].get_current_pseudonyms(pi);
 }
 
+/*
+ * PROOF COMMITMENT GETTERS
+ */
+
+void PrsonaServerEntity::get_other_vote_row_commitments(
+    std::vector<Proof>& pi, const Curvepoint& request) const
+{
+    get_other_vote_row_commitments(pi, request, 0);
+}
+
+void PrsonaServerEntity::get_other_vote_row_commitments(
+    std::vector<Proof>& pi, const Curvepoint& request, size_t whichNot) const
+{
+    for (size_t i = 0; i < servers.size(); i++)
+    {
+        if (i == whichNot)
+            continue;
+
+        pi.push_back(servers[i].get_vote_row_commitment(request));
+    }
+}
+
+void PrsonaServerEntity::get_other_vote_matrix_commitments(
+    std::vector<Proof>& pi) const
+{
+    get_other_vote_matrix_commitments(pi, 0);
+}
+
+void PrsonaServerEntity::get_other_vote_matrix_commitments(
+    std::vector<Proof>& pi, size_t whichNot) const
+{
+    for (size_t i = 0; i < servers.size(); i++)
+    {
+        if (i == whichNot)
+            continue;
+
+        pi.push_back(servers[i].get_vote_matrix_commitment());
+    }
+}
+
+void PrsonaServerEntity::get_other_user_tally_commitments(
+    std::vector<Proof>& pi, const Curvepoint& request) const
+{
+    get_other_user_tally_commitments(pi, request, 0);
+}
+
+void PrsonaServerEntity::get_other_user_tally_commitments(
+    std::vector<Proof>& pi, const Curvepoint& request, size_t whichNot) const
+{
+    for (size_t i = 0; i < servers.size(); i++)
+    {
+        if (i == whichNot)
+            continue;
+
+        pi.push_back(servers[i].get_user_tally_commitment(request));
+    }
+}
+
+void PrsonaServerEntity::get_other_server_tally_commitments(
+    std::vector<Proof>& pi, const Curvepoint& request) const
+{
+    get_other_server_tally_commitments(pi, request, 0);
+}
+
+void PrsonaServerEntity::get_other_server_tally_commitments(
+    std::vector<Proof>& pi, const Curvepoint& request, size_t whichNot) const
+{
+    for (size_t i = 0; i < servers.size(); i++)
+    {
+        if (i == whichNot)
+            continue;
+
+        pi.push_back(servers[i].get_server_tally_commitment(request));
+    }
+}
+
+void PrsonaServerEntity::get_other_pseudonyms_commitments(
+    std::vector<Proof>& pi) const
+{
+    get_other_pseudonyms_commitments(pi, 0);
+}
+
+void PrsonaServerEntity::get_other_pseudonyms_commitments(
+    std::vector<Proof>& pi, size_t whichNot) const
+{
+    for (size_t i = 0; i < servers.size(); i++)
+    {
+        if (i == whichNot)
+            continue;
+
+        pi.push_back(servers[i].get_pseudonyms_commitment());
+    }
+}
+
 /*
  * CLIENT INTERACTIONS
  */