123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- #ifndef __PRSONA_CLIENT_HPP
- #define __PRSONA_CLIENT_HPP
- #include <unordered_map>
- #include <vector>
- #include "Curvepoint.hpp"
- #include "Scalar.hpp"
- #include "BGN.hpp"
- #include "base.hpp"
- #include "EGCiphertext.hpp"
- #include "proof.hpp"
- // Forward declaration to be able to make a pointer to the servers,
- // which is needed in some proofs
- class PrsonaServerEntity;
- class PrsonaClient : public PrsonaBase {
- public:
- // CONSTRUCTORS
- PrsonaClient(
- const std::vector<Proof>& generatorProof,
- const Curvepoint& elGamalBlindGenerator,
- const BGNPublicKey& serverPublicKey,
- const PrsonaServerEntity* servers);
- // BASIC PUBLIC SYSTEM INFO GETTERS
- Curvepoint get_short_term_public_key() const;
- Curvepoint get_short_term_public_key(Proof &pi) const;
- // SERVER INTERACTIONS
- std::vector<CurveBipoint> make_votes(
- std::vector<Proof>& validVoteProof,
- const Proof& serverProof,
- const std::vector<CurveBipoint>& oldEncryptedVotes,
- const std::vector<Scalar>& votes,
- const std::vector<bool>& replaces
- ) const;
- bool receive_fresh_generator(
- const std::vector<Proof>& pi, const Curvepoint& freshGenerator);
- bool receive_vote_tally();
- bool receive_new_user_data(const std::vector<Proof>& pi);
- // REPUTATION PROOFS
- std::vector<Proof> generate_reputation_proof(
- const Scalar& threshold
- ) const;
- bool verify_reputation_proof(
- const std::vector<Proof>& pi,
- const Curvepoint& shortTermPublicKey,
- const Scalar& threshold
- ) const;
- // NEEDED FOR TESTING PROOFS
- Scalar get_score() const;
- private:
- // Constants for clients
- static bool SERVER_IS_MALICIOUS;
- static bool CLIENT_IS_MALICIOUS;
-
- // Things bound to the servers permanently
- const BGNPublicKey serverPublicKey;
- const PrsonaServerEntity *servers;
- // Things bound to the servers (but change regularly)
- Curvepoint currentFreshGenerator;
- // Things bound to this user permanently
- Scalar longTermPrivateKey;
- Scalar inversePrivateKey;
- // Things bound to this user (but change regularly)
- EGCiphertext currentEncryptedScore;
- Scalar currentScore;
- // Things related to making decryption more efficient
- std::unordered_map<Curvepoint, Scalar, CurvepointHash>
- decryption_memoizer;
- Scalar max_checked;
- // SCORE DECRYPTION
- Scalar decrypt_score(const EGCiphertext& score);
- // OWNERSHIP OF STPK PROOFS
- Proof generate_ownership_proof() const;
- // VALID VOTE PROOFS
- std::vector<Proof> generate_vote_proof(
- const std::vector<bool>& replaces,
- const std::vector<CurveBipoint>& oldEncryptedVotes,
- const std::vector<CurveBipoint>& newEncryptedVotes,
- const std::vector<Scalar>& seeds,
- const std::vector<Scalar>& votes
- ) 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
|