How can I save the private key with the context when serializing it?
wzjin2017 opened this issue · 1 comments
wzjin2017 commented
Question
How can I save the private key with the context when serializing it?
Further Information
Error when decrypting using deserialized context says :
ValueError: the current context of the tensor doesn't hold a secret_key, please provide one as argument
From this, it states the old version saves the secret key with the context by default, but the new version seems to drop the secret key by default now. So how can I save the private key with the context or how can I save and load the private in general?
Reproduce
This is how I create and serialize my context:
context = ts.context(ts.SCHEME_TYPE.CKKS, 8192, coeff_mod_bit_sizes=[60, 40, 40, 60])
context.global_scale = pow(2, 52)
context.generate_galois_keys()
with open('context.pickle', 'wb') as handle:
pickle.dump(context.serialize(), handle, protocol=pickle.HIGHEST_PROTOCOL)
wzjin2017 commented
Found this example, the fix is to add this argument in serialize:
context.serialize(save_secret_key=True)
It would be nice to update this instruction in the tutorial examples. Thanks!