multiply_pytorch_tensor
Engine.multiply_pytorch_tensor(x, y)- Returns the ciphertext resulting from the multiplication of a ciphertext and a PyTorch tensor. Consumes a level.
- Input:
- x:
torch.Tensor | Ciphertext - y:
torch.Tensor | Ciphertext xandymust be passed as positional arguments.- If x is a Ciphertext, y must be a PyTorch tensor and vice versa.
- x:
- Output:
Ciphertext
Warning
- The matrix form does not yet support this operation.
import torch
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
tensor = torch.tensor([4, 5, 6])
multiplied = engine.multiply_pytorch_tensor(ciphertext, tensor) # [4, 10, 18]