Hello,
I’ve looked at the serialization examples (focused on CKKS) and I see that the suggested approach to handle the context for a client-server application is to generate it in one of the parties which serializes it and sends it to the other party, which deserializes it to a fresh context.
Given the fact that the parameters of the FHE scheme are public, why do we need to send the context in the first place? Couldn’t we regenerated it when needed? Notice here that I’m only considering avoiding the serialization of CryptoContext, I know that the keys do need to be serialized and sent for everything to work properly.
I’m also wondering if this is even possible with OpenFHE, since I’ve run a small example which gives me the following error:
terminate called after throwing an instance of ‘lbcrypto::OpenFHEException’
what(): /usr/local/include/openfhe/pke/cryptocontext.h:l.317:TypeCheck(): Ciphertext was not created in this CryptoContext
For the small test, I’ve written this function which I use in both client and server side to generate the same CryptoContext object.
lbcrypto::CryptoContext<lbcrypto::DCRTPoly> InitializeCryptoContext(const ConfigLoader& configLoader) {
lbcrypto::CryptoContextFactory<lbcrypto::DCRTPoly>::ReleaseAllContexts();
lbcrypto::CCParams<lbcrypto::CryptoContextCKKSRNS> params;
params.SetMultiplicativeDepth(configLoader.GetMultDepth());
params.SetScalingModSize(configLoader.GetScaleMod());
params.SetFirstModSize(configLoader.GetFirstMod());
params.SetRingDim(configLoader.GetRingDimension());
params.SetSecurityLevel(lbcrypto::SecurityLevel::HEStd_128_classic);
params.SetScalingTechnique(lbcrypto::FIXEDAUTO);
auto cc = GenCryptoContext(params);
cc->Enable(lbcrypto::PKE);
cc->Enable(lbcrypto::KEYSWITCH);
cc->Enable(lbcrypto::LEVELEDSHE);
cc->Enable(lbcrypto::ADVANCEDSHE);
return cc;
}
Note: if I don’t call ReleaseAllContexts() everything works ok, since we are testing in a single machine.