openfheorg / openfhe-python

Official Python wrapper for OpenFHE. Current release is v0.8.8 (released on June 25, 2024).
https://openfheorg.github.io/openfhe-python/html/index.html
BSD 2-Clause "Simplified" License
60 stars 18 forks source link

Add Serialize() Method for Direct Binary Data Handling #145

Open Rana-KV opened 3 weeks ago

Rana-KV commented 3 weeks ago

Issue: Currently, the Python wrapper for OpenFHE includes the SerializeToFile() method, which allows saving ciphertext or keys into a file. However, in many projects, it is often necessary to work with binary data directly in variables for uploading to a database or for other management purposes, rather than storing it in a file.

For instance, when storing encrypted data in a database, I encountered an issue where I had to first create a file to store the data, then read the file contents to get the data into a variable, and finally use the variable to upload to the database. This process introduces unnecessary overhead and complexity.

OpenFHE Python has the potential to be a part of many complex projects, and this limitation poses a significant setback for working on large-scale projects. The overhead can be completely avoided, and it would be much easier if we had a Serialize() method, similar to the one in the C++ OpenFHE project.

Potential Solution: Implement a Serialize() method in the OpenFHE Python wrapper that allows direct serialization of ciphertext or keys into a binary data variable.

By adding this feature, we can streamline workflows and enhance the usability of OpenFHE Python for large-scale projects.

Manhbui1208 commented 2 weeks ago

Hi @Rana-KV , have you try to modify the binding.cpp in openfhe-python to add the function Serialize() for only binary data. I used to face the issue same as you and I tried that way and it worked for me.

erik-3milabs commented 1 week ago

@Manhbui1208 could you create a PR for your code?

Thadah commented 1 week ago

I have an implementation that's working in serialization.cpp. I'll send a PR shortly.