Automaticly find a good Plaintext Modulus

Currently, I am manually calculating or using the method below to find a plaintext modulus that is vaild and big enough for my needs (e.g., for chosen multiplicative depth).

FirstPrime(uint64_t nBits, uint64_t m);

By valid I mean a primeModulus(q) and a cyclotomic number(m) satisfying the condition: (q-1)/m is an integer.

Are there alternative ways for doing this?

No, this is the recommended approach. The plaintext modulus depends on the application. At a high level, the plaintext modulus should be large enough not to cause a wrap-around for the worst case of user application. I recommend watching Homomorphic Encryption for OpenFHE Users – OpenFHE.org for more details. Slide 15 is the one that describes the logic.

For m, you can use 131,072 to make sure it is compatible with any ring dimension.

2 Likes