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 or Ciphertext
- y: torch.Tensor or Ciphertext
- If x is a Ciphertext, y must be a PyTorch tensor and vice versa.
- 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]