HElib
HElib copied to clipboard
Write Context to stringstream and readfrom stringstream but the generated seckey cannot be used in decryption
Hi, I have a question, when I generate a new context by reading from stringstream, these two context should be equal. But if I encrypt the vector using the oldContext.publickey, then decrypt it using the newContext.seckey. It failed due to different context. @dubek @fionser @faberga Could you give me some suggestions?
context.writeTo(ss);
Context newContext = Context::readFrom(ss);
SecKey secret_key(newContext);
secret_key.GenSecKey();
addSome1DMatrices(secret_key);
const PubKey& public_key = secret_key;
const helib::EncryptedArray& newEa = newContext.getEA();
vector<long> inputtest(256);
for (long i = 0; i< 256; i++) {
inputtest[i] = i;
}
cout << inputtest << endl;
Ctxt inputCtxt(meta.data->publicKey);
ea.encrypt(inputCtxt, meta.data->publicKey, inputtest);
vector<long> outputtest1;
newEa.decrypt(inputCtxt, secret_key, outputtest1); // error: cannot decrypt due to different context