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
  1. Quick start

Verifying the Output

In this article we continue our quick start series. We assume that you are following from the previous article.

8. Deserialize and Display the Result

We will deserialize the decrypted tensor and output the result.

    // Deserialize the plaintext tensor
    Tensor<CPUCryptoSystem::PlainText*> result_tensor = cs.deserialize_plaintext_tensor(res->data());

    // Flatten the tensor for easy traversal
    result_tensor.flatten();

    // Display the result
    std::cout << "Resulting matrix after multiplication and decryption:" << std::endl;
    for (size_t idx = 0; idx < result_tensor.size(); ++idx) {
        float value = cs.get_float_from_plaintext(*result_tensor[idx]);
        std::cout << value << " ";
        if ((idx + 1) % p == 0) {
            std::cout << std::endl;
        }
    }

    // Calculate and display computation times
    auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
    auto duration_d = std::chrono::duration_cast<std::chrono::microseconds>(stop_d - stop);

    std::cout << "Time taken by multiplication: " << duration.count() << " microseconds" << std::endl;
    std::cout << "Time taken by decryption: " << duration_d.count() << " microseconds" << std::endl;

    return 0;
}

Explanation:

  • We deserialize the plaintext tensor from the response data.

  • Flattening the tensor allows us to traverse all elements easily.

  • We use get_float_from_plaintext to extract float values from the plaintexts.

  • The results are displayed in matrix form.

  • We output the durations for both multiplication and decryption.

PreviousDecrypting the OuputNextRunning the Program

Last updated 6 months ago