client.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. #ifndef __PRSONA_CLIENT_HPP
  2. #define __PRSONA_CLIENT_HPP
  3. #include <unordered_map>
  4. #include <vector>
  5. #include "Curvepoint.hpp"
  6. #include "Scalar.hpp"
  7. #include "BGN.hpp"
  8. #include "EGCiphertext.hpp"
  9. #include "proof.hpp"
  10. class PrsonaClient {
  11. public:
  12. PrsonaClient(const BGNPublicKey& serverPublicKey, const Curvepoint& elGamalBlindGenerator);
  13. static void set_malicious_server();
  14. static void set_malicious_client();
  15. Curvepoint get_short_term_public_key(Proof &pi) const;
  16. void make_votes(Proof& pi, std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote, const std::vector<bool>& replace) const;
  17. void receive_fresh_generator(const Proof& pi, const Curvepoint& freshGenerator);
  18. void receive_vote_tally(const Proof& pi, const EGCiphertext& score, bool isDefault);
  19. void receive_encrypted_votes(const Proof& pi, const std::vector<CurveBipoint>& votes, bool isDefault);
  20. Proof generate_reputation_proof() const;
  21. bool verify_reputation_proof(const Proof& pi, const Curvepoint& shortTermPublicKey) const;
  22. private:
  23. static const Curvepoint elGamalGenerator;
  24. static bool malicious_server;
  25. static bool malicious_client;
  26. const BGNPublicKey serverPublicKey;
  27. const Curvepoint elGamalBlindGenerator;
  28. Curvepoint currentFreshGenerator;
  29. EGCiphertext currentEncryptedScore;
  30. Scalar longTermPrivateKey;
  31. Scalar currentScore;
  32. std::vector<CurveBipoint> currEncryptedVotes;
  33. std::unordered_map<Curvepoint, Scalar, CurvepointHash> decryption_memoizer;
  34. Scalar max_checked;
  35. void decrypt_score(const EGCiphertext& score);
  36. Proof generate_stpk_proof() const;
  37. bool verify_generator_proof(const Proof& pi, const Curvepoint& generator) const;
  38. bool verify_default_tally_proof(const Proof& pi, const EGCiphertext& generator) const;
  39. bool verify_valid_tally_proof(const Proof& pi, const EGCiphertext& score) const;
  40. bool verify_default_votes_proof(const Proof& pi, const std::vector<CurveBipoint>& votes) const;
  41. bool verify_valid_votes_proof(const Proof& pi, const std::vector<CurveBipoint>& votes) const;
  42. Proof generate_vote_proof(const std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote) const;
  43. bool verify_score_proof(const Proof& pi) const;
  44. };
  45. #endif