123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175 |
- #ifndef __PRSONA_BASE_HPP
- #define __PRSONA_BASE_HPP
- #include <vector>
- #include "Curvepoint.hpp"
- #include "Bipoint.hpp"
- #include "Scalar.hpp"
- #include "EGCiphertext.hpp"
- #include "proof.hpp"
- class PrsonaBase {
- public:
- static size_t MAX_ALLOWED_VOTE;
- // SETUP FUNCTIONS
- static void init();
- static void set_server_malicious();
- static void set_client_malicious();
- // CONST GETTERS
- static size_t get_max_allowed_vote();
- Curvepoint get_blinding_generator() const;
- Curvepoint get_blinding_generator(std::vector<Proof>& pi) const;
- protected:
- // Essentially constants, true for both servers and clients
- static Curvepoint EL_GAMAL_GENERATOR;
- static Scalar SCALAR_N;
- static Scalar DEFAULT_TALLY;
- static Scalar DEFAULT_VOTE;
- static bool SERVER_IS_MALICIOUS;
- static bool CLIENT_IS_MALICIOUS;
-
- std::vector<Proof> elGamalBlindGeneratorProof;
- Curvepoint elGamalBlindGenerator;
- // PRIVATE ELEMENT SETTER
- bool set_EG_blind_generator(
- const std::vector<Proof>& pi,
- const Curvepoint& currGenerator,
- size_t numServers);
- // BINARY SEARCH
- size_t binary_search(
- const std::vector<Curvepoint> list, const Curvepoint& index) const;
- // SCHNORR PROOFS
- Proof schnorr_generation(
- const Curvepoint& generator,
- const Curvepoint& commitment,
- const Scalar& log
- ) const;
- bool schnorr_verification(
- const Curvepoint& generator,
- const Curvepoint& commitment,
- const Scalar& c,
- const Scalar& z
- ) const;
- // OWNERSHIP PROOFS
- Proof generate_ownership_proof(
- const Curvepoint& generator,
- const Curvepoint& commitment,
- const Scalar& log
- ) const;
- bool verify_ownership_proof(
- const Proof& pi,
- const Curvepoint& generator,
- const Curvepoint& commitment
- ) const;
- // ITERATED SCHNORR PROOFS
- Proof add_to_generator_proof(
- const Curvepoint& currGenerator,
- const Scalar& seed
- ) const;
- bool verify_generator_proof(
- const std::vector<Proof>& pi,
- const Curvepoint& currGenerator,
- size_t numServers
- ) const;
- // REPUTATION PROOFS
- std::vector<Proof> generate_reputation_proof(
- const Proof& ownershipProof,
- const EGCiphertext& commitment,
- const Scalar& currentScore,
- const Scalar& threshold,
- const Scalar& inverseKey,
- size_t numClients
- ) const;
- bool verify_reputation_proof(
- const std::vector<Proof>& pi,
- const Curvepoint& generator,
- const Curvepoint& owner,
- const EGCiphertext& commitment,
- const Scalar& threshold
- ) const;
- // VALID VOTE PROOFS
- std::vector<Proof> generate_vote_proof(
- const Proof& ownershipProof,
- const CurveBipoint& g,
- const CurveBipoint& h,
- const std::vector<bool>& replaces,
- const std::vector<CurveBipoint>& oldEncryptedVotes,
- const std::vector<CurveBipoint>& newEncryptedVotes,
- const std::vector<Scalar>& seeds,
- const std::vector<Scalar>& votes
- ) const;
- bool verify_vote_proof(
- const CurveBipoint& g,
- const CurveBipoint& h,
- const std::vector<Proof>& pi,
- const std::vector<CurveBipoint>& oldEncryptedVotes,
- const std::vector<CurveBipoint>& newEncryptedVotes,
- const Curvepoint& freshGenerator,
- const Curvepoint& owner
- ) const;
- // NEW USER PROOFS
- std::vector<Proof> generate_proof_of_added_user(
- const Scalar& twistBipointSeed,
- const Scalar& EGCiphertextSeed,
- const std::vector<Scalar>& curveBipointSelfSeeds,
- const std::vector<Scalar>& curveBipointOtherSeeds
- ) const;
- bool verify_proof_of_added_user(
- const std::vector<Proof>& pi,
- const Curvepoint& currentFreshGenerator,
- const Curvepoint& shortTermPublicKey,
- const Curvepoint& elGamalBlindGenerator,
- const CurveBipoint& curveG,
- const CurveBipoint& curveH,
- const TwistBipoint& twistG,
- const TwistBipoint& twistH,
- size_t selfIndex,
- const EGCiphertext& userEncryptedScore,
- const TwistBipoint& serverEncryptedScore,
- const std::vector<std::vector<CurveBipoint>> encryptedVoteMatrix
- ) const;
- // EPOCH PROOFS
- Proof generate_proof_of_added_user() const;
- Proof generate_proof_of_correct_tally() const;
- Proof generate_proof_of_correct_sum() const;
- Proof generate_proof_of_shuffle() const;
- bool verify_update_proof(const Proof& pi) const;
- // SERVER AGREEMENT PROOFS
- Proof generate_valid_user_tally_proof() const;
- Proof generate_valid_server_tally_proof() const;
- Proof generate_valid_vote_row_proof() const;
- Proof generate_valid_vote_matrix_proof() const;
- Proof generate_valid_pseudonyms_proof() const;
-
- bool verify_valid_user_tally_proof(const Proof& pi) const;
- bool verify_valid_server_tally_proof(const Proof& pi) const;
- bool verify_valid_vote_row_proof(const Proof& pi) const;
- bool verify_valid_vote_matrix_proof(const Proof& pi) const;
- bool verify_valid_pseudonyms_proof(const Proof& pi) const;
- };
- #endif
|