# CKKS modulus switching and scaling

**URL:** <https://openfhe.discourse.group/t/ckks-modulus-switching-and-scaling/307>\
**Category:** Library Questions\
**Created:** [January 18, 2023, 4:00am UTC](https://openfhe.discourse.group/t/ckks-modulus-switching-and-scaling/307 "2023-01-18T04:00:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hooman](https://avatars.discourse-cdn.com/v4/letter/h/aeb1de/32.png) [@hooman](https://openfhe.discourse.group/u/hooman)\
**Post date:** [January 18, 2023, 4:00am UTC](https://openfhe.discourse.group/t/ckks-modulus-switching-and-scaling/307/1 "2023-01-18T04:00:46Z")

</div>

Hi,

We are porting a CKKS code written for Microsoft SEAL to OpenFHE. In particular, we are following [this example](https://github.com/microsoft/SEAL/blob/206648d0e4634e5c61dcf9370676630268290b59/native/examples/5_ckks_basics.cpp) where the goal is to compute a polynomial function (PI_x^3 + 0.4_x + 1),

Our question is related to porting lines 200 to 286 of this SEAL code to OpenFHE. In particular we have two questions:

- Is the OpenFHE function SetScalingFactor() in ciphertext.h equivalent to the scale() function in SEAL? If not, Is there a way to change the scale of encrypted value in OpenFHE?

- Is there a way to do traditional CKKS modulus switching for plaintexts in OpenFHE?

Thank you

---

<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:** [January 21, 2023, 12:52am UTC](https://openfhe.discourse.group/t/ckks-modulus-switching-and-scaling/307/2 "2023-01-21T00:52:57Z")

</div>

Hi @hooman,

I am not too familiar with the API of SEAL, but I would recommend looking at the OpenFHE polynomial example at [openfhe-development/polynomial-evaluation.cpp at main · openfheorg/openfhe-development · GitHub](https://github.com/openfheorg/openfhe-development/blob/main/src/pke/examples/polynomial-evaluation.cpp)

By default, OpenFHE hides the CKKS complexity from the user and makes polynomial evaluation an easy task. The user does not need to know the internals of CKKS. Note OpenFHE will also automatically use the Paterson-Stockmeyer algorithm for larger-degree polynomials.

---

<div class="post-metadata">

**Author:** ![iquah](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/iquah/32/8_2.png) [@iquah](https://openfhe.discourse.group/u/iquah)\
**Post date:** [February 3, 2023, 2:38pm UTC](https://openfhe.discourse.group/t/ckks-modulus-switching-and-scaling/307/3 "2023-02-03T14:38:43Z")

</div>

@hooman

Has your question been resolved? If so please mark Yuriy’s answer as the solution. Thanks!
