client.hpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. #ifndef __PRSONA_CLIENT_HPP
  2. #define __PRSONA_CLIENT_HPP
  3. #include <unordered_map>
  4. #include <vector>
  5. #include "Curvepoint.hpp"
  6. #include "Scalar.hpp"
  7. #include "BGN.hpp"
  8. #include "base.hpp"
  9. #include "EGCiphertext.hpp"
  10. #include "proof.hpp"
  11. class PrsonaClient : public PrsonaBase {
  12. public:
  13. // CONSTRUCTORS
  14. PrsonaClient(
  15. const std::vector<Proof>& generatorProof,
  16. const Twistpoint& elGamalBlindGenerator,
  17. const BGNPublicKey& serverPublicKey,
  18. size_t numServers);
  19. // BASIC PUBLIC SYSTEM INFO GETTERS
  20. Twistpoint get_short_term_public_key() const;
  21. Twistpoint get_short_term_public_key(Proof &pi) const;
  22. // SERVER INTERACTIONS
  23. std::vector<TwistBipoint> make_votes(
  24. std::vector<Proof>& validVoteProof,
  25. const std::vector<Proof>& serverProof,
  26. const std::vector<TwistBipoint>& oldEncryptedVotes,
  27. const std::vector<Scalar>& votes,
  28. const std::vector<bool>& replaces
  29. ) const;
  30. bool receive_fresh_generator(
  31. const std::vector<Proof>& pi,
  32. const Twistpoint& freshGenerator);
  33. bool receive_vote_tally(
  34. const std::vector<Proof>& pi,
  35. const EGCiphertext& score);
  36. bool receive_new_user_data(
  37. const std::vector<Proof>& mainProof,
  38. const std::vector<Proof>& serverEncryptedScoreProof,
  39. const CurveBipoint& serverEncryptedScore,
  40. const std::vector<Proof>& userEncryptedScoreProof,
  41. const EGCiphertext& userEncryptedScore,
  42. const std::vector<Proof>& voteMatrixProof,
  43. const std::vector<std::vector<TwistBipoint>>& encryptedVoteMatrix,
  44. const std::vector<Proof>& pseudonymsProof,
  45. const std::vector<Twistpoint>& currentPseudonyms);
  46. // REPUTATION PROOFS
  47. std::vector<Proof> generate_reputation_proof(
  48. const Scalar& threshold,
  49. size_t numClients
  50. ) const;
  51. bool verify_reputation_proof(
  52. const std::vector<Proof>& pi,
  53. const Twistpoint& shortTermPublicKey,
  54. const Scalar& threshold,
  55. const std::vector<Proof>& encryptedScoreProof,
  56. const EGCiphertext& encryptedScore
  57. ) const;
  58. // NEEDED FOR TESTING PROOFS
  59. Scalar get_score() const;
  60. private:
  61. // Things bound to the servers permanently
  62. const BGNPublicKey serverPublicKey;
  63. const size_t numServers;
  64. // Things bound to the servers (but change regularly)
  65. Twistpoint currentFreshGenerator;
  66. // Things bound to this user permanently
  67. Scalar longTermPrivateKey;
  68. Scalar inversePrivateKey;
  69. // Things bound to this user (but change regularly)
  70. EGCiphertext currentEncryptedScore;
  71. Scalar currentScore;
  72. // Things related to making decryption more efficient
  73. std::unordered_map<Twistpoint, Scalar, TwistpointHash>
  74. decryption_memoizer;
  75. Scalar max_checked;
  76. // SCORE DECRYPTION
  77. Scalar decrypt_score(const EGCiphertext& score);
  78. // OWNERSHIP OF STPK PROOFS
  79. Proof generate_ownership_proof() const;
  80. // VALID VOTE PROOFS
  81. std::vector<Proof> generate_vote_proof(
  82. const std::vector<bool>& replaces,
  83. const std::vector<TwistBipoint>& oldEncryptedVotes,
  84. const std::vector<TwistBipoint>& newEncryptedVotes,
  85. const std::vector<Scalar>& seeds,
  86. const std::vector<Scalar>& votes
  87. ) const;
  88. };
  89. #endif