Decrypting the Ouput

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;
    }

Explanation:

  • We create a ComputeOperationOperand with the encrypted result data.

  • We define a ComputeOperationInstance for the DECRYPT operation.

  • The compute method is called again to perform the decryption.

  • We measure the time taken for decryption.

Last updated