add

GLEngine.add(x, y)
두 인자를 더한 암호문을 반환합니다. 레벨을 소모하지 않습니다.
  • 인풋:
    • x: double 혹은 complex double의 3차원 행렬, GLPlaintext, 혹은 GLCiphertext
    • y: double 혹은 complex double의 3차원 행렬, GLPlaintext, 혹은 GLCiphertext
    • 인풋 둘 중 하나는 암호문이어야 합니다.
  • 아웃풋:
    • GLCiphertext

Examples

암호문 간 덧셈

import numpy as np

from desilofhe import GLEngine

engine = GLEngine()
shape = engine.shape
secret_key = engine.create_secret_key()

message1 = np.ones(shape, dtype=np.float64)
ciphertext1 = engine.encrypt(message1, secret_key)

message2 = np.ones(shape, dtype=np.float64) * 2
ciphertext2 = engine.encrypt(message2, secret_key)

added = engine.add(ciphertext1, ciphertext2)

암호문과 3차원 행렬의 덧셈

import numpy as np

from desilofhe import GLEngine

engine = GLEngine()
shape = engine.shape
secret_key = engine.create_secret_key()

message1 = np.ones(shape, dtype=np.float64)
ciphertext1 = engine.encrypt(message1, secret_key)

message2 = np.ones(shape, dtype=np.float64) * 2
ciphertext2 = engine.encrypt(message2, secret_key)

added1 = engine.add(ciphertext1, message2)
added2 = engine.add(message1, ciphertext2)

암호문과 평문의 덧셈

import numpy as np

from desilofhe import GLEngine

engine = GLEngine()
shape = engine.shape
secret_key = engine.create_secret_key()

message1 = np.ones(shape, dtype=np.float64)
plaintext1 = engine.encode(message1)
ciphertext1 = engine.encrypt(plaintext1, secret_key)

message2 = np.ones(shape, dtype=np.float64) * 2
plaintext2 = engine.encode(message2)
ciphertext2 = engine.encrypt(plaintext2, secret_key)

added1 = engine.add(ciphertext1, plaintext2)
added2 = engine.add(plaintext1, ciphertext2)