Skip to content

merge_bootstrap

Engine.merge_bootstrap(ciphertext1, ciphertext2, relinearization_key, conjugation_key, merge_bootstrap_key)
Merge bootstrap enables bootstrapping two real number ciphertexts at once. Using the merge 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:
    • ciphertext1: Ciphertext
      • The first ciphertext to be bootstrapped. It should contain only real numbers. The values must be within the range [−1,1].
    • ciphertext2: Ciphertext
      • The second ciphertext to be bootstrapped. It should contain only real numbers. The values must be within the range [−1,1].
    • RelinearizationKey
    • ConjugationKey
    • MergeBootstrapKey
  • Output:
    • (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
      • A tuple of the bootstrapped ciphertexts. The ciphertexts are restored to a level of 10 by default. Level of the ciphertexts 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)
merge_bootstrap_key = engine.create_merge_bootstrap_key(
    secret_key, stage_count=3
)

message1 = [-1, 0, 1]
message2 = [1, 0, -1]
ciphertext1 = engine.encrypt(message1, public_key, level=0)
ciphertext2 = engine.encrypt(message2, public_key, level=0)
bootstrapped1, bootstrapped2 = engine.merge_bootstrap(
    ciphertext1,
    ciphertext2,
    relinearization_key,
    conjugation_key,
    merge_bootstrap_key,
)
Engine.merge_bootstrap(ciphertext1, ciphertext2, relinearization_key, conjugation_key, rotation_key, small_bootstrap_key, stage_count=3)
Merge bootstrap enables bootstrapping two real number ciphertexts at once. Using the small bootstrap key requires less memory than using the merge bootstrap key, but is slower. This function can only be used if the engine is initialized for bootstrapping.
  • Input:
    • ciphertext1: Ciphertext
      • The first ciphertext to be bootstrapped. It should contain only real numbers. The values must be within the range [−1,1].
    • ciphertext2: Ciphertext
      • The second ciphertext to be bootstrapped. It should contain only real numbers. 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:
    • (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
      • A tuple of the bootstrapped ciphertexts. The ciphertexts are restored to a level of 10 by default. Level of the ciphertexts 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)

message1 = [-1, 0, 1]
message2 = [1, 0, -1]
ciphertext1 = engine.encrypt(message1, public_key, level=0)
ciphertext2 = engine.encrypt(message2, public_key, level=0)
bootstrapped1, bootstrapped2 = engine.merge_bootstrap(
    ciphertext1,
    ciphertext2,
    relinearization_key,
    conjugation_key,
    rotation_key,
    small_bootstrap_key,
)

bootstrapped1_stage_count_5, bootstrapped2_stage_count_5 = (
    engine.merge_bootstrap(
        ciphertext1,
        ciphertext2,
        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