serverEntity.hpp 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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(
  14. size_t which
  15. ) const;
  16. Twistpoint get_blinding_generator() const;
  17. Twistpoint get_blinding_generator(
  18. size_t which
  19. ) const;
  20. Twistpoint get_blinding_generator(
  21. std::vector<Proof>& pi
  22. ) const;
  23. Twistpoint get_blinding_generator(
  24. std::vector<Proof>& pi,
  25. size_t which
  26. ) const;
  27. Twistpoint get_fresh_generator() const;
  28. Twistpoint get_fresh_generator(
  29. size_t which
  30. ) const;
  31. Twistpoint get_fresh_generator(
  32. std::vector<Proof>& pi
  33. ) const;
  34. Twistpoint get_fresh_generator(
  35. std::vector<Proof>& pi,
  36. size_t which
  37. ) const;
  38. size_t get_num_clients() const;
  39. size_t get_num_clients(
  40. size_t which
  41. ) const;
  42. size_t get_num_servers() const;
  43. size_t get_num_servers(
  44. size_t which
  45. ) const;
  46. // ENCRYPTED DATA GETTERS
  47. std::vector<TwistBipoint> get_current_votes_by(
  48. Proof& pi,
  49. const Twistpoint& shortTermPublicKey
  50. ) const;
  51. std::vector<TwistBipoint> get_current_votes_by(
  52. Proof& pi,
  53. const Twistpoint& shortTermPublicKey,
  54. size_t which
  55. ) const;
  56. std::vector<std::vector<TwistBipoint>> get_all_current_votes(
  57. Proof& pi
  58. ) const;
  59. std::vector<std::vector<TwistBipoint>> get_all_current_votes(
  60. Proof& pi,
  61. size_t which
  62. ) const;
  63. EGCiphertext get_current_user_encrypted_tally(
  64. Proof& pi,
  65. const Twistpoint& shortTermPublicKey
  66. ) const;
  67. EGCiphertext get_current_user_encrypted_tally(
  68. Proof& pi,
  69. const Twistpoint& shortTermPublicKey,
  70. size_t which
  71. ) const;
  72. CurveBipoint get_current_server_encrypted_tally(
  73. Proof& pi,
  74. const Twistpoint& shortTermPublicKey
  75. ) const;
  76. CurveBipoint get_current_server_encrypted_tally(
  77. Proof& pi,
  78. const Twistpoint& shortTermPublicKey,
  79. size_t which
  80. ) const;
  81. std::vector<Twistpoint> get_current_pseudonyms(
  82. Proof& pi
  83. ) const;
  84. std::vector<Twistpoint> get_current_pseudonyms(
  85. Proof& pi,
  86. size_t which
  87. ) const;
  88. // PROOF COMMITMENT GETTERS
  89. void get_other_vote_row_commitments(
  90. std::vector<Proof>& pi,
  91. const Twistpoint& request
  92. ) const;
  93. void get_other_vote_row_commitments(
  94. std::vector<Proof>& pi,
  95. const Twistpoint& request,
  96. size_t whichNot
  97. ) const;
  98. void get_other_vote_matrix_commitments(
  99. std::vector<Proof>& pi
  100. ) const;
  101. void get_other_vote_matrix_commitments(
  102. std::vector<Proof>& pi,
  103. size_t whichNot
  104. ) const;
  105. void get_other_user_tally_commitments(
  106. std::vector<Proof>& pi,
  107. const Twistpoint& request
  108. ) const;
  109. void get_other_user_tally_commitments(
  110. std::vector<Proof>& pi,
  111. const Twistpoint& request,
  112. size_t whichNot
  113. ) const;
  114. void get_other_server_tally_commitments(
  115. std::vector<Proof>& pi,
  116. const Twistpoint& request
  117. ) const;
  118. void get_other_server_tally_commitments(
  119. std::vector<Proof>& pi,
  120. const Twistpoint& request,
  121. size_t whichNot)
  122. const;
  123. void get_other_pseudonyms_commitments(
  124. std::vector<Proof>& pi
  125. ) const;
  126. void get_other_pseudonyms_commitments(
  127. std::vector<Proof>& pi,
  128. size_t whichNot
  129. ) const;
  130. // CLIENT INTERACTIONS
  131. void add_new_client(
  132. PrsonaClient& newUser);
  133. void add_new_client(
  134. PrsonaClient& newUser,
  135. size_t which);
  136. bool receive_vote(
  137. const std::vector<Proof>& pi,
  138. const std::vector<TwistBipoint>& newVotes,
  139. const Twistpoint& shortTermPublicKey);
  140. bool receive_vote(
  141. const std::vector<Proof>& pi,
  142. const std::vector<TwistBipoint>& newVotes,
  143. const Twistpoint& shortTermPublicKey,
  144. size_t which);
  145. void transmit_new_user_data(
  146. const std::vector<Proof>& pi,
  147. PrsonaClient& newUser
  148. ) const;
  149. void transmit_new_user_data(
  150. const std::vector<Proof>& pi,
  151. PrsonaClient& newUser,
  152. size_t which
  153. ) const;
  154. void transmit_updates(
  155. PrsonaClient& currUser
  156. ) const;
  157. void transmit_updates(
  158. PrsonaClient& currUser,
  159. size_t which
  160. ) const;
  161. // EPOCH
  162. void epoch();
  163. void epoch(
  164. size_t which);
  165. void print_scores() const;
  166. void print_votes() const;
  167. void print_current_votes_by(
  168. const Twistpoint& index
  169. ) const;
  170. private:
  171. std::vector<PrsonaServer> servers;
  172. // SCORE TALLYING
  173. void tally_scores(
  174. const Twistpoint& nextGenerator,
  175. std::vector<EGCiphertext>& userTallyScores,
  176. std::vector<CurveBipoint>& serverTallyScores,
  177. size_t which);
  178. void distribute_tallied_scores(
  179. const std::vector<EGCiphertext>& userScores,
  180. const std::vector<CurveBipoint>& serverScores);
  181. // BINARY SEARCH
  182. size_t binary_search(
  183. const Twistpoint& shortTermPublicKey,
  184. size_t which
  185. ) const;
  186. };
  187. #endif