123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- #ifndef __PRSONA_NETWORK_SERVER_HPP
- #define __PRSONA_NETWORK_SERVER_HPP
- #include <string>
- #include <vector>
- #include "server.hpp"
- #include "networking.hpp"
- void obtain_update_locks(
- std::unique_lock<std::mutex> &lck,
- const std::vector<std::string>& serverIPs,
- const std::string& selfIP,
- struct synchronization_tool *synch);
- void release_update_locks(
- std::unique_lock<std::mutex> &lck,
- const std::vector<std::string>& serverIPs,
- const std::string& selfIP,
- struct synchronization_tool *synch);
- std::string make_epoch_initiator_string(
- std::vector<Proof> generatorProof,
- Twistpoint nextGenerator);
- std::string make_epoch_update_string(
- std::vector<std::vector<Proof>> pi,
- std::vector<std::vector<Twistpoint>> permutationCommits,
- std::vector<std::vector<Twistpoint>> freshPseudonymCommits,
- std::vector<std::vector<Twistpoint>> freshPseudonymSeedCommits,
- std::vector<std::vector<CurveBipoint>> serverTallyCommits,
- std::vector<std::vector<std::vector<TwistBipoint>>> partwayVoteMatrixCommits,
- std::vector<std::vector<std::vector<TwistBipoint>>> finalVoteMatrixCommits,
- std::vector<std::vector<Twistpoint>> userTallyMaskCommits,
- std::vector<std::vector<Twistpoint>> userTallyMessageCommits,
- std::vector<std::vector<Twistpoint>> userTallySeedCommits,
- Twistpoint nextGenerator,
- bool doUserTallies);
- class PrsonaServerWebSocketHandler : public CivetWebSocketHandler {
- public:
- // CONSTRUCTORS
- PrsonaServerWebSocketHandler(
- const PrsonaServer *prsonaServer,
- const std::mutex *updateMtx,
- const std::atomic<size_t> *epochNum,
- const std::vector<std::string> serverIPs,
- const std::string selfIP);
- virtual bool handleConnection(
- CivetServer *server,
- const struct mg_connection *conn);
- virtual void handleReadyState(
- CivetServer *server,
- struct mg_connection *conn);
- virtual bool handleData(
- CivetServer *server,
- struct mg_connection *conn,
- int bits,
- char *data,
- size_t data_len);
- virtual void handleClose(
- CivetServer *server,
- const struct mg_connection *conn);
- private:
- const PrsonaServer *prsonaServer;
- const std::mutex *updateMtx;
- const std::atomic<size_t> *epochNum;
- const std::vector<std::string> serverIPs;
- const std::string selfIP;
- struct synchronization_tool updateSynch, distributeSynch;
- // BASIC PUBLIC SYSTEM INFO GETTERS
- void get_bgn_public_key(struct mg_connection *c) const;
- void get_num_clients(struct mg_connection *c) const;
- void get_num_servers(struct mg_connection *c) const;
- // ENCRYPTED DATA GETTERS
- void get_current_votes_by(struct mg_connection *c) const;
- void get_all_current_votes(struct mg_connection *c) const;
- void get_current_user_encrypted_tally(struct mg_connection *c) const;
- void get_current_server_encrypted_tally(struct mg_connection *c) const;
- void get_current_pseudonyms(struct mg_connection *c) const;
- // PROOF COMMITMENT GETTERS
- void get_vote_row_commitment(struct mg_connection *c) const;
- void get_vote_matrix_commitment(struct mg_connection *c) const;
- void get_user_tally_commitment(struct mg_connection *c) const;
- void get_server_tally_commitment(struct mg_connection *c) const;
- void get_pseudonyms_commitment(struct mg_connection *c) const;
- // CLIENT INTERACTIONS
- void add_new_client(struct mg_connection *c);
- void receive_vote(struct mg_connection *c);
- // CONSTRUCTOR HELPERS
- void get_bgn_details(struct mg_connection *c) const;
- void initialize_fresh_generator(struct mg_connection *c);
- void add_rand_seed_to_generator(struct mg_connection *c) const;
- void set_EG_blind_generator(struct mg_connection *c);
- // EPOCH ROUNDS
- void build_up_midway_pseudonyms(struct mg_connection *c);
- void break_down_midway_pseudonyms(struct mg_connection *c);
- void accept_epoch_updates(struct mg_connection *c);
- // DATA MAINTENANCE
- void import_new_user_update(struct mg_connection *c);
- };
- #endif
|