serverEntity.hpp 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. Twistpoint get_blinding_generator() const;
  15. Twistpoint get_blinding_generator(size_t which) const;
  16. Twistpoint get_blinding_generator(std::vector<Proof>& pi) const;
  17. Twistpoint get_blinding_generator(
  18. std::vector<Proof>& pi, size_t which) const;
  19. Twistpoint get_fresh_generator() const;
  20. Twistpoint get_fresh_generator(size_t which) const;
  21. Twistpoint get_fresh_generator(std::vector<Proof>& pi) const;
  22. Twistpoint 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<TwistBipoint> get_current_votes_by(
  30. Proof& pi, const Twistpoint& shortTermPublicKey) const;
  31. std::vector<TwistBipoint> get_current_votes_by(
  32. Proof& pi, const Twistpoint& shortTermPublicKey, size_t which) const;
  33. std::vector<std::vector<TwistBipoint>> get_all_current_votes(
  34. Proof& pi) const;
  35. std::vector<std::vector<TwistBipoint>> get_all_current_votes(
  36. Proof& pi, size_t which) const;
  37. EGCiphertext get_current_user_encrypted_tally(
  38. Proof& pi, const Twistpoint& shortTermPublicKey) const;
  39. EGCiphertext get_current_user_encrypted_tally(
  40. Proof& pi, const Twistpoint& shortTermPublicKey, size_t which) const;
  41. CurveBipoint get_current_server_encrypted_tally(
  42. Proof& pi, const Twistpoint& shortTermPublicKey) const;
  43. CurveBipoint get_current_server_encrypted_tally(
  44. Proof& pi, const Twistpoint& shortTermPublicKey, size_t which) const;
  45. std::vector<Twistpoint> get_current_pseudonyms(
  46. Proof& pi) const;
  47. std::vector<Twistpoint> get_current_pseudonyms(
  48. Proof& pi, size_t which) const;
  49. // PROOF COMMITMENT GETTERS
  50. void get_other_vote_row_commitments(
  51. std::vector<Proof>& pi, const Twistpoint& request) const;
  52. void get_other_vote_row_commitments(
  53. std::vector<Proof>& pi,
  54. const Twistpoint& request,
  55. size_t whichNot
  56. ) const;
  57. void get_other_vote_matrix_commitments(
  58. std::vector<Proof>& pi) const;
  59. void get_other_vote_matrix_commitments(
  60. std::vector<Proof>& pi, size_t whichNot) const;
  61. void get_other_user_tally_commitments(
  62. std::vector<Proof>& pi, const Twistpoint& request) const;
  63. void get_other_user_tally_commitments(
  64. std::vector<Proof>& pi,
  65. const Twistpoint& request,
  66. size_t whichNot
  67. ) const;
  68. void get_other_server_tally_commitments(
  69. std::vector<Proof>& pi, const Twistpoint& request) const;
  70. void get_other_server_tally_commitments(
  71. std::vector<Proof>& pi,
  72. const Twistpoint& request,
  73. size_t whichNot)
  74. const;
  75. void get_other_pseudonyms_commitments(
  76. std::vector<Proof>& pi) const;
  77. void get_other_pseudonyms_commitments(
  78. std::vector<Proof>& pi, size_t whichNot) const;
  79. // CLIENT INTERACTIONS
  80. void add_new_client(PrsonaClient& newUser);
  81. void add_new_client(PrsonaClient& newUser, size_t which);
  82. bool receive_vote(
  83. const std::vector<Proof>& pi,
  84. const std::vector<TwistBipoint>& newVotes,
  85. const Twistpoint& shortTermPublicKey);
  86. bool receive_vote(
  87. const std::vector<Proof>& pi,
  88. const std::vector<TwistBipoint>& newVotes,
  89. const Twistpoint& shortTermPublicKey,
  90. size_t which);
  91. void transmit_new_user_data(
  92. const std::vector<Proof>& pi, PrsonaClient& newUser) const;
  93. void transmit_new_user_data(
  94. const std::vector<Proof>& pi, PrsonaClient& newUser, size_t which) const;
  95. void transmit_updates(PrsonaClient& currUser) const;
  96. void transmit_updates(PrsonaClient& currUser, size_t which) const;
  97. // EPOCH
  98. void epoch();
  99. void epoch(size_t which);
  100. void print_scores() const;
  101. void print_votes() const;
  102. void print_current_votes_by(const Twistpoint& index) const;
  103. private:
  104. std::vector<PrsonaServer> servers;
  105. // SCORE TALLYING
  106. void tally_scores(
  107. const Twistpoint& nextGenerator,
  108. std::vector<EGCiphertext>& userTallyScores,
  109. std::vector<CurveBipoint>& serverTallyScores,
  110. size_t which);
  111. void distribute_tallied_scores(
  112. const std::vector<EGCiphertext>& userScores,
  113. const std::vector<CurveBipoint>& serverScores);
  114. // BINARY SEARCH
  115. size_t binary_search(
  116. const Twistpoint& shortTermPublicKey, size_t which) const;
  117. };
  118. #endif