networkClient.hpp 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #ifndef __PRSONA_NETWORK_CLIENT_HPP
  2. #define __PRSONA_NETWORK_CLIENT_HPP
  3. #include <string>
  4. #include <vector>
  5. #include <random>
  6. #include "client.hpp"
  7. #include "networking.hpp"
  8. // #define BGN_TMP_FILE (TMP_DIR "bgn")
  9. // #define GEN_TMP_FILE (TMP_DIR "generator")
  10. // #define EPOCH_GEN_TMP_FILE (TMP_DIR "epoch")
  11. class PrsonaClientWebSocketHandler : public CivetWebSocketHandler {
  12. public:
  13. // CONSTRUCTORS
  14. PrsonaClientWebSocketHandler(
  15. const PrsonaClient *prsonaClient,
  16. const std::vector<std::string>& serverIPs,
  17. const std::string& selfIP,
  18. const std::default_random_engine *generator);
  19. virtual bool handleConnection(
  20. CivetServer *server,
  21. const struct mg_connection *conn);
  22. virtual void handleReadyState(
  23. CivetServer *server,
  24. struct mg_connection *conn);
  25. virtual bool handleData(
  26. CivetServer *server,
  27. struct mg_connection *conn,
  28. int bits,
  29. char *data,
  30. size_t data_len);
  31. virtual void handleClose(
  32. CivetServer *server,
  33. const struct mg_connection *conn);
  34. private:
  35. const PrsonaClient *prsonaClient;
  36. const std::vector<std::string> serverIPs;
  37. const std::string selfIP;
  38. const std::default_random_engine *generator;
  39. void verify_reputation_proof(struct mg_connection *c) const;
  40. }
  41. template <typename T>
  42. T get_committed_val_from_file(
  43. struct synchronization_tool *sync,
  44. char *filename,
  45. Proof& pi);
  46. template <typename T>
  47. T get_first_committed_val(
  48. const std::string& server,
  49. Proof& pi,
  50. const Twistpoint& shortTermPublicKey,
  51. const char *firstUri);
  52. Proof get_commitment_from_file(
  53. struct synchronization_tool *sync,
  54. char *filename);
  55. void get_additional_commitment(
  56. const std::vector<std::string>& servers,
  57. const std::string& skip,
  58. std::vector<Proof>& pi,
  59. const Twistpoint& shortTermPublicKey,
  60. char *which);
  61. template <typename T>
  62. T get_server_committed_val(
  63. std::default_random_engine *generator,
  64. const std::vector<std::string>& serverIPs,
  65. std::vector<Proof>& pi,
  66. const Twistpoint& shortTermPublicKey,
  67. const char *firstUri
  68. const char *commitUri);
  69. #endif