Open cnquang opened 1 year ago
You can write code to do just that. Store the parameters. Did you encounter a problem with that?
Below is my code to store and read pir_params. I successful save the pir_params.bin file, but when I read the pir_params.bin file in another time. It is show an error: Segmentation fault (core dumped) when I run this line: print_pir_params(pir_params);
void save_pir_parameters(const PirParams &pir_params, const string &filename) { try { ofstream file(filename, std::ios::binary); if (file.is_open()) { // Serialize the PirParams structure to the file file.write(reinterpret_cast<const char*>(&pir_params), sizeof(PirParams)); file.close(); cout << "PirParams saved to " << filename << endl; } else { cerr << "Error: Unable to open file for writing." << endl; } } catch (const exception &e) { cerr << "Exception: " << e.what() << endl; } }
PirParams load_pir_parameters(const string &filename) { PirParams pir_params;
try {
ifstream file(filename, std::ios::binary);
if (file.is_open()) {
// Deserialize the PirParams structure from the file
file.read(reinterpret_cast<char*>(&pir_params), sizeof(PirParams));
file.close();
cout << "PirParams loaded from " << filename << endl;
} else {
cerr << "Error: Unable to open file for reading." << endl;
}
} catch (const exception &e) {
cerr << "Exception: " << e.what() << endl;
}
return pir_params;
}
How can we store and reuse Enc_Parameters and PIR_Parameters? Because if we execute another time, the Enc_Parameters and PIR_Parameters will change. And we cannot decode previous replies anymore.