About the plaintextModulus and packing method choice

For BGV or BFG scheme,
In library examples, the plaintextModulus was set as 65537 or 2.
I was trying to set different plaintextModulus such as some prime near 2^4, 2^6 , 2^{20}, but that will lead to a fail while doing the MakePackedPlaintext,

p = 61
m = 16384
log2 q = 180
KenGen Finished
terminate called after throwing an instance of 'lbcrypto::math_error'
  what():  /home/aluji/openfhe-development/src/core/lib/math/nbtheory.cpp:294 Please provide a primeModulus(q) and a cyclotomic number(m) satisfying the condition: (q-1)/m is an integer. The values of primeModulus = 61 and m = 16384 do not satisfy this condition
Aborted (core dumped)

I tried to fix it by setRingDim but small RingDim seems also not acceptable.

I can only use MakeCoefPackedPlaintext if I need to use small or extra large plaintextModulus for now, but MakeCoefPackedPlaintext can not support SIMD mult (maybe it can, I just also don’t know how) which makes it slow.

So I’m asking about the parameter choice, extremely about plaintextModulus and packing method.
I read the Standard – Homomorphic Encryption Standardization but it only emphasis on n and ciphertext modulus.


The plaintext modulus needs to be 1 modulo the ring dimension. You can use SetRingDim if you also use SetSecurityLevel(HEStd_NotSet), but note that this lowers the security level and should never be used in production code.

notice 65537 is 2^16+1