multiply_matrix
Engine.multiply_matrix(matrix, ciphertext, rotation_key)- 행렬과 암호문을 곱한 암호문을 반환합니다. 레벨을 소모합니다.
- 인풋:
- matrix: 파이썬 리스트나 numpy 어레이만 받습니다. dtype은 int, double, complex double 모두 가능합니다.
- 행렬은
Engine.slot_count행Engine.slot_count열 이어야 합니다.
- 행렬은
- Ciphertext
- Rotation key
- matrix: 파이썬 리스트나 numpy 어레이만 받습니다. dtype은 int, double, complex double 모두 가능합니다.
- 아웃풋:
- Ciphertext
예시
import numpy as np
from desilofhe import Engine
engine = Engine(slot_count=64)
secret_key = engine.create_secret_key()
rotation_key = engine.create_rotation_key(secret_key)
matrix = np.arange(64 * 64).reshape(64, 64)
message = [2] * 64
ciphertext = engine.encrypt(message, secret_key)
multiplied = engine.multiply_matrix(
matrix, ciphertext, rotation_key
) # [4032., 12224., 20416., 28608., ...]
Engine.multiply_matrix(plain_matrix, ciphertext, matrix_multiplication_key)- 행렬 평문과 암호문을 곱한 암호문을 반환합니다. 레벨을 소모합니다. 다자간 연산의 경우 지원하지 않습니다.
- 인풋:
- PlainMatrix
- Ciphertext
- MatrixMultiplicationKey
- 아웃풋:
- Ciphertext
예시
import numpy as np
from desilofhe import Engine
engine = Engine(slot_count=64)
secret_key = engine.create_secret_key()
matrix_multiplication_key = engine.create_matrix_multiplication_key(secret_key)
matrix = np.arange(64 * 64).reshape(64, 64)
plain_matrix = engine.encode_to_plain_matrix(matrix)
message = [2] * 64
ciphertext = engine.encrypt(message, secret_key)
multiplied = engine.multiply_matrix(
plain_matrix, ciphertext, matrix_multiplication_key
) # [4032., 12224., 20416., 28608., ...]