#ifndef __PRSONA_NETWORK_CLIENT_HPP #define __PRSONA_NETWORK_CLIENT_HPP #include #include #include #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& serverIPs, const std::vector& 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 serverIPs; const std::vector 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 T get_committed_val_from_file( struct synchronization_tool *sync, const char *filename, Proof& pi); template 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& serverIPs, const std::vector& serverPorts, const std::string& skipIP, int skipPort, std::vector& pi, const Twistpoint& shortTermPublicKey, char *which); template T get_server_committed_val( std::default_random_engine *generator, const std::vector& serverIPs, const std::vector& serverPorts, std::vector& pi, const Twistpoint& shortTermPublicKey, const char *firstUri, const char *commitUri); Twistpoint get_generator_from_file( struct synchronization_tool *sync, const char *filename, std::vector& pi); Twistpoint get_generator( std::default_random_engine *randomGenerator, const std::vector& serverIPs, const std::vector& serverPorts, std::vector& pi, bool fresh); #endif