Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ckksvector multiplied with identity matrix results in transparent ciphertext #398

Closed
MartinNoc opened this issue May 23, 2022 · 1 comment
Labels
Type: Question ❔ Question about implementation or some technical aspect

Comments

@MartinNoc
Copy link

MartinNoc commented May 23, 2022

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
@MartinNoc MartinNoc added the Type: Question ❔ Question about implementation or some technical aspect label May 23, 2022
@MartinNoc
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Question ❔ Question about implementation or some technical aspect
Projects
None yet
Development

No branches or pull requests

1 participant