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.
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:
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:
The constraint however is that the ciphertexts need to be encoded in the same interval and with the same number of padding bits. The result of adding and will be encoded in the interval with one less bit of padding.
There are constraints when using this method, namely that the ciphertexts must be encoded in intervals of the same size, meaning and have the same precision. The interval of the output ciphertext will then be .
Operation
Type
Leveled
Side effects
Increases noise
Potentially consumes padding
Potentially modifies encoding