add_pytorch_tensor
Engine.add_pytorch_tensor(x, y)- Returns a ciphertext that is the sum of a ciphertext and a PyTorch tensor. Does not consume any 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])
added = engine.add_pytorch_tensor(ciphertext, tensor) # [5, 7, 9]