1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- #ifndef __PRSONA_CLIENT_HPP
- #define __PRSONA_CLIENT_HPP
- #include <unordered_map>
- #include <vector>
- #include "Curvepoint.hpp"
- #include "Scalar.hpp"
- #include "BGN.hpp"
- #include "EGCiphertext.hpp"
- #include "proof.hpp"
- class PrsonaClient {
- public:
- PrsonaClient(const BGNPublicKey& serverPublicKey, const Curvepoint& elGamalBlindGenerator);
- static void set_malicious_server();
- static void set_malicious_client();
- Curvepoint get_short_term_public_key(Proof &pi) const;
- void make_votes(Proof& pi, std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote, const std::vector<bool>& replace) const;
- void receive_fresh_generator(const Proof& pi, const Curvepoint& freshGenerator);
- void receive_vote_tally(const Proof& pi, const EGCiphertext& score, bool isDefault, const Scalar& randomizationMask);
- void receive_encrypted_votes(const Proof& pi, const std::vector<CurveBipoint>& votes, bool isDefault);
-
- std::vector<Proof> generate_reputation_proof(const Scalar& threshold) const;
- bool verify_reputation_proof(const std::vector<Proof>& pi, const Curvepoint& shortTermPublicKey, const Scalar& threshold) const;
- Proof generate_ownership_proof() const;
- bool verify_ownership_proof(const Proof& pi, const Curvepoint& shortTermPublicKey) const;
- private:
- static Curvepoint elGamalGenerator;
- static bool malicious_server;
- static bool malicious_client;
- const BGNPublicKey serverPublicKey;
- const Curvepoint elGamalBlindGenerator;
-
- Curvepoint currentFreshGenerator;
- EGCiphertext currentEncryptedScore;
- Scalar currentRandomizationMask;
- Scalar longTermPrivateKey;
- Scalar inversePrivateKey;
- Scalar currentScore;
- std::vector<CurveBipoint> currEncryptedVotes;
- std::unordered_map<Curvepoint, Scalar, CurvepointHash> decryption_memoizer;
- Scalar max_checked;
- void decrypt_score(const EGCiphertext& score);
- Proof generate_stpk_proof() const;
- bool verify_generator_proof(const Proof& pi, const Curvepoint& generator) const;
- bool verify_default_tally_proof(const Proof& pi, const EGCiphertext& generator) const;
- bool verify_valid_tally_proof(const Proof& pi, const EGCiphertext& score) const;
- bool verify_default_votes_proof(const Proof& pi, const std::vector<CurveBipoint>& votes) const;
- bool verify_valid_votes_proof(const Proof& pi, const std::vector<CurveBipoint>& votes) const;
- Proof generate_vote_proof(const std::vector<CurveBipoint>& encryptedVotes, const std::vector<Scalar>& vote) const;
- bool verify_score_proof(const Proof& pi) const;
- };
- #endif
|