# About the plaintextModulus and packing method choice

**URL:** <https://openfhe.discourse.group/t/about-the-plaintextmodulus-and-packing-method-choice/218>\
**Category:** Library Questions\
**Created:** [November 10, 2022, 6:16am UTC](https://openfhe.discourse.group/t/about-the-plaintextmodulus-and-packing-method-choice/218 "2022-11-10T06:16:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aluji](https://avatars.discourse-cdn.com/v4/letter/a/65b543/32.png) [@Aluji](https://openfhe.discourse.group/u/Aluji)\
**Post date:** [November 10, 2022, 6:16am UTC](https://openfhe.discourse.group/t/about-the-plaintextmodulus-and-packing-method-choice/218/1 "2022-11-10T06:16:29Z")

</div>

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`,

```auto
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](https://homomorphicencryption.org/standard/) but it only emphasis on `n` and ciphertext modulus.

Thanks!

---

<div class="post-metadata">

**Author:** ![saroja](https://avatars.discourse-cdn.com/v4/letter/s/eada6e/32.png) [@saroja](https://openfhe.discourse.group/u/saroja)\
**Post date:** [November 10, 2022, 3:00pm UTC](https://openfhe.discourse.group/t/about-the-plaintextmodulus-and-packing-method-choice/218/2 "2022-11-10T15:00:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![dcousins](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/dcousins/32/71_2.png) [@dcousins](https://openfhe.discourse.group/u/dcousins)\
**Post date:** [November 10, 2022, 6:30pm UTC](https://openfhe.discourse.group/t/about-the-plaintextmodulus-and-packing-method-choice/218/3 "2022-11-10T18:30:21Z")

</div>

notice 65537 is 2^16+1
