123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109 |
- #ifndef __PRSONA_NETWORK_CLIENT_HPP
- #define __PRSONA_NETWORK_CLIENT_HPP
- #include <string>
- #include <vector>
- #include <random>
- #include "client.hpp"
- #include "networking.hpp"
- // #define BGN_TMP_FILE (TMP_DIR "bgn")
- // #define GEN_TMP_FILE (TMP_DIR "generator")
- // #define EPOCH_GEN_TMP_FILE (TMP_DIR "epoch")
- class PrsonaClientWebSocketHandler : public CivetWebSocketHandler {
- public:
- // CONSTRUCTORS
- PrsonaClientWebSocketHandler(
- PrsonaClient *prsonaClient,
- const std::vector<std::string>& serverIPs,
- const std::vector<int>& serverPorts,
- std::default_random_engine *generator);
- 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:
- PrsonaClient *prsonaClient;
- const std::vector<std::string> serverIPs;
- const std::vector<int> serverPorts;
- std::default_random_engine *generator;
- void generate_response(
- struct mg_connection *conn,
- const char *filename) const;
- void verify_reputation_proof(
- struct mg_connection *conn,
- const char *filename) const;
- };
- template <typename T>
- T get_committed_val_from_file(
- struct synchronization_tool *sync,
- const char *filename,
- Proof& pi);
- template <typename T>
- T get_first_committed_val(
- std::default_random_engine *rng,
- const std::string& server,
- int serverPort,
- Proof& pi,
- const Twistpoint& shortTermPublicKey,
- const char *firstUri);
- Proof get_commitment_from_file(
- struct synchronization_tool *sync,
- char *filename);
- void get_additional_commitment(
- std::default_random_engine *rng,
- const std::vector<std::string>& serverIPs,
- const std::vector<int>& serverPorts,
- const std::string& skipIP,
- int skipPort,
- std::vector<Proof>& pi,
- const Twistpoint& shortTermPublicKey,
- char *which);
- template <typename T>
- T get_server_committed_val(
- std::default_random_engine *generator,
- const std::vector<std::string>& serverIPs,
- const std::vector<int>& serverPorts,
- std::vector<Proof>& pi,
- const Twistpoint& shortTermPublicKey,
- const char *firstUri,
- const char *commitUri);
- Twistpoint get_generator_from_file(
- struct synchronization_tool *sync,
- const char *filename,
- std::vector<Proof>& pi);
- Twistpoint get_generator(
- std::default_random_engine *randomGenerator,
- const std::vector<std::string>& serverIPs,
- const std::vector<int>& serverPorts,
- std::vector<Proof>& pi,
- bool fresh);
- #endif
|