subtract
Engine.subtract(x, y)
- 두 인자를 뺀 암호문을 반환합니다.
- 인풋:
- x: int, double, complex double, array_like, Plaintext, or Ciphertext
- y: int, double, complex double, array_like, Plaintext, or Ciphertext
- 인자가 scalar이면 나머지 인자의 모든 값에 같은 값이 더해집니다.
- 인풋 둘 중 하나는 Ciphertext여야 합니다.
- 아웃풋:
- Ciphertext
예시
암호문 간 뺄셈
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
message1 = [1, 2, 3]
ciphertext1 = engine.encrypt(message1, public_key)
message2 = [4, 5, 6]
ciphertext2 = engine.encrypt(message2, public_key)
subtracted = engine.subtract(ciphertext1, ciphertext2)
암호문과 리스트의 뺄셈
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
message1 = [1, 2, 3]
ciphertext1 = engine.encrypt(message1, public_key)
message2 = [4, 5, 6]
ciphertext2 = engine.encrypt(message2, public_key)
subtracted1 = engine.subtract(ciphertext1, message2)
subtracted2 = engine.subtract(message1, ciphertext2)
암호문과 상수의 뺄셈
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)
subtracted1 = engine.subtract(ciphertext, 2)
subtracted2 = engine.subtract(2, ciphertext)
암호문과 평문간 뺄셈
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
message1 = [1, 2, 3]
plaintext1 = engine.encode(message1)
ciphertext1 = engine.encrypt(plaintext1, public_key)
message2 = [4, 5, 6]
plaintext2 = engine.encode(message2)
ciphertext2 = engine.encrypt(plaintext2, public_key)
subtracted1 = engine.subtract(ciphertext1, plaintext2)
subtracted2 = engine.subtract(plaintext1, ciphertext2)