serverEntity.hpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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. BGNPublicKey get_bgn_public_key(size_t which) const;
  14. Curvepoint get_blinding_generator() const;
  15. Curvepoint get_blinding_generator(size_t which) const;
  16. Curvepoint get_blinding_generator(std::vector<Proof>& pi) const;
  17. Curvepoint get_blinding_generator(
  18. std::vector<Proof>& pi, size_t which) const;
  19. Curvepoint get_fresh_generator() const;
  20. Curvepoint get_fresh_generator(size_t which) const;
  21. Curvepoint get_fresh_generator(std::vector<Proof>& pi) const;
  22. Curvepoint get_fresh_generator(
  23. std::vector<Proof>& pi, size_t which) const;
  24. size_t get_num_clients() const;
  25. size_t get_num_clients(size_t which) const;
  26. size_t get_num_servers() const;
  27. size_t get_num_servers(size_t which) const;
  28. // ENCRYPTED DATA GETTERS
  29. std::vector<CurveBipoint> get_current_votes_by(
  30. Proof& pi, const Curvepoint& shortTermPublicKey) const;
  31. std::vector<CurveBipoint> get_current_votes_by(
  32. Proof& pi, const Curvepoint& shortTermPublicKey, size_t which) const;
  33. EGCiphertext get_current_tally(
  34. Proof& pi, const Curvepoint& shortTermPublicKey) const;
  35. EGCiphertext get_current_tally(
  36. Proof& pi, const Curvepoint& shortTermPublicKey, size_t which) const;
  37. // CLIENT INTERACTIONS
  38. void add_new_client(PrsonaClient& newUser);
  39. void add_new_client(PrsonaClient& newUser, size_t which);
  40. bool receive_vote(
  41. const std::vector<Proof>& pi,
  42. const std::vector<CurveBipoint>& newVotes,
  43. const Curvepoint& shortTermPublicKey);
  44. bool receive_vote(
  45. const std::vector<Proof>& pi,
  46. const std::vector<CurveBipoint>& newVotes,
  47. const Curvepoint& shortTermPublicKey,
  48. size_t which);
  49. void transmit_updates(PrsonaClient& currUser) const;
  50. void transmit_updates(PrsonaClient& currUser, size_t which) const;
  51. // EPOCH
  52. void epoch(Proof& pi);
  53. void epoch(Proof& pi, size_t which);
  54. private:
  55. std::vector<PrsonaServer> servers;
  56. // SCORE TALLYING
  57. std::vector<EGCiphertext> tally_scores(
  58. std::vector<Proof>& tallyProofs,
  59. const Curvepoint& nextGenerator,
  60. size_t which);
  61. // BINARY SEARCH
  62. size_t binary_search(
  63. const Curvepoint& shortTermPublicKey, size_t which) const;
  64. };
  65. #endif