serverEntity.hpp 3.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  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. std::vector<std::vector<CurveBipoint>> get_all_current_votes(
  34. Proof& pi) const;
  35. std::vector<std::vector<CurveBipoint>> get_all_current_votes(
  36. Proof& pi, size_t which) const;
  37. EGCiphertext get_current_user_encrypted_tally(
  38. Proof& pi, const Curvepoint& shortTermPublicKey) const;
  39. EGCiphertext get_current_user_encrypted_tally(
  40. Proof& pi, const Curvepoint& shortTermPublicKey, size_t which) const;
  41. TwistBipoint get_current_server_encrypted_tally(
  42. Proof& pi, const Curvepoint& shortTermPublicKey) const;
  43. TwistBipoint get_current_server_encrypted_tally(
  44. Proof& pi, const Curvepoint& shortTermPublicKey, size_t which) const;
  45. std::vector<Curvepoint> get_current_pseudonyms(
  46. Proof& pi) const;
  47. std::vector<Curvepoint> get_current_pseudonyms(
  48. Proof& pi, size_t which) const;
  49. // CLIENT INTERACTIONS
  50. void add_new_client(PrsonaClient& newUser);
  51. void add_new_client(PrsonaClient& newUser, size_t which);
  52. bool receive_vote(
  53. const std::vector<Proof>& pi,
  54. const std::vector<CurveBipoint>& newVotes,
  55. const Curvepoint& shortTermPublicKey);
  56. bool receive_vote(
  57. const std::vector<Proof>& pi,
  58. const std::vector<CurveBipoint>& newVotes,
  59. const Curvepoint& shortTermPublicKey,
  60. size_t which);
  61. void transmit_new_user_data(
  62. const std::vector<Proof>& pi, PrsonaClient& newUser) const;
  63. void transmit_updates(PrsonaClient& currUser) const;
  64. void transmit_updates(PrsonaClient& currUser, size_t which) const;
  65. // EPOCH
  66. void epoch(Proof& pi);
  67. void epoch(Proof& pi, size_t which);
  68. void print_scores() const;
  69. void print_votes() const;
  70. private:
  71. std::vector<PrsonaServer> servers;
  72. // SCORE TALLYING
  73. std::vector<EGCiphertext> tally_scores(
  74. const Curvepoint& nextGenerator,
  75. size_t which);
  76. // BINARY SEARCH
  77. size_t binary_search(
  78. const Curvepoint& shortTermPublicKey, size_t which) const;
  79. };
  80. #endif