Skip to content

bootstrap

Engine.bootstrap(ciphertext, relinearization_key, conjugation_key, bootstrap_key)
Restores the level, which is the remaining number of multiplications you can do with a ciphertext, of a ciphertext. Using the bootstrap key is faster but requires more memory than using the small bootstrap key. This function can only be used if the engine is initialized for bootstrapping.
  • Input:
    • Ciphertext: The ciphertext to be bootstrapped. The values must be within the range [−1,1].
    • RelinearizationKey
    • ConjugationKey
    • BootstrapKey
  • Output:
    • Ciphertext: restored to a level of 10 by default. Level of a ciphertext differs according to stage_count.
from desilofhe import Engine

engine = Engine(use_bootstrap=True)
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
relinearization_key = engine.create_relinearization_key(secret_key)
conjugation_key = engine.create_conjugation_key(secret_key)
bootstrap_key = engine.create_bootstrap_key(secret_key, stage_count=3)

message = [-1, 0, 1]
ciphertext = engine.encrypt(message, public_key, level=0)
bootstrapped = engine.bootstrap(
    ciphertext, relinearization_key, conjugation_key, bootstrap_key
)
Engine.bootstrap(ciphertext, relinearization_key, conjugation_key, rotation_key, small_bootstrap_key, stage_count=3)
Restores the level, which is the remaining number of multiplications you can do with a ciphertext, of a ciphertext. Using the small bootstrap key requires less memory than using the bootstrap key, but is slower. This function can only be used if the engine is initialized for bootstrapping.
  • Input:
    • Ciphertext: The ciphertext to be bootstrapped. The values must be within the range [−1,1].
    • RelinearizationKey
    • ConjugationKey
    • RotationKey
    • SmallBootstrapKey
    • stage_count: optional
      • Specifies the number of levels used in coefficient to the slot function and the slot to coefficient function of bootstrapping algorithm. The default value is 3, and values from 3 to 5 are supported. The larger the stage count, the faster the bootstrapping, but the lower level of the final result. For the use_bootstrap_to_14_levels parameter, only 3 is supported.
  • Output:
    • Ciphertext: restored to a level of 10 by default. Level of a ciphertext differs according to stage_count.
from desilofhe import Engine

engine = Engine(use_bootstrap=True)
secret_key = engine.create_secret_key()
public_key = engine.create_public_key(secret_key)
relinearization_key = engine.create_relinearization_key(secret_key)
conjugation_key = engine.create_conjugation_key(secret_key)
rotation_key = engine.create_rotation_key(secret_key)
small_bootstrap_key = engine.create_small_bootstrap_key(secret_key)

message = [-1, 0, 1]
ciphertext = engine.encrypt(message, public_key, level=0)
bootstrapped = engine.bootstrap(
    ciphertext,
    relinearization_key,
    conjugation_key,
    rotation_key,
    small_bootstrap_key,
)

bootstrapped_stage_count_5 = engine.bootstrap(
    ciphertext,
    relinearization_key,
    conjugation_key,
    rotation_key,
    small_bootstrap_key,
    stage_count=5,
)

Stage Count

Stage counts of 3, 4, and 5 are supported by default. For sparse bootstrapping, the following values are supported.

key_size slot_count 1 2 3 4 5
medium 1 ✅
medium 2 ✅
medium 3 ✅
medium 4 ✅ ✅
medium 5 ✅ ✅
medium 6 ✅
medium 7 ✅ ✅
medium 8 ✅ ✅
medium 9 ✅ ✅
medium 10 ✅ ✅ ✅
medium 11 ✅ ✅
medium 12 ✅ ✅
medium 13 ✅ ✅ ✅
medium 14 ✅ ✅ ✅
large 3 ✅
large 4 ✅
large 5 ✅
large 6 ✅
large 7 ✅
large 8 ✅
large 9 ✅ ✅
large 10 ✅ ✅
large 11 ✅
large 12 ✅ ✅
large 13 ✅ ✅
large 14 ✅ ✅