Closed pen9u1nlee closed 2 years ago
So, your problem comes from these two lignes:
var rn *ckks.Ciphertext = ckks.NewCiphertext(tc.params, 1<<tc.params.LogSlots(), tc.params.MaxLevel(), tc.params.DefaultScale()) // new(ckks.Ciphertext)
var grad *ckks.Ciphertext = ckks.NewCiphertext(tc.params, 1<<tc.params.LogSlots(), tc.params.MaxLevel(), tc.params.DefaultScale())
More specifically the 1<<tc.params.LogSlots()
part, which creates ciphertexts of degree 2^LogSlots.
The degree of the ciphertext is the number of polynomials forming the ciphertext. A ciphertext can be seen as a polynomial (of polynomials) with respect to the secret key, and the decryption is its evaluation at the point of the secret-key.
A plaintext is a ciphertext of degree zero : [m(x)], a fresh ciphertext is of degree one: [-as + m(x) + e, a], a ciphertext multiplied with an other ciphertext, before its relinearization, is of degree two; [-as - a^2s^2 + m(x)^2 + e, a, a^2], and so on.
So you should replace 1<<params.LogSlots()
by 1
if you are creating fresh ciphertexts.
This should make everything 4^Logslots times faster and use 2^LogSlots times less memory ;)
Thanks for your reply...Obviously I misused this library.
I thought the degree of newly generated ciphertext should be of degree 1 by default like PALISADE/SEAL, and I directly copied the code in the test.
Hello, I encounter a problem when I am using Add and Mul in CKKS. The code shown below is runnable for demonstrating the problem. I generate 3 ciphertexts (a, b and x) to compute
a*x + b
anda*x + b*x
.a*x + b
runs fluently, buta*x + b*x
takes up a plenty of time and memory (60+ GB or OOM killed), especially in the add after two multiplications. Also, when I do multiplea*x + b*x
s and sum them together (which is not shown here), it panics that receiver operand degree is too small. I noticed that there was a bug mentioned in issues which is about the ciphertext level of Mul&Relin. Perhaps this bug reborns, or it is because of my improper use of this library?