multiply_pytorch_tensor_matrix

Engine.multiply_pytorch_tensor_matrix(tensor, ciphertext, rotation_key)
Returns the product of a Pytorch tensor matrix with a ciphertext. Consumes a level.
  • Input:
    • tensor: torch.Tensor
      • The tensor should be a Engine.slot_count by Engine.slot_count matrix.
    • Ciphertext
    • Rotation key
  • Output:
    • Ciphertext

Examples

import torch

from desilofhe import Engine

engine = Engine(slot_count=64)
secret_key = engine.create_secret_key()
rotation_key = engine.create_rotation_key(secret_key)

tensor = torch.arange(64 * 64).reshape(64, 64)

message = [2] * 64
ciphertext = engine.encrypt(message, secret_key)

multiplied = engine.multiply_pytorch_tensor_matrix(
    tensor, ciphertext, rotation_key
)  # [4032., 12224., 20416., 28608., ...]