Open raghav198 opened 3 years ago
Hi @raghav198, I cannot seem to reproduce the helib::LogicError
using the code you have provided above.
Have you tried running it single threaded?
How are you populating the matrix mat
and vector vec
? Also how are you encrypting your data using the conventional encrypt and dummy encrypt?
You might want to look at using the function helib::innerProduct(ans, mat, rotations)
to perform your multiplication and summation at the end of your code. The API can be found in Ctxt.h
P.S. You might want to consider finding out the m
value produced by findM
and hard coding it so as to not call the function every time you run the program.
Hi @jlhcrawford,
It runs fine single threaded; for some reason the issue only appears when its multithreaded.
During testing I've just been using garbage data in mat
and vec
, but these are normally filled with 1s and 0s (plaintext space mod 2).
I encode mat
as follows:
std::vector<long> plain;
std::vector<helib::Ctxt> mat;
for (int i = 0; i < sz; i++) {
std::vector<long> diag = {1, 0, 1, 1, 1, 0, 1, 1, 0, 1};
diag.resize(ea->size());
NTL::ZZX pp;
ea->encode(pp, diag);
helib::Ctxt enc_diag(pk);
enc_diag.DummyEncrypt(pp);
mat.push_back(enc);
}
The vector vec
is simply
std::vector<long> plain_vec;
helib::Ctxt vec(pk);
ea->encrypt(vec, pk, plain_vec);
I've noticed that the error doesn't always show up, and also not always at the same iteration of the loop; the matrices I've been working with are ~100-150 columns wide, in case that changes things.
Also, thanks, I'll look into helib::innerProduct
; do you know if it does the multplications in parallel (multithreaded)?
@raghav198 @faberga hit this issue when using multithread
Hi,
I'm trying to write a matrix/vector multiplication where the vector is encrypted but the matrix is not, and I've been using
DummyEncrypt
on the matrix to achieve that, but I've been running into some errors. Using the matrix multiplication algorithm found in "Algorithms in HELib", the matrixA
is represented as astd::vector
of ciphertexts of the diagonals of the matrix, and each diagonal is multiplied by the corresponding rotation of the vectorb
. Since I haveA
s I need to multiply by the sameb
, I've been storing all the necessary rotations ofb
in a vector and then using them for each matrix. This works fine normally, but when the matrix isDummyEncrypt
ed and each diagonal is processed in a different thread (usingNTL_EXEC_INDEX
for multithreading) I get a fewWARNING: addPrimes called (2) in DoubleCRT::op
and then eventually anhelib::LogicError
that saysaddPrimes can only be called on a disjoint set
.I'm not sure what's causing this, since it doesn't always happen after the same number of steps, and only occurs when the matrix is DummyEncrypt'ed and the vector of rotations of
b
is accessed from multiple threads.DummyEncrypt usage:
Sample code:
What does this error mean? Am I using something incorrectly, or mistaken with what
DummyEncrypt
does?Thanks in advance!