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 | 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, 6, 8])
subtracted1 = engine.subtract_pytorch_tensor(ciphertext, tensor) # [-3, -4, -5]
subtracted2 = engine.subtract_pytorch_tensor(tensor, ciphertext) # [ 3, 4, 5]