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 the rotate function 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
    • fixed_rotation_keys: list[FixedRotationKey]
  • Output:
    • list[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 the rotate function 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[int]
  • Output:
    • list[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]
)

Bootstrap Key-Based Rotation

Engine.rotate_many(ciphertext, bootstrap_key, deltas)
Rotates the input ciphertext to the left by each of the specified delta values, using the fixed roll keys contained in the bootstrap key. For example, rotating [1, 2, 3, 4] by 1 results in [2, 3, 4, 1]. The engine must be created with Engine(bootstrap=True).
  • Input:
    • Ciphertext
    • BootstrapKey
    • deltas: list[int]
  • Output:
    • list[Ciphertext]

Warning

  • The matrix form does not support this operation.
from desilofhe import Engine

engine = Engine(bootstrap=True)
secret_key = engine.create_secret_key()
bootstrap_key = engine.create_bootstrap_key(secret_key)

message = [1, 2, 3]
ciphertext = engine.encrypt(message, secret_key)
rotated_ciphertexts = engine.rotate_many(
    ciphertext, bootstrap_key, deltas=[1, 2]
)

Evaluation Key-Based Rotation

Engine.rotate_many(ciphertext, evaluation_key, deltas)
Rotates the input ciphertext to the left by each of the specified delta values, using the keys bundled in the evaluation key. 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 the rotate function 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
    • EvaluationKey
    • deltas: list[int]
  • Output:
    • list[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)
evaluation_key = engine.create_evaluation_key(secret_key)

message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
rotated_ciphertexts = engine.rotate_many(
    ciphertext, evaluation_key, deltas=[1, 2]
)