Modulus switching in openfhe-python

Hello,

I have a question about the modulus switching in CKKS, and I’m using openFHE-python.

To add two ciphertexts that have different levels (e.g., level L and L-1), I’d like to reduce only the level L to L-1. But ModReduce and Rescale not only reduce the level but also divide the ciphertext by a scaling factor.

For example,

Let mes = [1, 2, 3, …] be a message vector, and I performed EvelNegate and ModReduce with the vector. Then, the result is [(-2.621235345677497e-14+0j), (-1.5490541299598393e-13+0j), (5.694239059418031e-14+0j), …]. The values are near 0. For reference, I’m using FIXEDMANUAL mode.

Could you let me know how I can match two different levels before operations? I want to reduce only the level.

Note that your question is about level reduction, rather than modulus switching. Modulus switching in CKKS is rescaling. In BGV/BFV, modulus switching scales down the noise while in CKKS is scales down both the message and noise.

In the FIXEDMANUAL mode OpenFHE often automatically calls level reduction. If you want to do it manually, I suggest reading How can i do levelreduce explicitly while using flexibleauto mode Basically you can call the LevelReduceInPlace method of CryptoContext for this.

1 Like