In this article we continue our quick start series. We assume that you are following from the previous article.
7. Create a Compute Request for Decryption
Since the result is still encrypted, we need to decrypt it.
// Create an operand for the encrypted result
ComputeRequest::ComputeOperationOperand decrypt_operand(
ComputeRequest::DataType::TENSOR,
ComputeRequest::DataEncrytionType::CIPHERTEXT,
res->data()
);
// Define the decryption operation instance
ComputeRequest::ComputeOperationInstance decrypt_operation(
ComputeRequest::ComputeOperationType::UNARY,
ComputeRequest::ComputeOperation::DECRYPT,
{ decrypt_operand }
);
// Create the compute request for decryption
ComputeRequest req_d(decrypt_operation);
// Perform the decryption
client_node.compute(req_d, &res);
// Measure the end time of decryption
auto stop_d = std::chrono::high_resolution_clock::now();
// Check if decryption was successful
if (res && res->status() == ComputeResponse::Status::OK) {
std::cout << "Decrypted result tensor received." << std::endl;
} else {
std::cerr << "Decryption failed." << std::endl;
return 1;
}