Skip to content
This repository was archived by the owner on Aug 5, 2024. It is now read-only.
This repository was archived by the owner on Aug 5, 2024. It is now read-only.

Question about sending BinaryIO of context and pubKey to another party #175

@DylanWangWQF

Description

@DylanWangWQF

Hi, @boland25 @deanthomasson .
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.
Could you give me some suggestions?

context.writeTo(ss);
Context newContext = Context::readFrom(ss);
cout << "Context isEqual: " << (newContext == meta.data->context) << endl; // result:1

SecKey secret_key(newContext);
secret_key.GenSecKey();
addSome1DMatrices(secret_key);
const PubKey& public_key = secret_key;
const helib::EncryptedArray& newEa = newContext.getEA();

cout << "PublicKey isEqual: " << (public_key == meta.data->publicKey) << endl; // result:0

vector<long> inputtest(256);
    for (long i = 0; i< 256; i++) {
        inputtest[i] = i;
    }
    
// oldContext.publicKey
Ctxt inputCtxt(meta.data->publicKey);
ea.encrypt(inputCtxt, meta.data->publicKey, inputtest);

//newContext.seckey
vector<long> outputtest1;
newEa.decrypt(inputCtxt, secret_key, outputtest1); // error: cannot decrypt due to different context

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions