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
62 stars 18 forks source link

DeserializeCryptoContext (buffer) fails to create a proper CryptoContext object #157

Closed Thadah closed 3 weeks ago

Thadah commented 3 weeks ago

When using cc.Decrypt() after executing openfhe.DeserializeCryptoContextString(cc_bytes, openfhe.BINARY), I receive an error:

'tuple' object has no attribute 'Decrypt'

When trying to execute cc.KeyGen() after executing cc = openfhe.DeserializeCryptoContextString(cc_serial, openfhe.JSON), I receive another error:

/usr/local/include/openfhe/pke/cryptocontext.h:l.116:GetContextForPointer(): Cannot find context for the given pointer to CryptoContextImpl

I think the CryptoContext needs its own functio for buffer deserialization like it's done with DeserializeCCWrapper in the file deserialization for the generated CryptoContext to work properly:

template <typename ST>
std::tuple<CryptoContext<DCRTPoly>, bool> DeserializeCCWrapper(const std::string& filename, const ST& sertype) {
    CryptoContext<DCRTPoly> newob;
    bool result = Serial::DeserializeFromFile<DCRTPoly>(filename, newob, sertype);
    return std::make_tuple(newob, result);
}