I want to write a program that consists of n messages (such as [1,2,3,4,5,6,7,8]), starting with CKKS ciphertext, then converting to FHEW ciphertext, extracting the intervals between these n messages to half their original size (resulting in [1,3,5,7]), and then converting this ciphertext to CKKS ciphertext. How should I write this program? Can you give me an example?
Hi, could you please explain what you mean by extracting the intervals? If you simply want to obtain [x0, x2, x4, x6] from [x0, x1, x2, x3, x4, x5, x6, x7], you don’t need conversion to FHEW, but you can just use multiplicative masking and rotations in CKKS, which is cheaper than a conversion CKKS to FHEW and a conversion FHEW to CKKS.
I do want to get [x0, x2, x4, x4, x6, x7]
from [x0, x1, x2, x2, x3, x4, x7]
, but I don’t know how to get it by rotating and masking operations. At the same time, I would like to know how to change from CKKS to FHEW, and then change FHEW to CKKS after some simple calculations. Can you write the code for each of these two issues? Thank you very much.
I can tell you the ideas and you can implement them yourself to deepen your understanding.

You can convert the CKKS ciphertext encrypting a vector of values to a vector of FHEW ciphertexts, each encrypting a single value, via EvalCKKStoFHEW. From the obtained vector of FHEW ciphertexts, you extract the elements you care about (the first, third, fifth etc or any elements you need) and create a vector of FHEW ciphertexts with them. You then feed this new vector to EvalFHEWtoCKKS, specifying as the second parameter the total number of elements you wanted to retrieve.

The simplest way to do it (which works well if you don’t want to retrieve too many elements) is to create a plaintext onehot mask for each element you want to retrieve: e_0 = \left[ 1, 0, 0, 0, \ldots\right], e_2 = \left[ 0, 0, 1, 0, \ldots\right], etc, then multiply, rotate and sum to get the final CKKS ciphertext:
\sum_{i = 0}^{n/2} \text{Rotate}(\text{ctxt} \cdot e_{2i}, i), where \text{Rotate}(\text{ctxt}, i) rotates ctxt to the left by i positions.