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

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:

[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:

[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!

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).
1 Like