server.hpp 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #ifndef __PRSONA_SERVER_HPP
  2. #define __PRSONA_SERVER_HPP
  3. #include "BGN.hpp"
  4. #include "Curvepoint.hpp"
  5. #include "Bipoint.hpp"
  6. #include "EGCiphertext.hpp"
  7. class PrsonaServer : public BGN {
  8. public:
  9. PrsonaServer();
  10. Curvepoint get_blinding_generator() const;
  11. Curvepoint get_fresh_generator() const;
  12. Curvepoint add_new_client(const Curvepoint& longTermPublicKey);
  13. vector<EGCiphertext> epoch();
  14. void receive_vote(const Proof& pi, const vector<CurveBipoint>& votes, const Curvepoint& shortTermPublicKey);
  15. private:
  16. static const Curvepoint elGamalGenerator;
  17. Curvepoint elGamalBlindGenerator;
  18. Scalar currentSeed;
  19. vector<TwistBipoint> previousVoteTally;
  20. vector<Curvepoint> currentPseudonyms;
  21. /* each element represents a vote by <rowID>
  22. * applied to <colID> */
  23. vector<vector<CurveBipoint>> voteMatrix;
  24. template <typename T>
  25. void shuffle_vote_matrix(vector<T>& otherVector);
  26. void rerandomize_vote_matrix();
  27. size_t binary_search(const Curvepoint& index) const;
  28. bool verify_vote_proof(CurveBipoint vote, Proof pi, PrsonaPublicKey shortTermPublicKey);
  29. struct SortingType {
  30. Curvepoint pseudonym;
  31. size_t index;
  32. bool operator<( const SortingType& rhs ) const
  33. { return pseudonym < rhs.pseudonym; }
  34. }
  35. };
  36. #endif