weighted_sum
Engine.weighted_sum(ciphertexts, weights)
- 주어진 암호문의 배열과 가중 계수들을 이용하여 가중 합(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:
list[Ciphertext]
- weights:
list[int] | list[float]
- 아웃풋:
from desilofhe 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)
ciphertexts = [ciphertext1, ciphertext2]
weights = [7, 8, 9]
weighted_sum = engine.weighted_sum(ciphertexts, weights)