Closed jayavanth closed 5 years ago
You can treat a 1-slot ciphertext ctxt(x) as a ciphertext ctxt(x,x,x,.....,x) with n slots, where n is power-of-two.
If you have for example 4-slot ciphertext ctxt(x,y,z,t), you can treat it as a ciphertext ctxt(x,y,z,t,x,y,z,t,...,x,y,z,t), with n slots, where n>=4 is power-of-two
Thanks, @kimandrik. Is it possible to do the same with leftShift
s and add
instead of the last two steps?
Also, how does multiplying a ciphertext by plaintext work? Is it a multByConst
?
You mean multiply ctxt(x_1,x_1,...,x_1,x_1) by ptxt(0,0,...,0,1) to obtain ctxt(0,0,...,0,x_1), then left rotate it to obtain ctxt(0,0,...,0,x_1,0), then multiply ctxt(x_2,x_2,...,x_2,x_2) by ptxt(0,0,...,0,1) to obtain ctxt(0,0,...,0,x_2), add it to ctxt(0,0,...,0,x_1,0) to obtain ctxt(0,0,...,0,x_1,x_2), then left rotate it to obtain ctxt(0,0,...,0,x_1,x_2,0), etc? This takes n multiplications by constant and n leftrotations. Multiplication by constant is much faster than left rotation, so the first method should be much faster.
How to multiply for example by (1,0,0,...,0): 1) in one of the latest commit we added a method
multByConstVec(Ciphertext& res, Ciphertext& cipher, complex
Ah sweet, that makes sense. Thanks!
Suppose you have n 1-slot ciphertexts: ctxt_1(x_1), ..., ctxt_n(x_n).
You can create n different plaintexts: ptxt_1(1,0,0,....,0), ptxt_2(0,1,0,0,....,0), ptxt_3(0,0,1,0,0,....,0), ..., ptxt_n(0,0,...,0,0,1) each encoding a vector of size n (suppose n is a power of two, otherwise take 1<< ceil(logn) ) with all 0 except single 1.
Now you can multiply each of ctxt_i(x_i) by ptxt_i. The result is a ciphertext ctxt(0,0,...,x_i,...,0).
Then you can add them all together.