# How to transform a ciphertext from one slot count to another without decryption

**URL:** <https://openfhe.discourse.group/t/how-to-transform-a-ciphertext-from-one-slot-count-to-another-without-decryption/2097>\
**Category:** FHE Questions\
**Tags:** questions\
**Created:** [July 15, 2025, 7:15am UTC](https://openfhe.discourse.group/t/how-to-transform-a-ciphertext-from-one-slot-count-to-another-without-decryption/2097 "2025-07-15T07:15:37Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![haohaohao](https://yyz1.discourse-cdn.com/flex031/user_avatar/openfhe.discourse.group/haohaohao/32/400_2.png) [@haohaohao](https://openfhe.discourse.group/u/haohaohao)\
**Post date:** [July 15, 2025, 7:15am UTC](https://openfhe.discourse.group/t/how-to-transform-a-ciphertext-from-one-slot-count-to-another-without-decryption/2097/1 "2025-07-15T07:15:37Z")

</div>

Hello everyone!

I’m working on a problem where I need to transform a ciphertext’s effective slot count without decrypting and re-encrypting.

**Context:** I have a ciphertext with `numSlots = 8` containing the plaintext:

```auto
[0.11, 0.12, 0.13, 0.14, 0.21, 0.22, 0.23, 0.24]

```

After using `rotate` and `EvalAdd` operations to compute partial sums, I get a new ciphertext with plaintext:

```auto
[0.5, x, x, x, 0.9, x, x, x]

```

where `x` represents values I don’t care about (they’re actually different values, but I’m using `x` for simplicity).

**My Question:** Since I only need the sum results (0.5 and 0.9), I’d like to treat this as a ciphertext with `numSlots = 2` containing `[0.5, 0.9]`.

Is there a way to transform this ciphertext to actually have `numSlots = 2` without decrypting and re-encrypting? This would help optimize subsequent operations that only need to work with these two values.

Thank you in advance for any suggestions!

---

<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 19, 2025, 5:37pm UTC](https://openfhe.discourse.group/t/how-to-transform-a-ciphertext-from-one-slot-count-to-another-without-decryption/2097/2 "2025-07-19T17:37:14Z")

</div>

If you are referring to transforming a ciphertext with 8 slots (sparsely packed ciphertext), then you can transform it to a ciphertext with 2 slots via the operations of rotation and multiplication by a binary mask. A sparsely packed ciphertext corresponds to a subring of Z\_q(X)/(X^{N}+1), i.e., Z\_q(X)/(X^{n}+1), where n is the number of slots. The way this sparse ciphertext is represented is by cloning a vector of n slots N/n times.

For your case, you could do the following:

1. Multiply by a binary mask [1,0,0,0,1,0,0,0].
2. Then add up the first four slots, e.g., using `EvalSum` (for batch size 4).
