client.hpp 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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(
  22. Proof &pi
  23. ) const;
  24. // SERVER INTERACTIONS
  25. std::vector<TwistBipoint> make_votes(
  26. std::vector<Proof>& validVoteProof,
  27. const std::vector<Proof>& serverProof,
  28. const std::vector<TwistBipoint>& oldEncryptedVotes,
  29. const std::vector<Scalar>& votes,
  30. const std::vector<bool>& replaces
  31. ) const;
  32. bool receive_fresh_generator(
  33. const std::vector<Proof>& pi,
  34. const Twistpoint& freshGenerator);
  35. bool receive_vote_tally(
  36. const std::vector<Proof>& pi,
  37. const EGCiphertext& score);
  38. bool receive_new_user_data(
  39. const std::vector<Proof>& mainProof,
  40. const std::vector<Proof>& serverEncryptedScoreProof,
  41. const CurveBipoint& serverEncryptedScore,
  42. const std::vector<Proof>& userEncryptedScoreProof,
  43. const EGCiphertext& userEncryptedScore,
  44. const std::vector<Proof>& voteMatrixProof,
  45. const std::vector<std::vector<TwistBipoint>>& encryptedVoteMatrix,
  46. const std::vector<Proof>& pseudonymsProof,
  47. const std::vector<Twistpoint>& currentPseudonyms);
  48. // REPUTATION PROOFS
  49. std::vector<Proof> generate_reputation_proof(
  50. const Scalar& threshold,
  51. size_t numClients
  52. ) const;
  53. bool verify_reputation_proof(
  54. const std::vector<Proof>& pi,
  55. const Twistpoint& shortTermPublicKey,
  56. const Scalar& threshold,
  57. const std::vector<Proof>& encryptedScoreProof,
  58. const EGCiphertext& encryptedScore
  59. ) const;
  60. // NEEDED FOR TESTING PROOFS
  61. Scalar get_score() const;
  62. private:
  63. // Things bound to the servers permanently
  64. const BGNPublicKey serverPublicKey;
  65. const size_t numServers;
  66. // Things bound to the servers (but change regularly)
  67. Twistpoint currentFreshGenerator;
  68. // Things bound to this user permanently
  69. Scalar longTermPrivateKey;
  70. Scalar inversePrivateKey;
  71. // Things bound to this user (but change regularly)
  72. EGCiphertext currentEncryptedScore;
  73. Scalar currentScore;
  74. // Things related to making decryption more efficient
  75. std::unordered_map<Twistpoint, Scalar, TwistpointHash>
  76. decryption_memoizer;
  77. Scalar max_checked;
  78. // SCORE DECRYPTION
  79. Scalar decrypt_score(
  80. const EGCiphertext& score);
  81. // OWNERSHIP OF STPK PROOFS
  82. Proof generate_ownership_proof() const;
  83. // VALID VOTE PROOFS
  84. std::vector<Proof> generate_vote_proof(
  85. const std::vector<bool>& replaces,
  86. const std::vector<TwistBipoint>& oldEncryptedVotes,
  87. const std::vector<TwistBipoint>& newEncryptedVotes,
  88. const std::vector<Scalar>& seeds,
  89. const std::vector<Scalar>& votes
  90. ) const;
  91. };
  92. #endif