roll

회전 키를 통한 회전

GLEngine.roll(ciphertext, rotation_key, shift, axis)
암호문을 지정된 축을 기준으로 주어진 shift 만큼 인덱스가 큰 방향으로 회전시켜서 반환합니다. 레벨을 소모하지 않습니다.
  • 인풋:
    • GLCiphertext
    • GLRotationKey
    • shift: int
    • axis: int
      • 0: batch 축을 따라 회전
      • 1: width 축을 따라 회전
      • 2: height 축을 따라 회전
  • 아웃풋:
    • GLCiphertext
import numpy as np

from desilofhe import GLEngine

engine = GLEngine()
secret_key = engine.create_secret_key()
rotation_key = engine.create_rotation_key(secret_key)

message = np.ones(engine.shape)
ciphertext = engine.encrypt(message, secret_key)
rotated_ciphertext = engine.roll(ciphertext, rotation_key, shift=1, axis=0)

Plaintext Rotation

GLEngine.roll(plaintext, shift, axis)
평문을 지정된 축을 기준으로 주어진 shift 만큼 인덱스가 큰 방향으로 회전시켜서 반환합니다.
  • 인풋:
    • GLPlaintext
    • shift: int
    • axis: int
      • 0: batch 축을 따라 회전
      • 1: width 축을 따라 회전
      • 2: height 축을 따라 회전
  • 아웃풋:
    • GLPlaintext
import numpy as np

from desilofhe import GLEngine

engine = GLEngine()

message = np.ones(engine.shape)
plaintext = engine.encode(message)
rotated_plaintext = engine.roll(plaintext, shift=1, axis=2)