Guest User

Untitled

a guest
Apr 6th, 2016
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. If you have an initialized "FHEPubKey pk" you can save it to a file in the following way:
  2.  
  3. ofstream pkFile("pk.txt");
  4. if (pkFile.good())
  5. {
  6. pkFile << pk;
  7. pkFile.close();
  8. }
  9.  
  10. That's for saving he public key to a file. Now if you need to recover the key from the file you need to have an initialized "FHEPubKey" object.
  11.  
  12. FHEPubKey otherPK(context); // Where context is an initialized FHEContext object, and must be the same context (same parameters) used with the previous public key
  13. ifstream inPkFile("pk.txt");
  14. if (inPkFile.good())
  15. {
  16. inPkFile >> otherPK;
  17. inPkFile.close();
  18. }
  19.  
  20. Now you should have recovered the public key in otherPK.
  21.  
  22. I would like to mention that the method used for HElib to store/recover its data objects to/from files is not efficient in storage space nor is in execution time.
  23.  
  24. GNZL
Add Comment
Please, Sign In to add comment