rotate_many
Fixed Rotation Key-Based Rotation
Engine.rotate_many(ciphertext, fixed_rotation_keys)- Rotates the input ciphertext to the left by the delta value specified in each of the fixed rotation key respectively.
For example, rotating
[1, 2, 3, 4]by 1 results in[2, 3, 4, 1]. When rotating the same ciphertext by multiple values of delta, this function is more efficient than calling therotatefunction several times. In general, does not consume any level. A level is consumed only if the engine is not configured for bootstrapping and the ciphertext is at the maximum allowable level for a given parameter.
- Input:
- Ciphertext
- FixedRotationKeys: list of FixedRotationKey
- Output:
- list of Ciphertext
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_many(ciphertext, fixed_rotation_keys)
Warning
- The matrix form does not support this operation.
Rotation Key-Based Rotation
Engine.rotate_many(ciphertext, rotation_key, deltas)- Rotates the input ciphertext to the left by the specified delta value. For example, rotating
[1, 2, 3, 4]by 1 results in[2, 3, 4, 1]. When rotating the same ciphertext by multiple values of delta, this function is more efficient than calling therotatefunction several times. In general, does not consume any level. A level is consumed only if the engine is not configured for bootstrapping and the ciphertext is at the maximum allowable level for a given parameter.
- Input:
- Ciphertext
- RotationKey
- deltas: list of ints
- Output:
- list of Ciphertext
Warning
- The matrix form does not support this operation.
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_many(
ciphertext, rotation_key, deltas=[1, 2]
)