lossy_merge_bootstrap
Engine.lossy_merge_bootstrap(ciphertext1, ciphertext2, relinearization_key, conjugation_key, lossy_bootstrap_key)- Lossy merge bootstrap enables lossy bootstrapping two real number ciphertexts at once.
Using the lossy 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.
This function is not supported for the
use_bootstrap_to_14_levelsparameter.
- Input:
- ciphertext1: Ciphertext
- The first ciphertext to be bootstrapped. It should contain only real numbers, and the values must be within the range [−1,1]. The level of the ciphertext must be at least the stage_count of the lossy bootstrap key.
- ciphertext2: Ciphertext
- The second ciphertext to be bootstrapped. It should contain only real numbers, and the values must be within the range [−1,1]. The level of the ciphertext must be at least the stage_count of the lossy bootstrap key.
- RelinearizationKey
- ConjugationKey
- LossyBootstrapKey
- ciphertext1: Ciphertext
- Output:
- (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
- A tuple of bootstrapped ciphertexts, each restored to a level of (16 − stage_count).
- (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
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)
lossy_bootstrap_key = engine.create_lossy_bootstrap_key(
secret_key, stage_count=3
)
message1 = [-1, 0, 1]
message2 = [1, 0, -1]
ciphertext1 = engine.encrypt(message1, public_key, level=3)
ciphertext2 = engine.encrypt(message2, public_key, level=3)
bootstrapped1, bootstrapped2 = engine.lossy_merge_bootstrap(
ciphertext1,
ciphertext2,
relinearization_key,
conjugation_key,
lossy_bootstrap_key,
)
Engine.lossy_merge_bootstrap(ciphertext1, ciphertext2, relinearization_key, conjugation_key, rotation_key, small_bootstrap_key, stage_count=3)- Lossy merge bootstrap enables sign bootstrapping two real number ciphertexts at once. Using the small bootstrap key requires less memory than using the lossy bootstrap key, but is slower. This function can only be used if the engine is initialized for bootstrapping. It bootstraps a sign message with high precision.
- Input:
- ciphertext1: Ciphertext
- The first ciphertext to be bootstrapped. It should contain only real numbers, and the values must be within the range [−1,1]. The level of the ciphertext must be at least the stage_count of the lossy bootstrap key.
- ciphertext2: Ciphertext
- The second ciphertext to be bootstrapped. It should contain only real numbers, and the values must be within the range [−1,1]. The level of the ciphertext must be at least the stage_count of the lossy bootstrap key.
- 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.
- ciphertext1: Ciphertext
- Output:
- (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
- A tuple of bootstrapped ciphertexts, each restored to a level of (16 − stage_count).
- (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
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_level_3 = engine.encrypt(message1, public_key, level=3)
ciphertext2_level_3 = engine.encrypt(message2, public_key, level=3)
bootstrapped1, bootstrapped2 = engine.lossy_merge_bootstrap(
ciphertext1_level_3,
ciphertext2_level_3,
relinearization_key,
conjugation_key,
rotation_key,
small_bootstrap_key,
)
ciphertext1_level_5 = engine.encrypt(message1, public_key, level=5)
ciphertext2_level_5 = engine.encrypt(message2, public_key, level=5)
bootstrapped1_stage_count_5, bootstrapped2_stage_count_5 = (
engine.lossy_merge_bootstrap(
ciphertext1_level_5,
ciphertext2_level_5,
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 | ✅ | ✅ |