roll
Rotation Key-Based Roll
GLEngine.roll(ciphertext, rotation_key, shift, axis)
- Roll the input ciphertext to the higher indices along a specified axis by the given
shift value.
Does not consume any level.
- Input:
- GLCiphertext
- GLRotationKey
- shift: int
- axis: int
- 0: roll along the batch dimension
- 1: roll along the width dimension
- 2: roll along the height dimension
- Output:
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)
- Rotates the input plaintext to the height indices along a specified axis by the given
shift value.
- Input:
- GLPlaintext
- shift: int
- axis: int
- 0: roll along the batch dimension
- 1: roll along the width dimension
- 2: roll along the height dimension
- Output:
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)