level_down

Engine.level_down(ciphertext, level)
Reduces the level of the given ciphertext to the target level. In any operation, the engine will automatically level down input ciphertexts if needed. This function is intended for experts who want the best possible performance.
  • Input:
    • Ciphertext
    • level
      • The level should be an integer greater or equal to 0.
  • Output:
    • Ciphertext
from desilofhe import Engine

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

message = [1, 2, 3]
ciphertext = engine.encrypt(message, public_key)

leveled_down = engine.level_down(ciphertext, level=1)

print(leveled_down.level)  # 1
Engine.level_down(plaintext, level)
Reduces the level of the given plaintext to the target level. In any operation, the engine will automatically level down input plaintexts if needed. This function is intended for experts who want the best possible performance.
  • Input:
    • Plaintext
    • level
      • The level should be an integer greater or equal to 0.
  • Output:
    • Ciphertext
from desilofhe import Engine

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

message = [1, 2, 3]
plinatext = engine.encrypt(message, public_key)

leveled_down = engine.level_down(plaintext, level=1)

print(leveled_down.level)  # 1
Engine.level_down(plain_matrix, level)
Reduces the level of the given plain matrix to the target level. In any operation, the engine will automatically level down the input plain matrix if needed. This function is intended for experts who want the best possible performance.
  • Input:
    • PlainMatrix
    • level
      • The level should be an integer greater or equal to 0.
  • Output:
    • PlainMatrix
import numpy as np

from desilofhe import Engine

engine = Engine(slot_count=64)

message = np.arange(64 * 64).reshape(64, 64)
plain_matrix = engine.encode_to_plain_matrix(message)

leveled_down = engine.level_down(plain_matrix, level=1)

print(leveled_down.level)  # 1