#pragma once #include "senderreceiver.hpp" #include "cmix.h" #include "api.h" #include "groupelement.h" #include "keypair.h" #include "sharedkey.h" #include #include #include #include #include namespace boost { namespace asio { namespace ssl { class context; } } } namespace cmix_proto { class CMixMessage; } namespace cmix_proto { class KeyExchange; } /*! * \file */ /*! * \brief The NodeDetails struct */ struct NodeDetails { std::string host; ///< The host of the node. std::string port; ///< The port of the node. }; /*! * \brief The NetworkDetails struct */ struct NetworkDetails { std::vector node_details; ///< Vector with all the node hosts and ports in network order. std::string certdir; ///< The directory with trusted certificates. }; /*! * \brief The CMixClient class */ class CMixClient { struct NodeData { GroupElement secret_value; GroupElement shared_value; }; boost::asio::io_service io_service; std::shared_ptr ssl_ctx; CMixContext cmix_ctx; NetworkDetails network_details; std::vector network_connections; std::vector secret_values; std::vector shared_values; void key_exchange(size_t node_id); void initialize_connections(); void handle_payload(cmix_proto::Payload pl); void handle_key_exchange(size_t node_id, cmix_proto::KeyExchange const& ke); void handle_message(size_t node_id, cmix_proto::CMixMessage message); public: /*! * \brief CMixClient * \param details A vector of the connectiondetails for the cmix network */ CMixClient(NetworkDetails details); ~CMixClient(); /*! * \brief run Runs the underlying io_service. */ void run(); };