# NTT operations in CKKS

Hi,

I am new to OpenFHE, and am trying to understand the use of NTT(CRT).

According to my understanding, the ciphertext polynomial ring elements are either in COEF form or EVAL form. When operations like EvalAdd() are done, the ciphertext is transformed to EVAL form by applying NTT(CRT), the operations are done, and then converted back to COEF. I might be wrong.

When I print the ciphertext to stdout, I get an output of form:

``````Element 0: 0: EVAL: [vector of numbers] modulus: number
1: EVAL: [vector of numbers] modulus: number
.
.
.
Element 1: 0: EVAL: [vector of numbers] modulus: number
1: EVAL: [vector of numbers] modulus: number
.
.
.
``````

So is this output in EVAL form (The form of the polynomial ring elements after NTT is applied)? Can I switch the form of the ciphertext (I know there is a SwitchFormat() function) to print the other form? Or are NTT operations separate from operations like EvalAdd()? I basically want to print the output of NTT operations on ciphertexts

IIRC in OpenFHE, we usually keep all ciphertext keys etc in Eval form. the only time we go back to Coef form is for decryption or rotation operations. otherwise we would be going back and forth all the time and that is not efficient.

the switchformat function will basically convert between the two forms. I believe you can also get the current setting of the format to check what format your ciphertext is in.

If you have a signals background you can think of NTT as an FFT: coef is the time domain, and eval is the frequency domain. we have NTT and inverse NTT. to go back and forth.
To simply things, you might want to set the problem up so you have no multiplicative depth. that will give you a small number of residues.

That makes sense. While I was digging into the NTT implementation, I found that a rootOfUnity table was used in many places, and from other posts, it seems to be the precomputed powers of a 2N-th root of unity modulo q. Is it possible to see the contents of the table (maybe by displaying it somewhere)?

Yes, it is a static map that you can print out in your C++ code. See `m_rootOfUnityReverseTableByModulus` in Program Listing for File transformnat.h — OpenFHE documentation The class is accessed as `ChineseRemainderTransformFTT<NativeVector>` in upper layers of OpenFHE. So you should be able to access `ChineseRemainderTransformFTT<NativeVector>::m_rootOfUnityReverseTableByModulus`. Note that we use bit-reversed NTT

Thank you! This worked