rotate_batch
Fixed Rotation Key-Based Rotation
Engine.rotate_batch(ciphertext, fixed_rotation_keys)
- Rotates the input ciphertext to the right by the delta value specified in each of the fixed rotation key respectively.
For example, rotating
[1, 2, 3, 4]
by 1 results in [4, 1, 2, 3]
.
When rotating the same ciphertext by multiple values of delta, this function is more efficient than calling the rotate
function several times.
In general, does not consume any level.
A level is consumed only if the operation is not a multiparty computation and the ciphertext is at the maximum allowable level for a given parameter.
- Input:
- Ciphertext
- FixedRotationKey
- Output:
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
fixed_rotation_key_1 = engine.create_fixed_rotation_key(secret_key, delta=1)
fixed_rotation_key_2 = engine.create_fixed_rotation_key(secret_key, delta=2)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
fixed_rotation_keys = [fixed_rotation_key_1, fixed_rotation_key_2]
rotated_ciphertexts = engine.rotate_batch(ciphertext, fixed_rotation_keys)
Rotation Key-Based Rotation
Engine.rotate_batch(ciphertext, rotation_key, deltas)
- Rotates the input ciphertext to the right by the specified delta value. For example, rotating
[1, 2, 3, 4]
by 1 results in [4, 1, 2, 3]
.
When rotating the same ciphertext by multiple values of delta, this function is more efficient than calling the rotate
function several times.
In general, does not consume any level.
A level is consumed only if the operation is not a multiparty computation and the ciphertext is at the maximum allowable level for a given parameter.
- Input:
- Ciphertext
- RotationKey
- delta: int
- Output:
from desilofhe import Engine
engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
rotation_key = engine.create_rotation_key(secret_key)
message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
rotated_ciphertexts = engine.rotate_batch(
ciphertext, rotation_key, deltas=[1, 2]
)