#ifndef __PRSONA_BASE_HPP #define __PRSONA_BASE_HPP #include #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& 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 elGamalBlindGeneratorProof; Curvepoint elGamalBlindGenerator; // PRIVATE ELEMENT SETTER bool set_EG_blind_generator( const std::vector& pi, const Curvepoint& currGenerator, size_t numServers); // BINARY SEARCH size_t binary_search( const std::vector 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& pi, const Curvepoint& currGenerator, size_t numServers ) const; // REPUTATION PROOFS std::vector 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& pi, const Curvepoint& generator, const Curvepoint& owner, const EGCiphertext& commitment, const Scalar& threshold ) const; // VALID VOTE PROOFS std::vector generate_vote_proof( const Proof& ownershipProof, const CurveBipoint& g, const CurveBipoint& h, const std::vector& replaces, const std::vector& oldEncryptedVotes, const std::vector& newEncryptedVotes, const std::vector& seeds, const std::vector& votes ) const; bool verify_vote_proof( const CurveBipoint& g, const CurveBipoint& h, const std::vector& pi, const std::vector& oldEncryptedVotes, const std::vector& newEncryptedVotes, const Curvepoint& freshGenerator, const Curvepoint& owner ) const; // NEW USER PROOFS std::vector generate_proof_of_added_user( const Scalar& twistBipointSeed, const Scalar& EGCiphertextSeed, const std::vector& curveBipointSelfSeeds, const std::vector& curveBipointOtherSeeds ) const; bool verify_proof_of_added_user( const std::vector& pi, const Curvepoint& currentFreshGenerator, const Curvepoint& shortTermPublicKey, const CurveBipoint& curveG, const CurveBipoint& curveH, const TwistBipoint& twistG, const TwistBipoint& twistH, size_t selfIndex, const EGCiphertext& userEncryptedScore, const TwistBipoint& serverEncryptedScore, const std::vector> encryptedVoteMatrix ) const; // EPOCH PROOFS std::vector generate_valid_permutation_proof( const std::vector>& permutations, const std::vector>& seeds, const std::vector>& commits ) const; bool verify_valid_permutation_proof( const std::vector& pi, const std::vector>& commits ) const; std::vector generate_proof_of_reordering_plus_power( const std::vector>& permutations, const Scalar& power, const std::vector>& permutationSeeds, const std::vector>& productSeeds, const std::vector& oldValues, const std::vector>& permutationCommits, const std::vector>& productCommits, const std::vector>& seedCommits ) const; bool verify_proof_of_reordering_plus_power( const std::vector& pi, const std::vector& oldValues, const std::vector>& permutationCommits, const std::vector>& productCommits, const std::vector>& seedCommits ) const; template std::vector generate_proof_of_reordering( const std::vector>& permutations, const std::vector>& permutationSeeds, const std::vector>& productSeeds, const std::vector& oldValues, const std::vector>& permutationCommits, const std::vector>& productCommits, const T& otherG, const T& otherH, bool inverted ) const; template bool verify_proof_of_reordering( const std::vector& pi, const std::vector& oldValues, const std::vector>& permutationCommits, const std::vector>& productCommits, const T& otherG, const T& otherH, bool inverted ) const; // SERVER AGREEMENT PROOFS Proof generate_valid_vote_row_proof( const std::vector& commitment) const; Proof generate_valid_vote_matrix_proof( const std::vector>& commitment) const; Proof generate_valid_user_tally_proof( const EGCiphertext& commitment) const; Proof generate_valid_server_tally_proof( const TwistBipoint& commitment) const; Proof generate_valid_pseudonyms_proof( const std::vector& commitment) const; bool verify_valid_vote_row_proof( const std::vector& pi, const std::vector& commitment ) const; bool verify_valid_vote_matrix_proof( const std::vector& pi, const std::vector>& commitment ) const; bool verify_valid_user_tally_proof( const std::vector& pi, const EGCiphertext& commitment ) const; bool verify_valid_server_tally_proof( const std::vector& pi, const TwistBipoint& commitment ) const; bool verify_valid_pseudonyms_proof( const std::vector& pi, const std::vector& commitment ) const; }; #endif