multiply_matrix
Engine.multiply_matrix(matrix, ciphertext, rotation_key)- Returns the product of a matrix with a ciphertext. Consumes a level.
- Input:
- matrix: A Python list or numpy array. Data types supported include int, double, and complex double.
- The matrix should be a
Engine.slot_countbyEngine.slot_countmatrix.
- The matrix should be a
- Ciphertext
- Rotation key
- matrix: A Python list or numpy array. Data types supported include int, double, and complex double.
- Output:
- Ciphertext
Examples
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)- Returns the prodcut of a plain matrix with a ciphertext. Consumes a level. This function is not supported in multiparty computation.
- Input:
- PlainMatrix
- Ciphertext
- MatrixMultiplicationKey
- Output:
- Ciphertext
Examples
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., ...]