BFV levelled mod_switch_to_next_inplace and specifying moduli

I am going through BFV API in openfhe and I have the following questions:

  1. Mod Switch to next in place: How can I mod switch a ciphertext from next level? I expect the behaviour to be similar to mod_switch_to_next_inplace in SEAL.
  2. Specify moduli array: How can I specify moduli array myself? For example something similar to CoeffModulus::Create(poly_modulus_degree, {40, 60, 60, 60}) in SEAL.


Hi @jmall,

I am not familiar with the API of SEAL. So I will answer your questions in a general way.

  1. mod_switch_to_next_in_place in BFV. In BFV, OpenFHE typically works with the same moduli throughout the computation (which is typical for BFV or any scale-invariant scheme). The only exception is the MultiplicationTechnique of HPSPOVERQLEVELED (see OpenFHE: Open-Source Fully Homomorphic Encryption Library for details). In BGV and CKKS, modulus switching/rescaling is supported by calling ModReduce or Rescale. If you need to modulus switching before decryption in BFV (to minimize communication costs), you should be able to use the Compress method.
  2. The same modulus is used for RNS limbs in BFV. If you are trying to optimize the ciphertext modulus, you can use SetScalingModSize to use a value different from the default 60. For instance, if you want to achieve 220 bits, you can set SetScalingModSize to 55.
1 Like