123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- #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"
- class PrsonaClient {
- public:
- PrsonaClient(const BGNPublicKey& serverPublicKey, const Curvepoint& elGamalBlindGenerator);
- static void set_malicious_server();
- static void set_malicious_client();
- Curvepoint get_short_term_public_key(Proof &pi) const;
- void make_votes(Proof& pi, std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote, const std::vector<bool>& replace) const;
- void receive_fresh_generator(const Proof& pi, const Curvepoint& freshGenerator);
- void receive_vote_tally(const Proof& pi, const EGCiphertext& score, bool isDefault);
- void receive_encrypted_votes(const Proof& pi, const std::vector<CurveBipoint>& votes, bool isDefault);
-
- Proof generate_reputation_proof() const;
- bool verify_reputation_proof(const Proof& pi, const Curvepoint& shortTermPublicKey) const;
- private:
- static const Curvepoint elGamalGenerator;
- static bool malicious_server;
- static bool malicious_client;
- const BGNPublicKey serverPublicKey;
- const Curvepoint elGamalBlindGenerator;
-
- Curvepoint currentFreshGenerator;
- EGCiphertext currentEncryptedScore;
- Scalar longTermPrivateKey;
- Scalar currentScore;
- std::vector<CurveBipoint> currEncryptedVotes;
- std::unordered_map<Curvepoint, Scalar, CurvepointHash> decryption_memoizer;
- Scalar max_checked;
- void decrypt_score(const EGCiphertext& score);
- Proof generate_stpk_proof() 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 generate_vote_proof(const std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote) const;
- bool verify_score_proof(const Proof& pi) const;
- };
- #endif
|