# What is the differences among firstModSize, scalingModSize and scalingFactor?

**URL:** <https://openfhe.discourse.group/t/what-is-the-differences-among-firstmodsize-scalingmodsize-and-scalingfactor/344>\
**Category:** Library Questions\
**Tags:** feature-requests, questions\
**Created:** [February 8, 2023, 8:44am UTC](https://openfhe.discourse.group/t/what-is-the-differences-among-firstmodsize-scalingmodsize-and-scalingfactor/344 "2023-02-08T08:44:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![lance](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lance](https://openfhe.discourse.group/u/lance)\
**Post date:** [February 8, 2023, 8:44am UTC](https://openfhe.discourse.group/t/what-is-the-differences-among-firstmodsize-scalingmodsize-and-scalingfactor/344/1 "2023-02-08T08:44:01Z")

</div>

In CKKS, I am confused by the three parameters that `firstModSize`, `scalingModSize` and `scalingFactor`.  
In my view, the `scalingFactor` probably is the logp in CKKS scheme, but what is the means of `firstModSize`, `scalingModSize`?

---

<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 8, 2023, 4:27pm UTC](https://openfhe.discourse.group/t/what-is-the-differences-among-firstmodsize-scalingmodsize-and-scalingfactor/344/2 "2023-02-08T16:27:21Z")

</div>

A bit of background information before answering your question.  
In CKKS, the ciphertext coefficient modulus at level l is Q\_l=q\_0 \cdot q\_1 \ldots \cdot q\_l, where q\_i's are prime integers of almost equal size.

`firstModSize` denotes the size of q\_0, a special modulus used to contain the actual payload information (your encrypted data).

`scalingModSize` denotes the size of the `scalingFactor` to control the underlying precision of the computation. In CKKS, input real data are scaled by the `scalingFactor` before getting encoded and encrypted.

---

<div class="post-metadata">

**Author:** ![lance](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@lance](https://openfhe.discourse.group/u/lance)\
**Post date:** [February 10, 2023, 3:08am UTC](https://openfhe.discourse.group/t/what-is-the-differences-among-firstmodsize-scalingmodsize-and-scalingfactor/344/3 "2023-02-10T03:08:18Z")

</div>

Thank you for your help, and I have another question.

In my konwledge, ciphertext coefficient modulus at level L is Q\_L = q\_0\*q^L, in which q^L is the scaling factor.

1. I detect in OpenFHE the firstModSize is a constant 60, when scalingModSize = 50, the scalingFactor = 2^{62}, I wannd **how to calculate the scalingFactor**? 🤔

2. According to your word, could I understand that, when L=1, q can be denoted as q= scalingFactor = 2^ { scalingModSize}, and q\_0 = 2^{ firstModSize}? 🤔

3. Additionally, is the scalingModSize also the bits of precision for the decimal part? If so, what is the bits of precision for the integer part? 🤔

Danke!

---

<div class="post-metadata">

**Author:** ![mmazz](https://avatars.discourse-cdn.com/v4/letter/m/50afbb/32.png) [@mmazz](https://openfhe.discourse.group/u/mmazz)\
**Post date:** [December 14, 2023, 7:54pm UTC](https://openfhe.discourse.group/t/what-is-the-differences-among-firstmodsize-scalingmodsize-and-scalingfactor/344/4 "2023-12-14T19:54:17Z")

</div>

Probably a little bit late, but I think that you are missing the RNS implementation.  
The way you describe is before that.

You can check a little bit here [A Full RNS Variant of Approximate Homomorphic Encryption](https://eprint.iacr.org/2018/931.pdf)
