client.hpp 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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 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 inversePrivateKey;
  32. Scalar currentScore;
  33. std::vector<CurveBipoint> currEncryptedVotes;
  34. std::unordered_map<Curvepoint, Scalar, CurvepointHash> decryption_memoizer;
  35. Scalar max_checked;
  36. void decrypt_score(const EGCiphertext& score);
  37. Proof generate_stpk_proof() const;
  38. bool verify_generator_proof(const Proof& pi, const Curvepoint& generator) const;
  39. bool verify_default_tally_proof(const Proof& pi, const EGCiphertext& generator) const;
  40. bool verify_valid_tally_proof(const Proof& pi, const EGCiphertext& score) const;
  41. bool verify_default_votes_proof(const Proof& pi, const std::vector<CurveBipoint>& votes) const;
  42. bool verify_valid_votes_proof(const Proof& pi, const std::vector<CurveBipoint>& votes) const;
  43. Proof generate_vote_proof(const std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote) const;
  44. bool verify_score_proof(const Proof& pi) const;
  45. };
  46. #endif