1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- #ifndef __PRSONA_SERVER_HPP
- #define __PRSONA_SERVER_HPP
- #include <vector>
- #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<CurveBipoint> 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<CurveBipoint>& 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<TwistBipoint> previousVoteTally;
- std::vector<Curvepoint> currentPseudonyms;
- /* each element represents a vote by <rowID>
- * applied to <colID>. The outer std::vector is a std::vector of rows
- * and the inner std::vector is a std::vector of curvepoints. */
- std::vector<std::vector<CurveBipoint>> voteMatrix;
- friend class PrsonaServerEntity;
- const BGN& get_bgn_details() const;
- Curvepoint add_next_seed_to_generator(Proof& pi, const Curvepoint& currGenerator) const;
- std::vector<Scalar> tally_scores(Proof& pi);
- void export_updates(std::vector<TwistBipoint>& otherPreviousVoteTally, std::vector<Curvepoint>& otherCurrentPseudonyms, std::vector<std::vector<CurveBipoint>>& otherVoteMatrix) const;
- void import_updates(const Proof& pi, const std::vector<TwistBipoint>& otherPreviousVoteTally, const std::vector<Curvepoint>& otherCurrentPseudonyms, const std::vector<std::vector<CurveBipoint>>& otherVoteMatrix);
- void epoch_part_one(Proof& pi, Curvepoint& nextGenerator, std::vector<Scalar>& decryptedTallies);
- void epoch_part_two(Proof& pi, std::vector<EGCiphertext>& encryptedTallies);
- std::vector<size_t> 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<CurveBipoint>& votes, const Curvepoint& shortTermPublicKey) const;
- bool verify_update_proof(const Proof& pi, const std::vector<TwistBipoint>& otherPreviousVoteTally, const std::vector<Curvepoint>& otherCurrentPseudonyms, const std::vector<std::vector<CurveBipoint>>& otherVoteMatrix) const;
- Proof generate_valid_fresh_generator_proof(const Proof& pi) const;
- Proof generate_votes_valid_proof(const std::vector<CurveBipoint>& 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<Quadripoint>& BGNEncryptedTallies, const std::vector<Scalar>& decryptedTallies) const;
- Proof generate_proof_of_shuffle(const std::vector<size_t>& shuffle_order) const;
- };
- #endif
|