SEAL-Python icon indicating copy to clipboard operation
SEAL-Python copied to clipboard

CKKS rotate_vector ValueError: encrypted size must be 2

Open xuxiaoda opened this issue 3 years ago • 1 comments

Type ValueError

Descripe

    I = np.array([1, 0, 0, 0, 1, 0, 0, 0, 1])
    plain_I = ckks_encoder.encode(I, scale)
    E_I = encryptor.encrypt(plain_I)
    A = np.array([1, 0, 0, 0, 1, 0, 0, 0, 1])
    plain_A = ckks_encoder.encode(A, scale)
    E_A = encryptor.encrypt(plain_A)
    print("E_A.size:")
    print(E_A.size())
    print("E_I.size:")
    print(E_I.size())

    E_mult=evaluator.multiply(E_A,E_I)
    print("E_mult.size:")
    print(E_mult.size())
    evaluator.rotate_vector(E_mult, 1, galois_keys)

First I have a ciphertext E_mult, which is the product of two ciphertexts E_A and E_I. Now I want to rotate the ciphertext E_mult, but such an error occurs. The size of E_A and E_I are both 2, but the size of E_mult is 3. Why does the rotate_vector function have to require the size of the ciphertext to be 2?

image

And how to change the encrypted size of E_mult? Or how to solve this problem?

The parameters are as follows. image

xuxiaoda avatar Aug 09 '22 04:08 xuxiaoda

This problem is solved by using the relinearize function, which can change the size of E_mult from 3 to 2.

xuxiaoda avatar Aug 09 '22 05:08 xuxiaoda