[go: nahoru, domu]

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

How to assign a constant (0 or 1) to a slot in the plaintext ? #79

Open
fya opened this issue Mar 9, 2016 · 8 comments
Open

How to assign a constant (0 or 1) to a slot in the plaintext ? #79

fya opened this issue Mar 9, 2016 · 8 comments

Comments

@fya
Copy link
fya commented Mar 9, 2016
     When using the code Test_General.cpp as a test ,I can only use P*.random() function to generate each plaintext in the vector<plaintextarray> .Is that able to assign the number (0 or 1) we wanted to each slot in the plaintext instead of getting them randomly ?How ?
@ssmiler
Copy link
ssmiler commented Mar 9, 2016

You can use the EncryptedArray::encrypt(Ctxt& ctxt, const FHEPubKey& pKey, const vector< long >& ptxt) method. Slot content is given by the third parameter ptxt.

@fya
Copy link
Author
fya commented Mar 9, 2016

Thanks for your reply. Would you mind giving an example to further explain how to realize this method? That will be grateful.

@ssmiler
Copy link
ssmiler commented Mar 9, 2016

In the context of Test_General.cpp something like this (replace line 130 with):

vector<long> content(nslots, 0); //all slots to 0
content[42] = 1; //42-th slot to 1
ea.encrypt(c1, publicKey, p1);

@fya
Copy link
Author
fya commented Mar 9, 2016

Whoo, that's great. Thanks again for your explanation.

@ssmiler
Copy link
ssmiler commented Mar 9, 2016

Welcome :)

@fya
Copy link
Author
fya commented Mar 10, 2016

I don't know how this affect p1. I've tested those codes. The result is that p1 wasn't changed. In my project, I want p1 in the class plaintextarray but long for the further computation.

@ssmiler
Copy link
ssmiler commented Mar 11, 2016

Sorry, it was a typo. The last line must be:
ea.encrypt(c1, publicKey, content);

@fya
Copy link
Author
fya commented Mar 13, 2016

Well, the data type in the vector was still 'long'. However, I wanted it to be 'plaintextarray'. Is there any treatment I can do?

victorshoup pushed a commit to victorshoup/HElib that referenced this issue Jun 17, 2019
* Removed #warning from fft.cpp

* Fixed armadillo enabled cmake status message
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

2 participants