# About CKKS Encoding Method: Gap Between the Original Paper and the Implementation

**URL:** <https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447>\
**Category:** Library Questions\
**Created:** [July 24, 2024, 11:18pm UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447 "2024-07-24T23:18:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![oksuman](https://avatars.discourse-cdn.com/v4/letter/o/6de8d8/32.png) [@oksuman](https://openfhe.discourse.group/u/oksuman)\
**Post date:** [July 24, 2024, 11:18pm UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447/1 "2024-07-24T23:18:39Z")

</div>

Hello.  
I have some questions about the encoding method in the CKKS scheme.  
I feel that there are some gaps between the original encoding mechanism and the OpenFHE implementations.  
Thus, I want to verify if my interpretation is correct and understand the reason for such implementations.

First, I am considering the following condition:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/dfb0f8becd3c7667dfc39cd08af536e6b174164a.png)

Then, my interpretation of the encoding implemented in the OpenFHE library (ckkspackedencoding.cpp) is as follows:

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/openfhe/original/1X/0e6dc54362d5d20666ed358662e2a9a4e7749b77.png)

Is my interpretation roughly correct?

In the original paper,  
I understood that the interpolation through inverse FFT uses not only the N/2 root of unity but also the N/2 conjugated root of unity.  
Based on my understanding of the implementation, wasn’t the original paper intending to make P(X) a 2N-1 degree polynomial instead of an N/2-1 degree polynomial?  
(It seems that the encoding implementations do not include the conjugated root of unity.)

My last question is about the reason for the implementation.  
Why should the imaginary parts of IFFT coefficients b\_l be used for generating P’(X)?

I have difficulty understanding the process of creating a polynomial with real coefficients (not complex number) through the inverse FFT.

( Or is it just for tracking the precision? Without the need for calculating precision, can I generate P’(X) as an N/2-1 degree polynomial with integer coefficients?)

Thank you for reading.

---

<div class="post-metadata">

**Author:** ![oksuman](https://avatars.discourse-cdn.com/v4/letter/o/6de8d8/32.png) [@oksuman](https://openfhe.discourse.group/u/oksuman)\
**Post date:** [July 25, 2024, 6:00am UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447/2 "2024-07-25T06:00:06Z")

</div>

Sorry. I think I now understand the implementation.  
(This is just the implementation of encoding using a special FFT.?)

---

<div class="post-metadata">

**Author:** ![narger](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/narger/32/420_2.png) [@narger](https://openfhe.discourse.group/u/narger)\
**Post date:** [July 25, 2024, 9:44am UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447/3 "2024-07-25T09:44:10Z")

</div>

I think the CKKS OpenFHE implementation is closer to [this paper](https://link.springer.com/chapter/10.1007/978-3-030-95312-6_6) than to the original one

---

<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:** [July 26, 2024, 2:28am UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447/4 "2024-07-26T02:28:13Z")

</div>

> [@oksuman](#):
>
> Is my interpretation roughly correct?

Yes

> [@oksuman](#):
>
> I have difficulty understanding the process of creating a polynomial with real coefficients (not complex number) through the inverse FFT.

The complex number vector obtained after FFTSpecialInv is mapped to a vector of real numbers (so they could be rounded to integers). The first half corresponds to real components of complex numbers. The second half corresponds to the imaginary components of complex numbers.

---

<div class="post-metadata">

**Author:** ![oksuman](https://avatars.discourse-cdn.com/v4/letter/o/6de8d8/32.png) [@oksuman](https://openfhe.discourse.group/u/oksuman)\
**Post date:** [August 1, 2024, 7:45am UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447/5 "2024-08-01T07:45:24Z")

</div>

Thank you for your reply!  
Are there any papers that discuss the BGV/BFV schemes implemented in OpenFHE too?

---

<div class="post-metadata">

**Author:** ![andreea.alexandru](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/andreea.alexandru/32/378_2.png) [@andreea.alexandru](https://openfhe.discourse.group/u/andreea.alexandru)\
**Post date:** [August 1, 2024, 5:11pm UTC](https://openfhe.discourse.group/t/about-ckks-encoding-method-gap-between-the-original-paper-and-the-implementation/1447/6 "2024-08-01T17:11:00Z")

</div>

Take a look at the OpenFHE paper [https://eprint.iacr.org/2022/915.pdf](https://eprint.iacr.org/2022/915.pdf) on pages 4 and 5, the references for the different procedures for BGV and BFV are given there.
