#ifndef __PRSONA_CLIENT_HPP #define __PRSONA_CLIENT_HPP #include #include #include "Curvepoint.hpp" #include "Scalar.hpp" #include "BGN.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: // CONSTRUCTORS PrsonaClient( const BGNPublicKey& serverPublicKey, const PrsonaServerEntity *servers); // SETUP FUNCTIONS static void init(const Curvepoint& elGamalBlindGenerator); static void set_server_malicious(); static void set_client_malicious(); // BASIC PUBLIC SYSTEM INFO GETTERS Curvepoint get_short_term_public_key(Proof &pi) const; // SERVER INTERACTIONS std::vector make_votes( Proof& pi, const std::vector& vote, const std::vector& replace); void receive_fresh_generator(const Curvepoint& freshGenerator); void receive_vote_tally(const Proof& pi, const EGCiphertext& score); void receive_encrypted_votes( const Proof& pi, const std::vector& votes); // REPUTATION PROOFS std::vector generate_reputation_proof( const Scalar& threshold) const; bool verify_reputation_proof( const std::vector& pi, const Curvepoint& shortTermPublicKey, const Scalar& threshold) const; private: // Constants for clients static Curvepoint EL_GAMAL_GENERATOR; static Curvepoint EL_GAMAL_BLIND_GENERATOR; 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; std::vector currentEncryptedVotes; // Things related to making decryption more efficient std::unordered_map decryption_memoizer; Scalar max_checked; // SCORE DECRYPTION void decrypt_score(const EGCiphertext& score); // OWNERSHIP OF STPK PROOFS Proof generate_ownership_proof() const; bool verify_ownership_proof( const Proof& pi, const Curvepoint& shortTermPublicKey) const; // PROOF VERIFICATION bool verify_score_proof(const Proof& pi) const; bool verify_generator_proof( const Proof& pi, const Curvepoint& generator) const; bool verify_default_tally_proof( const Proof& pi, const EGCiphertext& generator) const; bool verify_valid_tally_proof( const Proof& pi, const EGCiphertext& score) const; bool verify_default_votes_proof( const Proof& pi, const std::vector& votes) const; bool verify_valid_votes_proof( const Proof& pi, const std::vector& votes) const; // PROOF GENERATION Proof generate_vote_proof( const std::vector& encryptedVotes, const std::vector& vote) const; }; #endif