subtract_pytorch_tensor
Engine.subtract_pytorch_tensor(x, y)
- Returns a ciphertext that represents the result of subtracting two inputs.
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:
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, 6, 8])
subtracted1 = engine.subtract_pytorch_tensor(ciphertext, tensor) # [-3, -4, -5]
subtracted2 = engine.subtract_pytorch_tensor(tensor, ciphertext) # [ 3, 4, 5]