Hello together,
we are currently benchmarking different kinds of polynomial approximations and found some strange patterns in our data.
We are doing Chebyshev Evaluations with EvalChebyshevFunction and it works perfectly fine except for one certain degree. For degree 6 the results are off by a lot. At first we thought this was a problem with the parameters or that the degree is too low to obtain a good accuracy as mentioned in other posts. But this seems not to be the case since the values are reasonably precise for degree 5 and 7. Even when evaluating more and higher degrees, the problem only does not occur again. So only the sixth degree seems to have a problem.
The following is a MWE where the error occurs:
CCParams<CryptoContextCKKSRNS> parameters;
parameters.SetSecretKeyDist(UNIFORM_TERNARY);
parameters.SetSecurityLevel(lbcrypto::HEStd_128_classic);
parameters.SetMultiplicativeDepth(10);
parameters.SetScalingModSize(30);
parameters.SetBatchSize(8);
CryptoContext<DCRTPoly> cc = GenCryptoContext(parameters);
cc->Enable(PKE);
cc->Enable(FHE);
cc->Enable(LEVELEDSHE);
cc->Enable(ADVANCEDSHE);
auto keyPair = cc->KeyGen();
cc->EvalMultKeyGen(keyPair.secretKey);
vector<double> vals = {1,2,3,4,5,6,7,8};
Plaintext ptx = cc ->MakeCKKSPackedPlaintext(vals);
Ciphertext<DCRTPoly> c = cc ->Encrypt(keyPair.publicKey, ptx);
for(int i = 1; i<11; i++){
auto res = cc ->EvalChebyshevFunction([](double val) -> double{return std::sqrt(val);},c,1,8,i);
Plaintext out;
cc ->Decrypt(keyPair.secretKey, res, &out);
std::cout << out << std::endl;
}
We also tried different functions, not only the square root, but the problem occurred for all of them.
Is this a bug?