54 uint64_t r = k % (p - 1), q = (k - r) / (p - 1);
67 uint64_t a = 0, k = std::rand(), p = 0, g = 0;
83 p = std::get<0>(pair);
84 auto q = std::get<1>(pair);
114 throw std::runtime_error(
"Failed to send key!");
116 throw std::runtime_error(
"Failed to send key!");
120 throw std::runtime_error(
"Failed to send key!");
132 throw std::runtime_error(
"Failed to send key!");
The namespace for Key-Exchange functions.
Definition exchange.h:34
uint64_t exchange_keys(const bool &server)
Exchange keys on an established connection.
Definition exchange.h:65
uint64_t compute_intermediary(const uint64_t &p, const uint64_t &g, const uint64_t &k)
Compute the intermeidary value to send across the wire.
Definition exchange.h:47
int send_value(const T &value, const network::meta &type=DATA, const size_t &timeout=5)
Send a value.
Definition network.h:109
const T recv_value(const size_t &timeout=5)
Receive a value.
Definition network.h:131
std::pair< uint64_t, uint64_t > generate()
Generates a prime number.
Definition prime.h:93
uint64_t raise(uint64_t value, uint64_t exp, const uint64_t &mod)
A O(logn) raise operation that works within modulus to prevent overflow.
Definition prime.h:64