#ifndef __PRSONA_SERVER_HPP #define __PRSONA_SERVER_HPP #include #include "BGN.hpp" #include "Curvepoint.hpp" #include "Bipoint.hpp" #include "EGCiphertext.hpp" #include "proof.hpp" class PrsonaServer { public: PrsonaServer(); PrsonaServer(const BGN& other_bgn, const Curvepoint& other_blind_gen); static void set_malicious_server(); static void set_malicious_client(); BGNPublicKey get_bgn_public_key() const; Curvepoint get_blinding_generator() const; Curvepoint add_seed_to_generator(Proof& pi, const Curvepoint& currGenerator) const; std::vector get_current_votes_by(Proof& pi, const Curvepoint& shortTermPublicKey) const; void add_new_client(const Proof& proofOfValidKey, Proof& proofOfValidAddition, const Curvepoint& shortTermPublicKey); void receive_vote(const Proof& pi, const std::vector& votes, const Curvepoint& shortTermPublicKey); private: static const Curvepoint elGamalGenerator; static const Scalar scalarN; static const Scalar defaultTally; static const Scalar defaultVote; static bool malicious_server; static bool malicious_client; BGN bgn_system; Curvepoint elGamalBlindGenerator; Scalar currentSeed; Scalar nextSeed; std::vector previousVoteTally; std::vector currentPseudonyms; /* each element represents a vote by * applied to . The outer std::vector is a std::vector of rows * and the inner std::vector is a std::vector of curvepoints. */ std::vector> voteMatrix; friend class PrsonaServerEntity; const BGN& get_bgn_details() const; Curvepoint add_next_seed_to_generator(Proof& pi, const Curvepoint& currGenerator) const; std::vector tally_scores(Proof& pi); void export_updates(std::vector& otherPreviousVoteTally, std::vector& otherCurrentPseudonyms, std::vector>& otherVoteMatrix) const; void import_updates(const Proof& pi, const std::vector& otherPreviousVoteTally, const std::vector& otherCurrentPseudonyms, const std::vector>& otherVoteMatrix); void epoch_part_one(Proof& pi, Curvepoint& nextGenerator, std::vector& decryptedTallies); void epoch_part_two(Proof& pi, std::vector& encryptedTallies); std::vector order_data(); void rerandomize_vote_matrix(); size_t binary_search(const Curvepoint& index) const; struct SortingType { Curvepoint pseudonym; size_t index; bool operator<( const SortingType& rhs ) const { return pseudonym < rhs.pseudonym; } }; bool verify_valid_key_proof(const Proof& pi, const Curvepoint& shortTermPublicKey) const; bool verify_vote_proof(const Proof& pi, const std::vector& votes, const Curvepoint& shortTermPublicKey) const; bool verify_update_proof(const Proof& pi, const std::vector& otherPreviousVoteTally, const std::vector& otherCurrentPseudonyms, const std::vector>& otherVoteMatrix) const; Proof generate_valid_fresh_generator_proof(const Proof& pi) const; Proof generate_votes_valid_proof(const std::vector& votes, const Curvepoint& voter) const; Proof generate_proof_of_added_user(const Curvepoint& shortTermPublicKey) const; Proof generate_score_proof(const EGCiphertext& score) const; Proof generate_proof_of_correct_tally(const std::vector& BGNEncryptedTallies, const std::vector& decryptedTallies) const; Proof generate_proof_of_shuffle(const std::vector& shuffle_order) const; }; #endif