12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394 |
- #ifndef __PRSONA_NETWORK_CLIENT_HPP
- #define __PRSONA_NETWORK_CLIENT_HPP
- #include <string>
- #include <sstream>
- #include <cstring>
- #include <cstdio>
- #include "client.hpp"
- #include "CivetServer.h"
- #define MG_WEBSOCKET_OPCODE_DATACOMPLETE 0xb
- #define PRSONA_PORT 8080
- #define USE_SSL 0
- #define USER_TALLY_URI "/ws?h"
- #define USER_TALLY_COMMIT_URI "/ws?m"
- enum RequestType {
- PRSONA_ADD_CLIENT = 'a',
- PRSONA_RECEIVE_VOTE,
- PRSONA_GET_BGN_PUBKEY,
- PRSONA_GET_NUM_CLIENTS,
- PRSONA_GET_NUM_SERVERS,
- PRSONA_GET_VOTES_BY,
- PRSONA_GET_ALL_VOTES,
- PRSONA_GET_USER_TALLY,
- PRSONA_GET_SERVER_TALLY,
- PRSONA_GET_PSEUDONYMS,
- PRSONA_GET_VOTE_ROW_COMMITMENT,
- PRSONA_GET_VOTE_MATRIX_COMMITMENT,
- PRSONA_GET_USER_TALLY_COMMITMENT,
- PRSONA_GET_SERVER_TALLY_COMMITMENT,
- PRSONA_GET_PSEUDONYMS_COMMITMENT,
- PRSONA_GET_BGN_DETAILS,
- PRSONA_ADD_CURR_SEED_TO_GENERATOR,
- PRSONA_SET_FRESH_GENERATOR,
- PRSONA_ADD_RAND_SEED_TO_GENERATOR,
- PRSONA_SET_EG_BLIND_GENERATOR,
- PRSONA_EPOCH_BUILD_UP,
- PRSONA_EPOCH_BREAK_DOWN,
- PRSONA_EPOCH_UPDATE,
- PRSONA_NEW_USER_UPDATE,
- PRSONA_GET_PARTIAL_DECRYPTION,
- PRSONA_RECEIVE_PARTIAL_DECRYPTION,
- PRSONA_GET_FRESH_GENERATOR = '-',
- PRSONA_GET_EG_BLIND_GENERATOR ='_',
- PRSONA_RECEIVE_FRESH_GENERATOR = 'a',
- PRSONA_RECEIVE_VOTE_TALLY,
- PRSONA_RECEIVE_NEW_USER_DATA,
- PRSONA_VERIFY_REPUTATION_PROOF
- };
- struct synchronization_tool {
- std::mutex mtx;
- std::condition_variable cv;
- size_t val, val2;
- };
- class PrsonaClientWebSocketHandler : public CivetWebSocketHandler {
- public:
- // CONSTRUCTORS
- PrsonaClientWebSocketHandler(
- const PrsonaClient *prsonaClient,
- 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 PrsonaClient *prsonaClient;
- const std::vector<std::string> serverIPs;
- const std::string selfIP;
- void verify_reputation_proof(struct mg_connection *c) const;
- }
- #endif
|