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

how to seralize openfhe binfhecontext #129

Open bpradeep508 opened 2 months ago

bpradeep508 commented 2 months ago

from openfhe import * import pickle5 as pickle

Sample Program: Step 1: Set CryptoContext

cc = BinFHEContext() file_name = 'std1.pkl'

Writing the student object to a file using pickle

with open(file_name, 'wb') as file: pickle.dump(cc, file,protocol=pickle.HIGHEST_PROTOCOL) print(f'Object successfully saved to "{file_name}"')

arcturusannamalai commented 2 months ago

seems like we need to implement https://pybind11.readthedocs.io/en/latest/advanced/classes.html#pickling-support

arcturusannamalai commented 2 months ago

Could you explain @bpradeep508 why you need this feature ?

bpradeep508 commented 2 months ago

Distributed environment computation going on different nodes. So bininfhe context needed to be shared among the nodes for computation.

On Sun, 28 Apr, 2024, 1:05 am Muthu Annamalai (முத்து அண்ணாமலை), < @.***> wrote:

Could you explain @bpradeep508 https://github.com/bpradeep508 why you need this feature ?

— Reply to this email directly, view it on GitHub https://github.com/openfheorg/openfhe-python/issues/129#issuecomment-2081160829, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBYDJG22Z35EU3DSUGANADY7P4Z5AVCNFSM6AAAAABGQWU5ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGE3DAOBSHE . You are receiving this because you were mentioned.Message ID: @.***>

arcturusannamalai commented 2 months ago

Thanks. So you need to really specify what attributes of the FHE Context you need to serialize and thats enough to deserialize; how do you currently check the equality of the two FHE Context ? Maybe that is a good enough test to know if the ser-des approach is working or not. Please share it

bpradeep508 commented 2 months ago

how do you currently check the equality of the two FHE Context ? c ++ version already available. we need same for python binfhe context

On Sun, Apr 28, 2024 at 5:07 AM Muthu Annamalai (முத்து அண்ணாமலை) < @.***> wrote:

Thanks. So you need to really specify what attributes of the FHE Context you need to serialize and thats enough to deserialize; how do you currently check the equality of the two FHE Context ? Maybe that is a good enough test to know if the ser-des approach is working or not. Please share it

— Reply to this email directly, view it on GitHub https://github.com/openfheorg/openfhe-python/issues/129#issuecomment-2081249543, or unsubscribe https://github.com/notifications/unsubscribe-auth/ALBYDJEVANQACA6FDRK5UD3Y7QZERAVCNFSM6AAAAABGQWU5ZSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDAOBRGI2DSNJUGM . You are receiving this because you were mentioned.Message ID: @.***>

arcturusannamalai commented 2 months ago

currently equality is reflexive: a = a tautological

arcturusannamalai commented 2 months ago

the key members of binfhecontext are in form of a binary large object (BLOB) and need to be serialized/deserialized; this can't be done easily without more support from the upstream C++ API