serverEntity.hpp 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. PrsonaServerEntity(size_t numServers);
  10. BGNPublicKey get_bgn_public_key() const;
  11. Curvepoint get_blinding_generator() const;
  12. Curvepoint get_fresh_generator(Proof& pi) const;
  13. Scalar decrypt(const CurveBipoint& input);
  14. std::vector<CurveBipoint> get_current_votes_by(Proof& pi, const Curvepoint& shortTermPublicKey) const;
  15. EGCiphertext get_current_tally(const Proof& ownerProof, Proof& serverProof, const Curvepoint& shortTermPublicKey, bool isOwner, Scalar& randomizationMask) const;
  16. void add_new_client(PrsonaClient& newUser);
  17. void receive_vote(const Proof& pi, const std::vector<CurveBipoint>& votes, const Curvepoint& shortTermPublicKey);
  18. void epoch();
  19. void transmit_score(PrsonaClient& currUser) const;
  20. private:
  21. std::vector<PrsonaServer> servers;
  22. std::vector<EGCiphertext> encryptedTallies;
  23. std::vector<Scalar> encryptedTallyMasks;
  24. std::vector<Proof> tallyProofs;
  25. EGCiphertext get_default_tally(Proof& pi, const Curvepoint& shortTermPublicKey, Scalar& randomizationMask) const;
  26. Proof generate_valid_default_tally_proof(const EGCiphertext& encryptedDefaultTally, const Scalar& lambda) const;
  27. Proof generate_epoch_round_one_proof(const Proof& pi1, const Proof& pi2) const;
  28. Proof generate_epoch_proof(const Proof& pi, const EGCiphertext& encryptedTally) const;
  29. bool verify_ownership_proof(const Proof& pi, const Curvepoint& shortTermPublicKey) const;
  30. std::vector<Scalar> tally_scores(Proof& pi);
  31. size_t binary_search(const Curvepoint& index) const;
  32. };
  33. #endif