Setting up Client Node

This guide(along with next few pages in this section) provides an example of how to use the CoFHE (Collaborative Fully Homomorphic Encryption) library to perform computations over encrypted data using the provided API. We will walk through setting up a client node, encrypting data, creating compute requests, and interpreting the responses.

Prerequisites

  • CoFHE Library: The CoFHE library and its dependencies should be properly installed and included in your project.

1. Include Necessary Headers

Begin by including the necessary headers:

#include <iostream>
#include <chrono>
#include "cofhe.hpp"
#include "node/network_details.hpp"
#include "node/client_node.hpp"
#include "node/compute_request_handler.hpp"

Make sure these headers correspond to the CoFHE library's files in your project.

2. Set Up the Client Node

We need to initialize a ClientNode that will communicate with the network.

int main(int argc, char* argv[]) {
    // Check for the required number of command-line arguments
    if (argc < 5) {
        std::cerr << "Usage: " << argv[0] << " <client_ip> <client_port> <setup_ip> <setup_port>" << std::endl;
        return 1;
    }

    // Parse node details from command-line arguments
    auto self_details = NodeDetails{argv[1], argv[2], NodeType::CLIENT_NODE};
    auto setup_node_details = NodeDetails{argv[3], argv[4], NodeType::SETUP_NODE};

    // Create the client node
    auto client_node = make_client_node<CPUCryptoSystem>(setup_node_details);

    // Get the CryptoSystem instance from the client node
    auto& cs = client_node.crypto_system();

Explanation:

  • We parse the client and setup node details from the command-line arguments.

  • make_client_node<CPUCryptoSystem> creates a client node using the CPU-based cryptosystem.

  • We obtain a reference to the cryptosystem to perform local cryptographic operations.

Last updated