serverEntity.hpp 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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. // PROOF COMMITMENT GETTERS
  50. void get_other_vote_row_commitments(
  51. std::vector<Proof>& pi, const Curvepoint& request) const;
  52. void get_other_vote_row_commitments(
  53. std::vector<Proof>& pi,
  54. const Curvepoint& 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 Curvepoint& request) const;
  63. void get_other_user_tally_commitments(
  64. std::vector<Proof>& pi,
  65. const Curvepoint& request,
  66. size_t whichNot
  67. ) const;
  68. void get_other_server_tally_commitments(
  69. std::vector<Proof>& pi, const Curvepoint& request) const;
  70. void get_other_server_tally_commitments(
  71. std::vector<Proof>& pi,
  72. const Curvepoint& 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<CurveBipoint>& newVotes,
  85. const Curvepoint& shortTermPublicKey);
  86. bool receive_vote(
  87. const std::vector<Proof>& pi,
  88. const std::vector<CurveBipoint>& newVotes,
  89. const Curvepoint& shortTermPublicKey,
  90. size_t which);
  91. void transmit_new_user_data(
  92. const std::vector<Proof>& pi, PrsonaClient& newUser) const;
  93. void transmit_updates(PrsonaClient& currUser) const;
  94. void transmit_updates(PrsonaClient& currUser, size_t which) const;
  95. // EPOCH
  96. void epoch();
  97. void epoch(size_t which);
  98. void print_scores() const;
  99. void print_votes() const;
  100. void print_current_votes_by(const Curvepoint& index) const;
  101. private:
  102. std::vector<PrsonaServer> servers;
  103. // SCORE TALLYING
  104. void tally_scores(
  105. const Curvepoint& nextGenerator,
  106. std::vector<EGCiphertext>& userTallyScores,
  107. std::vector<TwistBipoint>& serverTallyScores,
  108. size_t which);
  109. void distribute_tallied_scores(
  110. const std::vector<EGCiphertext>& userScores,
  111. const std::vector<TwistBipoint>& serverScores);
  112. // BINARY SEARCH
  113. size_t binary_search(
  114. const Curvepoint& shortTermPublicKey, size_t which) const;
  115. };
  116. #endif