base.hpp 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. #ifndef __PRSONA_BASE_HPP
  2. #define __PRSONA_BASE_HPP
  3. #include <vector>
  4. #include "Curvepoint.hpp"
  5. #include "Bipoint.hpp"
  6. #include "Scalar.hpp"
  7. #include "EGCiphertext.hpp"
  8. #include "proof.hpp"
  9. class PrsonaBase {
  10. public:
  11. static size_t MAX_ALLOWED_VOTE;
  12. // SETUP FUNCTIONS
  13. static void init();
  14. static void set_server_malicious();
  15. static void set_client_malicious();
  16. // CONST GETTERS
  17. static size_t get_max_allowed_vote();
  18. Curvepoint get_blinding_generator() const;
  19. Curvepoint get_blinding_generator(std::vector<Proof>& pi) const;
  20. protected:
  21. // Essentially constants, true for both servers and clients
  22. static Curvepoint EL_GAMAL_GENERATOR;
  23. static Scalar SCALAR_N;
  24. static Scalar DEFAULT_TALLY;
  25. static Scalar DEFAULT_VOTE;
  26. static bool SERVER_IS_MALICIOUS;
  27. static bool CLIENT_IS_MALICIOUS;
  28. std::vector<Proof> elGamalBlindGeneratorProof;
  29. Curvepoint elGamalBlindGenerator;
  30. // PRIVATE ELEMENT SETTER
  31. bool set_EG_blind_generator(
  32. const std::vector<Proof>& pi,
  33. const Curvepoint& currGenerator,
  34. size_t numServers);
  35. // SCHNORR PROOFS
  36. Proof schnorr_generation(
  37. const Curvepoint& generator,
  38. const Curvepoint& commitment,
  39. const Scalar& log
  40. ) const;
  41. bool schnorr_verification(
  42. const Curvepoint& generator,
  43. const Curvepoint& commitment,
  44. const Scalar& c,
  45. const Scalar& z
  46. ) const;
  47. // OWNERSHIP PROOFS
  48. Proof generate_ownership_proof(
  49. const Curvepoint& generator,
  50. const Curvepoint& commitment,
  51. const Scalar& log
  52. ) const;
  53. bool verify_ownership_proof(
  54. const Proof& pi,
  55. const Curvepoint& generator,
  56. const Curvepoint& commitment
  57. ) const;
  58. // ITERATED SCHNORR PROOFS
  59. Proof add_to_generator_proof(
  60. const Curvepoint& currGenerator,
  61. const Scalar& seed
  62. ) const;
  63. bool verify_generator_proof(
  64. const std::vector<Proof>& pi,
  65. const Curvepoint& currGenerator,
  66. size_t numServers
  67. ) const;
  68. // REPUTATION PROOFS
  69. std::vector<Proof> generate_reputation_proof(
  70. const Proof& ownershipProof,
  71. const EGCiphertext& commitment,
  72. const Scalar& currentScore,
  73. const Scalar& threshold,
  74. const Scalar& inverseKey,
  75. size_t numClients
  76. ) const;
  77. bool verify_reputation_proof(
  78. const std::vector<Proof>& pi,
  79. const Curvepoint& generator,
  80. const Curvepoint& owner,
  81. const EGCiphertext& commitment,
  82. const Scalar& threshold
  83. ) const;
  84. // VALID VOTE PROOFS
  85. std::vector<Proof> generate_vote_proof(
  86. const Proof& ownershipProof,
  87. const CurveBipoint& g,
  88. const CurveBipoint& h,
  89. const std::vector<bool>& replaces,
  90. const std::vector<CurveBipoint>& oldEncryptedVotes,
  91. const std::vector<CurveBipoint>& newEncryptedVotes,
  92. const std::vector<Scalar>& seeds,
  93. const std::vector<Scalar>& votes
  94. ) const;
  95. bool verify_vote_proof(
  96. const CurveBipoint& g,
  97. const CurveBipoint& h,
  98. const std::vector<Proof>& pi,
  99. const std::vector<CurveBipoint>& oldEncryptedVotes,
  100. const std::vector<CurveBipoint>& newEncryptedVotes,
  101. const Curvepoint& freshGenerator,
  102. const Curvepoint& owner
  103. ) const;
  104. // EPOCH PROOFS
  105. bool verify_update_proof(
  106. const Proof& pi
  107. ) const;
  108. // SERVER AGREEMENT PROOFS
  109. Proof generate_valid_default_tally_proof() const;
  110. Proof generate_valid_fresh_generator_proof() const;
  111. Proof generate_votes_valid_proof() const;
  112. Proof generate_proof_of_added_user() const;
  113. Proof generate_score_proof() const;
  114. Proof generate_proof_of_correct_tally() const;
  115. Proof generate_proof_of_correct_sum() const;
  116. Proof generate_proof_of_shuffle() const;
  117. Proof generate_valid_pseudonyms_proof() const;
  118. bool verify_valid_tally_proof(const Proof& pi) const;
  119. bool verify_score_proof(const Proof& pi) const;
  120. bool verify_default_tally_proof(const Proof& pi) const;
  121. bool verify_default_votes_proof(const Proof& pi) const;
  122. bool verify_valid_votes_proof(const Proof& pi) const;
  123. bool verify_valid_pseudonyms_proof(const Proof& pi) const;
  124. };
  125. #endif