ckksvector multiplied with identity matrix results in transparent ciphertext
Question
Is it a bug or intended behavior when I get a "result ciphertext is transparent" error when multiplying a ckksvector with a numpy identity matrix?
Further Information
When multiplying a ckksvector with a numpy identity matrix, I get the error "result ciphertext is transparent" which seems very strange to me, as the result should be the same ciphertext as before, right? Moreover, when I compute the dot product of the ciphertext and any identity matrix column, it works.
System Information
- OS: Windows
- Python 3.9.7, tenseal 0.3.8
- Conda 4.11.0
Code
import tenseal as ts
import numpy as np
# Create TenSEAL context
bits_scale = 32
context = ts.context(
ts.SCHEME_TYPE.CKKS,
poly_modulus_degree=16384,
coeff_mod_bit_sizes=[43] + [bits_scale]*11 + [43]
)
context.global_scale = 2**bits_scale
context.generate_galois_keys()
N = 100
x = np.random.rand(N)
eye = np.eye(N)
x_enc = ts.ckks_vector(context, x)
# this works
x_enc.dot(eye[:,0])
# this results in an error
x_enc @ eye
Ok, I figured out, TenSEAL uses the diagonal method to compute vector-matrix products. This means for the identity matrix that all vectors except the first one are zero, resulting in the transparent ciphertext error.
See here the corresponding code piece.
How can we solve this? In my opinion, the transparent ciphertext should be thrown for the resulting product, not for intermediate results.