roll_many

Fixed Roll Key-Based Roll

Engine.roll_many(ciphertext, fixed_roll_keys)
Rolls the input ciphertext to the right by the shift value specified in each of the fixed roll key respectively. For example, rolling [1, 2, 3, 4] by 1 results in [4, 1, 2, 3]. When rolling the same ciphertext by multiple values of shift, this function is more efficient than calling the roll 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_roll_keys: list[FixedRollKey]
  • Output:
    • list[Ciphertext]

Warning

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

engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
fixed_roll_key_1 = engine.create_fixed_roll_key(secret_key, shift=1)
fixed_roll_key_2 = engine.create_fixed_roll_key(secret_key, shift=2)

message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
fixed_roll_keys = [fixed_roll_key_1, fixed_roll_key_2]
rolled_ciphertexts = engine.roll_many(ciphertext, fixed_roll_keys)

Roll Key-Based Roll

Engine.roll_many(ciphertext, roll_key, shifts, axis=None)
Rolls the input ciphertext to the right by the specified shift value. For example, rolling [1, 2, 3, 4] by 1 results in [4, 1, 2, 3]. When rolling the same ciphertext by multiple values of shift, this function is more efficient than calling the roll 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
    • RollKey
    • shifts: list[int]
    • axis: None, optional
  • Output:
    • list[Ciphertext]

Warning

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

engine = Engine()
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
roll_key = engine.create_roll_key(secret_key)

message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)
rolled_ciphertexts = engine.roll_many(ciphertext, roll_key, shifts=[1, 2])

Evaluation Key-Based Roll

Engine.roll_many(ciphertext, evaluation_key, shifts, axis=None)
Rolls the input ciphertext to the right by the specified shift value, using the roll key bundled in the evaluation key. For example, rolling [1, 2, 3, 4] by 1 results in [4, 1, 2, 3]. When rolling the same ciphertext by multiple values of shift, this function is more efficient than calling the roll 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
    • shifts: list[int]
    • axis: None, optional
  • Output:
    • list[Ciphertext]

Warning

  • The matrix form does not yet 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)
rolled_ciphertexts = engine.roll_many(ciphertext, evaluation_key, shifts=[1, 2])

Bootstrap Key-Based Roll

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

Warning

  • The matrix form does not yet 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)
rolled_ciphertexts = engine.roll_many(ciphertext, bootstrap_key, shifts=[1, 2])