Added challenge issue and verification for peer connections (#93)

Implemented flatbuffer peer challenge issue and verification messages.
Replaced session flags with challenge status enum.
This commit is contained in:
Ravidu Lashan
2020-04-20 05:55:42 +05:30
committed by GitHub
parent 721daf19f3
commit ef8ec0f51d
12 changed files with 303 additions and 145 deletions

View File

@@ -17,7 +17,6 @@ contract_config cfg;
const static char *MODE_OBSERVER = "observer";
const static char *MODE_PROPOSER = "proposer";
constexpr size_t PEERID_LEN = 16;
/**
* Loads and initializes the contract config for execution. Must be called once during application startup.
@@ -36,12 +35,6 @@ int init()
// Append self peer to peer list.
const std::string portstr = std::to_string(cfg.peerport);
// We calculate the self peer id to be a random string.
// Use libsodium to generate the random challenge bytes.
unsigned char peerid_bytes[PEERID_LEN];
randombytes_buf(peerid_bytes, PEERID_LEN);
util::bin2hex(cfg.self_peerid, peerid_bytes, PEERID_LEN);
cfg.peers.emplace(std::make_pair(SELF_HOST, cfg.peerport));
// Append self pubkey to unl list.