Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Write Context to stringstream and readfrom stringstream but the generated seckey cannot be used in decryption #450

Open
DylanWangWQF opened this issue Jun 24, 2021 · 0 comments

Comments

@DylanWangWQF
Copy link

DylanWangWQF commented Jun 24, 2021

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant