Adding and subtracting ciphertexts
Adding or subtracting LWE ciphertexts together is a leveled operation that increases noise and potentially consumer padding and modify the encoding. It is one of the fundamental FHE operation.
Adding LWE ciphertexts
The common way to add ciphertexts is to consume bits of padding and update the interval of their respective encoders. This can be achieved using the short form method add
(or add_inplace
) which simply takes another ciphertext as argument. This is an alias for the more verbose add_with_padding
(or add_with_padding_inplace
).
Homomorphic subtraction works exactly the same as addition, using the sub_with_padding
(or sub_with_padding_inplace
) methods.
Here is a code example:
And in vectorized form:
Adding LWE ciphertexts without consuming padding
If the interval of the output of the homomorphic addition is known, it is possible to add ciphertexts without consuming padding. To do so, you can use the add_with_new_min
(or add_with_new_min_inplace
) method that takes as arguments the ciphertext to add and the minimum new_min
of the interval of the result.
If the result of the homomorphic addition is outside of the specified range, the behavior is undefined and the result most likely to be incorrect.
Subtracting ciphertexts without consuming padding is not yet implemented in Concrete.
Here is a code example:
Last updated