# Why is log Q so small

**URL:** <https://openfhe.discourse.group/t/why-is-log-q-so-small/1455>\
**Category:** Library Questions\
**Created:** [July 26, 2024, 11:14pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455 "2024-07-26T23:14:40Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JuriusStep](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JuriusStep](https://openfhe.discourse.group/u/JuriusStep)\
**Post date:** [July 26, 2024, 11:14pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455/1 "2024-07-26T23:14:40Z")

</div>

I set Ring Dimension to 32768 (in CKKS)  
And write code to get Q: cc-\>GetModulus().GetLengthForBase(2)  
I get loqQ:230  
Why is log Q so small

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [July 27, 2024, 12:46pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455/2 "2024-07-27T12:46:09Z")

</div>

How do you set the ring dimension? Manually? The ring dimension should be chosen by the library depending on other application parameters such as precision and multiplicative depth.

The multiplicative depth may be low, allowing for a smaller ciphertext coefficient modulus Q.

To help you better, please provide a full working example.

---

<div class="post-metadata">

**Author:** ![JuriusStep](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JuriusStep](https://openfhe.discourse.group/u/JuriusStep)\
**Post date:** [July 27, 2024, 1:07pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455/3 "2024-07-27T13:07:15Z")

</div>

How do you set the ring dimension? Manually?  
I am changing it to automatic now  
multDepth = 3, scaleModSize = 50; batchSize = 32;  
cc-\>GetRingDimension() show 16384 and cc-\>GetModulus().GetLengthForBase(2)=230  
If i change multDepth to 10, i get loqQ:580

If i change ring dimension manually, i get: cc-\>GetModulus().GetLengthForBase(2)=230 too

uint32\_t multDepth = 3;  
SecurityLevel sl = HEStd\_NotSet;  
parameters.SetSecurityLevel(sl);  
parameters.SetRingDim(32768);

Can i not change Ring Dimension, if i want to know cipher modulus?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [July 27, 2024, 1:22pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455/4 "2024-07-27T13:22:33Z")

</div>

In short, \log{}Q is small because the multiplicative depth is small.

I suggest you do not set the security level as `HEStd_NotSet` and not set the ring dimension manually because this will deteriorate the security level of your application unless you know what you are doing.

---

<div class="post-metadata">

**Author:** ![JuriusStep](https://avatars.discourse-cdn.com/v4/letter/j/ee59a6/32.png) [@JuriusStep](https://openfhe.discourse.group/u/JuriusStep)\
**Post date:** [July 27, 2024, 3:49pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455/5 "2024-07-27T15:49:02Z")

</div>

Last small Question  
i find this example([openfhe-development/src/pke/examples/SHE\_table.cpp at security-guidelines · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/security-guidelines/src/pke/examples/SHE_table.cpp#L187))  
i am confused about meaning of loq Q, log P, log PQ  
i thinked that loq Q is Ciphertext modulus  
but what is loq PQ?

---

<div class="post-metadata">

**Author:** ![Caesar](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/caesar/32/63_2.png) [@Caesar](https://openfhe.discourse.group/u/Caesar)\
**Post date:** [July 27, 2024, 7:55pm UTC](https://openfhe.discourse.group/t/why-is-log-q-so-small/1455/6 "2024-07-27T19:55:28Z")

</div>

P is an auxiliary modulus used in key switching. When considering the security analysis of the RLWE scheme, the ciphertext coefficient modulus is considered to be Q \cdot P, i.e., comprising both moduli. If you use OpenFHE as shown in the usage examples, you do not need to worry about these parameters; they will be set automatically by the library, optimized to achieve the application requirements and the desired security level.
