# OpenFHE Parameters

**URL:** <https://openfhe.discourse.group/t/openfhe-parameters/1075>\
**Category:** Library Questions\
**Tags:** questions, openfhe-help\
**Created:** [February 13, 2024, 3:22pm UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075 "2024-02-13T15:22:51Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![santosjha](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@santosjha](https://openfhe.discourse.group/u/santosjha)\
**Post date:** [February 13, 2024, 3:22pm UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/1 "2024-02-13T15:22:51Z")

</div>

I am trying to find equivalent HELib parameters in the OpenFHE library. I have a hard time finding equivalents of the following parameters:

1. Cyclotomic polynomial - defines phi(m)

2. Hensel lifting (default = 1)

3. Number of bits in the modulus chain

4. Number of columns of the Key-Switching matrix (default = 2 or 3)etc.Any explanations and pointers are highly appreciated.

---

<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:** [February 13, 2024, 5:23pm UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/2 "2024-02-13T17:23:29Z")

</div>

Can you provide some context about what you are trying to achieve? I might be able to help you better.

Note that in OpenFHE, we ideally support power-of-2 cyclotomic rings, that is, the ring dimension N is a power of 2, hence, m = 2N. Non-power-of-2 cyclotomics are minimally supported and not advised to be used to instantiate any of the existing schemes in OpenFHE.

That being said, here are my answers to your questions:

1. You can set the ring dimension using `parameters.SetRingDim(N); // ` =\> m = 2N. We do not recommend setting this parameter manually, but if you choose to do that, you may want to set the security level to `HEStd_NotSet` via `parameters.SetSecurityLevel(HEStd_NotSet);`. Note this will disable security checks of the chosen parameters, use it at your own risk.
2. I do not think any of the existing encoding schemes support the plaintext modulus of the form P = p^r, with p being a prime. I am afraid there is no equivalent to this. Note, that you can modify OpenFHE and add an encoding scheme that supports prime-power plaintext modulus.
3. You can set the bit-size of certain primes in the moduli chain via `parameters.SetScalingModSize(bit_size);`
4. It is better to get an estimate of the extended ciphertext modulus size from HElib and use the same or close size in OpenFHE. We advise to use `parameters.SetKeySwitchTechnique(HYBRID);`, and you can control the size of the expanded ciphertext modulus via `parameters.SetNumLargeDigits(k); // k = 1, 2, 3, 4, 5 ... we recommend k = 3`. You will need to dig deep in OpenFHE to find the total size of the coefficient modulus. I suggest printing the evaluation/public keys to get a feeling of what the prime moduli chain looks like.

---

<div class="post-metadata">

**Author:** ![santosjha](https://avatars.discourse-cdn.com/v4/letter/s/58f4c7/32.png) [@santosjha](https://openfhe.discourse.group/u/santosjha)\
**Post date:** [February 13, 2024, 6:51pm UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/3 "2024-02-13T18:51:40Z")

</div>

Thank you for your insightful answers. My example application using openFHE is an overly simple key-value database. The key is in plaintext, and the value is an encrypted blob. Based on your answers, I assume I can proceed with the normal OpenFHE parameters stated in the examples, as it does several things behind the scenes.

---

<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, 12:11am UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/4 "2024-07-26T00:11:58Z")

</div>

@Caesar small question about ckks. How can i set CIPHERTEXT MODULUS q in ckks? and how can i see which q is used in implementation

---

<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 26, 2024, 1:44am UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/5 "2024-07-26T01:44:34Z")

</div>

You can use the function `print_moduli_chain` in this [post](https://openfhe.discourse.group/t/openfhe-ckks-chooses-modulus-chain-that-doesnt-guarantee-128-bits-of-security/405) to print all the prime factors of the extended ciphertext modulus QP in CKKS.

To control the size of the ciphertext modulus Q, you can try controling the multiplicative depth via `parameters.SetMultiplicativeDepth(d);` =\> increasing `d` will increase Q.

There are other ways to control P, but I assume you are not interested in that parameter.

---

<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, 10:58pm UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/6 "2024-07-26T22:58:50Z")

</div>

Can i not use cc-\>GetModulus().GetLengthForBase(2) for q?

---

<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:42pm UTC](https://openfhe.discourse.group/t/openfhe-parameters/1075/7 "2024-07-27T12:42:03Z")

</div>

Yes, this one should work too. But I like the method I referred to above because it prints all prime factors of QP.
