Verifying the Output
8. Deserialize and Display 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;
}Last updated