123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106 |
- #ifndef __PRSONA_CLIENT_HPP
- #define __PRSONA_CLIENT_HPP
- #include <unordered_map>
- #include <vector>
- #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<CurveBipoint> make_votes(
- Proof& pi,
- const std::vector<Scalar>& vote,
- const std::vector<bool>& 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<CurveBipoint>& votes);
-
- // 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;
- 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<CurveBipoint> currentEncryptedVotes;
- // Things related to making decryption more efficient
- std::unordered_map<Curvepoint, Scalar, CurvepointHash>
- 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<CurveBipoint>& votes) const;
- bool verify_valid_votes_proof(
- const Proof& pi, const std::vector<CurveBipoint>& votes) const;
- // PROOF GENERATION
- Proof generate_vote_proof(
- const std::vector<CurveBipoint>& encryptedVotes,
- const std::vector<Scalar>& vote) const;
- };
- #endif
|