Closed laek3 closed 5 years ago
Resurfacing this issue. We are seeing the same problem on multiple experiments with different numbers (but the same parameters): the first 3 locations of the output vector are less numerically accurate than the others.
Looking into it.
Previously I was suffering with the same problem and I figure out that this is from moduls switching process. When this process do "flooring" (n instead of "rounding"), this makes positive error to all coefficient. If you see the decoding from polynomial to vector of double variable, it is corresponding to multiplying some matrix. From the property of this matrix, positive error becomes larger especially for the first element of vector.
@HanKyoohyung Thanks, Kay. We also have narrowed it down to "flooring". I still can't be sure why this happens. Have you tried to implement "rounding"? Does the problem go away? If we raise the root of unity to its 3rd power, encoding/decoding should still be correct, does the more affected slots rotate?
When I change from floor to round, this problem was solved.
It is quite hard to explain the reason in text, but following is brief explaination.
The decode is evalute roots in complex field. In case of the first slot, decode evaluate w = exp(2pi / M) for M = 2 × degree. When the polynomial is f(x) = Sum f_i x^i, f(w) is Sum f_i w^i. Here we only use w^i for i < degree, so all imag part is w^i is positive. This means that 1st slot can be larger than other when f_i > 0 for all i.
In addition, raising the root of unity to its 3rd power those not help to solve the problem. Always decode will use exp(2pi/M) in some place.
@HanKyoohyung I have also switched to rounding. The error is vastly improved rather than eliminated. Rounding still introduces a very little bias: [0, (p-1)/2] are rounded to 0, [(p+1)/2, p-1] are rounded to 1. The set rounded to 1 has one less element. I guess this is the best we can do now. Thank you for the help!
@lae3C069 @yaronf Internally the error is fixed. We will run more tests and release the fix soon in 3.3.2. This does not affect security, which is a relief. Thank you very much for the "scrutiny". It is extremely valuable. I'll close the issue now.
Regarding the use of CKKS without batching, I was wondering why I observe different accuracy along the output vector. I noticed on multiple examples that the first 3 or 4 values of the vector have less accuracy compared to the following ones. Here is one example showing this behavior, I have as input 98.123456789, and I simply encrypt then decrypt it.
This is the output I get: