weighted_sum
Engine.weighted_sum(ciphertexts, weights)
- 주어진 암호문의 어레이와 가중 계수들을 이용하여 가중 합(weighted weighted_sum)을 계산합니다.
암호문의 어레이 \([x_1, x_2, \dots, x_n]\) 와 계수들 \([a_0, a_1, \dots, a_n]\) 에 대해, \(a_0 + a_1x_1 + a_2x_2 + \cdots + a_nx_n\) 를 계산합니다.
- 인풋:
- ciphertexts: Ciphertext의 어레이
- weights: int 혹은 double의 어레이
- 아웃풋:
from liberate import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
message1 = [1, 2, 3]
message2 = [4, 5, 6]
ciphertext1 = engine.encrypt(message1, public_key)
ciphertext2 = engine.encrypt(message2, public_key)
cipherexts = [ciphertext1, ciphertext2]
weights = [7, 8, 9]
weighted_sum = engine.weighted_sum(ciphertexts, weights)