serverEntity.hpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #ifndef __PRSONA_SERVER_ENTITY_HPP
  2. #define __PRSONA_SERVER_ENTITY_HPP
  3. #include <vector>
  4. #include "client.hpp"
  5. #include "server.hpp"
  6. #include "proof.hpp"
  7. class PrsonaServerEntity {
  8. public:
  9. // CONSTRUCTORS
  10. PrsonaServerEntity(size_t numServers);
  11. // BASIC PUBLIC SYSTEM INFO GETTERS
  12. BGNPublicKey get_bgn_public_key() const;
  13. Curvepoint get_blinding_generator() const;
  14. Curvepoint get_fresh_generator() const;
  15. size_t get_num_clients() const;
  16. size_t get_num_servers() const;
  17. // ENCRYPTED DATA GETTERS
  18. std::vector<CurveBipoint> get_current_votes_by(
  19. Proof& pi, const Curvepoint& shortTermPublicKey) const;
  20. EGCiphertext get_current_tally(
  21. Proof& pi, const Curvepoint& shortTermPublicKey) const;
  22. // CLIENT INTERACTIONS
  23. void add_new_client(PrsonaClient& newUser);
  24. bool receive_vote(
  25. const std::vector<Proof>& pi,
  26. const std::vector<CurveBipoint>& newVotes,
  27. const Curvepoint& shortTermPublicKey);
  28. bool receive_vote(
  29. const std::vector<Proof>& pi,
  30. const std::vector<CurveBipoint>& newVotes,
  31. const Curvepoint& shortTermPublicKey,
  32. size_t which);
  33. void transmit_updates(PrsonaClient& currUser) const;
  34. // EPOCH
  35. void epoch(Proof& pi);
  36. private:
  37. std::vector<PrsonaServer> servers;
  38. // SCORE TALLYING
  39. std::vector<EGCiphertext> tally_scores(
  40. std::vector<Proof>& tallyProofs, const Curvepoint& nextGenerator);
  41. // BINARY SEARCH
  42. size_t binary_search(const Curvepoint& index) const;
  43. };
  44. #endif