#include "Context.hpp"

#include "utils/crypto/rsa/RsaKeyPair.hpp"


Context::Context(const int socket, addrinfo* broadcastAddressInfo) {
    const auto keyPair = drp::util::crypto::RsaKeyPair(2048);

    // communication
    this->socket = socket;
    this->broadcastAddressInfo = broadcastAddressInfo;
    this->server = nullptr;

    // ourselves
    this->me = Peer(keyPair.getPublicKey());

    // others
    this->latestPeerDiscovery = std::chrono::high_resolution_clock::now();

    // crytography
    this->cryptoRsaPrivateKey = keyPair.getPrivateKey();
}
