subtract_pytorch_tensor

Engine.subtract_pytorch_tensor(x, y)
두 인자를 뺀 암호문을 반환합니다. 레벨을 소모하지 않습니다.
  • 인풋:
    • x: torch.Tensor 혹은 Ciphertext
    • y: torch.Tensor 혹은 Ciphertext
    • 만약 x가 Ciphertext라면 y는 반드시 PyTorch tensor여야 하며 그 반대의 경우도 마찬가지입니다.
  • 아웃풋:
    • Ciphertext
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]