# Connection between PlaintextModulus and MultiplicativeDepth

**URL:** <https://openfhe.discourse.group/t/connection-between-plaintextmodulus-and-multiplicativedepth/912>\
**Category:** Library Questions\
**Tags:** questions, openfhe-help\
**Created:** [November 14, 2023, 11:12am UTC](https://openfhe.discourse.group/t/connection-between-plaintextmodulus-and-multiplicativedepth/912 "2023-11-14T11:12:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maximilian](https://avatars.discourse-cdn.com/v4/letter/m/d6d6ee/32.png) [@Maximilian](https://openfhe.discourse.group/u/Maximilian)\
**Post date:** [November 14, 2023, 11:12am UTC](https://openfhe.discourse.group/t/connection-between-plaintextmodulus-and-multiplicativedepth/912/1 "2023-11-14T11:12:18Z")

</div>

Hello,

My issue that choosing a higher MultiplicativeDepth will create an error,  
in the PlaintextModulus.

When setting the MultiplicativeDepth to 3 or 4 everything will compile fine.  
Between 5 and 9 i get the first error:

“terminate called after throwing an instance of ‘lbcrypto::math\_error’  
what(): /usr/local/include/openfhe/core/math/nbtheory-impl.h:191 Please provide a primeModulus(q) and a cyclotomic number(m) satisfying the condition: (q-1)/m is an integer. The values of primeModulus = 536903681 and m = 65536 do not satisfy this condition  
./run.sh: line 3: 4414 Aborted (core dumped) ./test and above ten i get the second of the following errors:”

Above 10 i get:  
“terminate called after throwing an instance of ‘lbcrypto::math\_error’  
what(): /usr/local/include/openfhe/core/math/nbtheory-impl.h:191 Please provide a primeModulus(q) and a cyclotomic number(m) satisfying the condition: (q-1)/m is an integer. The values of primeModulus = 536903681 and m = 131072 do not satisfy this condition  
./run.sh: line 3: 4448 Aborted”

For debugging i watched the pallisade webinar 3:  
[https://www.openfhe.org/portfolio-item/homomorphic-encryption-for-palisade-users-3/](https://www.openfhe.org/portfolio-item/homomorphic-encryption-for-palisade-users-3/)

Thank you in advance,  
Maximilian Krug

P.S.  
My current parameters are:

// Sample Program: Step 1 - Set CryptoContext  
CCParams parameters;  
parameters.SetMultiplicativeDepth(4);  
parameters.SetPlaintextModulus(536903681); //47030924089  
// should replace the modReduce() call after every evalMult() call  
parameters.SetScalingTechnique(FLEXIBLEAUTOEXT);

CryptoContext cryptoContext = GenCryptoContext(parameters);  
// Enable features that you wish to use  
cryptoContext-\>Enable(PKE);  
cryptoContext-\>Enable(KEYSWITCH);  
cryptoContext-\>Enable(LEVELEDSHE);

---

<div class="post-metadata">

**Author:** ![ypolyakov](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/ypolyakov/32/47_2.png) [@ypolyakov](https://openfhe.discourse.group/u/ypolyakov)\
**Post date:** [November 14, 2023, 10:19pm UTC](https://openfhe.discourse.group/t/connection-between-plaintextmodulus-and-multiplicativedepth/912/2 "2023-11-14T22:19:56Z")

</div>

The plaintext modulus t you are using dos not satisfy the constraint: t \bmod m =1

See [Automaticly find a good Plaintext Modulus - #2 by ypolyakov](https://openfhe.discourse.group/t/automaticly-find-a-good-plaintext-modulus/312/2) for the instructions on how to find a plaintext modulus.
