OpenVector
  • OpenVector
  • Introduction
    • Our Thesis
    • Our Solution
    • Other Approaches
    • Benchmarks
  • Network Architecture
    • Overview
    • Networking
    • Deploy Compute Node
    • Deploy CoFHE Node
    • Deploy Client Node
  • Quick start
    • Overview
    • Setting up Client Node
    • Encrypting Data
    • Tensor Multiplication
    • Decrypting the Ouput
    • Verifying the Output
    • Running the Program
  • Tutorials
    • Building MLP Block
  • Use Cases
    • Confidential LLM Inference
    • Training on Encrypted Data
    • Vector Search on Encrypted Data
    • Encrypted Data Access Control
  • API references
    • CryptoSystem Interface
    • ClientNode Class
    • ComputeRequest Class
    • ComputeResponse Class
  • PYTHON API REFERENCES
    • Overview
    • Tensor
    • nn.Module
    • nn.Functional
  • Contribution
    • Call for Research
    • CoFHE Library
Powered by GitBook
On this page
  • Public Enums
  • Constructors
  • Member Functions
  • Usage Example
  • Notes
  • See Also
  1. API references

ComputeResponse Class

The ComputeResponse class represents the response received from the OpenVector network after a computation has been performed. It contains the status of the computation and any resulting data.

Public Enums

enum class Status

Indicates the status of the computation.

  • Values:

    • OK: The computation was successful.

    • ERROR: An error occurred during the computation.

Constructors

ComputeResponse(Status status, std::string data);

Creates a compute response with the specified status and data.

ComputeResponse response(ComputeResponse::Status::OK, resultData);
  • Parameters:

    • status: The status of the computation (OK or ERROR).

    • data: The result data as a string. The format and content depend on the computation performed.

Member Functions

  • Status& status();

    Returns a reference to the status of the computation.

  • const Status& status() const;

    Returns a constant reference to the status of the computation.

  • std::string& data();

    Returns a reference to the result data string.

  • const std::string& data() const;

    Returns a constant reference to the result data string.

  • std::string to_string() const;

    Serializes the compute response to a string.

  • static ComputeResponse from_string(const std::string& str);

    Deserializes a compute response from a string.

Usage Example

// After performing a compute operation using ClientNode
ComputeResponse* response = nullptr;
clientNode.compute(request, &response);

if (response) {
    if (response->status() == ComputeResponse::Status::OK) {
        // Deserialize the result
        PlainTextImpl resultPt = cs.deserialize_plaintext(response->data());
        float resultValue = cs.get_float_from_plaintext(resultPt);
        // Use the resultValue
    } else {
        // Handle error
        std::cerr << "Computation failed." << std::endl;
    }
} else {
    // Handle null response
    std::cerr << "No response received from the server." << std::endl;
}

Notes

  • The data field contains the serialized result of the computation. You need to deserialize it using the appropriate method from the CryptoSystem.

  • Always check the status before attempting to use the data.

  • In case of an error, the data field may contain an error message or be empty.

See Also

PreviousComputeRequest ClassNextOverview

Last updated 6 months ago

ClientNode Class
ComputeRequest Class
CryptoSystem Interface