Problem with using EvalDivide together with EvalMult

We have a problem with using EvalDivide together with EvalMult. This problem is with the python version. When we try to compute (1/x) * y, where x and y are integers greater than or equal to 1, by first using EvalDivide and then EvalMult, we get the following error when trying to decrypt the result: “The decryption failed because the approximation error is too high. Check the parameters.” Which parameters are we supposed to check? We get this error even when we compute (1/1) * 1. The result of just EvalDivide can be decrypted without issue. If it is relevant we are also using multiparty encryption with 7 parties.

The crypto context uses the following parameters:

The parameters enabled using cryptocontext.Enable are:

  • PKE
  • KEYSWITCH
  • LEVELEDSHE
  • ADVANCEDSHE
  • MULTIPARTY

The arguments passed to EvalDivide, in addition to the ciphertext, are currently:

  • a: 1 – 10^4
  • b: 1 + 10^4
  • degree: 100

Could you please help us, thank you in advance :slight_smile:

Are you sure EvalDivide works fine without multiplication with that large range?!
Have you tried the single-party case?

Judging by the parameters provided, most likely the issue is in the huge range you supplied to the Chebyshev approximation. Try reducing the range [a,b].

Also, try increasing the multiplicative depth. Your computation requires at least 9 multiplications.
I would also try avoiding 0 both in the range and input data.

Please review the API documentation for EvalDivide (Template Class CryptoContextImpl — OpenFHE documentation), specifically the constraint for x. The value of a does not seem to satisfy the constraint (as it is negative). Moreover, the range is too large (as @Caesar pointed out).

Thank you for your reply. It helped but we still have some questions.

The parameters for the crypto context, except the multiplicative depth, remain unchanged from the original post. As do the enabled features.

Currently the implementation works for multiple values of x and y when the parameters are a = 1, b = 100, degree = 100 and multiplicative depth = 9.

It also works for the same a and b with multiplicative depth = 10 and degree = 134 but stops working when degree = 135, with the following error: “RuntimeError: ./openfhe-development/src/pke/lib/encoding/ckkspackedencoding.cpp:l.535:Decode(): The decryption failed because the approximation error is too high. Check the parameters.”. Is this because of the values for a and b or something else?

Also, the estimated precision for the result of EvalDivide is quite low, sometimes as low as 5 bits, do you have any recommendations for increasing it?

Thanks in advance for any help.

5 bits of precision implies the result becomes incorrect. Have you tried increasing the multiplicative depth to 11? If the average value is larger than 2^{60}/2^{50} (for your parameters), there may not be enough room for larger values (and an overflow happens).