Just wanted to know if it is possible for us to perform some operations on rotated ciphertexts such that only part of the ciphertext takes part in the operation and not the whole object. Let's say we want only the slot_count/2 part of the ct to take part in the operation and the latter slot_count/2 should be left as it is. Any ideas how to go about it? I am currently using the BFV scheme
Asked
Active
Viewed 242 times
2
-
Hi Nandini, and welcome to StackOverflow! You might want to mention which scheme (BFV/CKKS) you're using. – Alexander Sep 01 '21 at 22:58
-
Hey Alexander, thank you so much for the answer! I have edited my question. And am using the BFV scheme as of now – Nandini Malhotra Sep 02 '21 at 07:58
1 Answers
1
Since we can't really choose which slots will be rotated, the general way to achieve this is more of a workaround:
Given seal::Ciphertext x
, int steps
and appropriate evaluator/encoder and keys as in the Seal Rotation Example (including Explanations) we can do the following:
- make a copy of x
seal::Ciphertext copy = x;
- rotate the copy
evaluator.rotate_vector_inplace(copy, steps, galoisKeys);
(assuming you're using the CKKS scheme) - multiply with a mask (plaintext with 0 or 1 in the slots)
std::vector<unsigned long int> mask = {1,1,1,1,1,0,0,0,0 /*...*/};
seal::Plaintext mask_ptxt;
encoder.encode(mask, mask_ptxt);
evaluator.multiply_plain_inplace(copy, mask_ptxt);
- multiply the original with the inverse mask
std::vector<unsigned long int> inv_mask = {0,0,0,0,0,1,1,1,1 /*...*/};
seal::Plaintext inv_mask_ptxt;
encoder.encode(inv_mask , inv_mask_ptxt);
evaluator.multiply_plain_inplace(x, mask_ptxt);
- add the original and rotated ciphertext together
evaluator.add_inplace(x,copy);

Alexander
- 539
- 5
- 16