merge_bootstrap
Engine.merge_bootstrap(ciphertext1, ciphertext2, relinearization_key, conjugation_key, merge_bootstrap_key)- 병합 부트스트랩은 실수 값만을 포함한 두 암호문의 부트스트랩을 한 번에 수행합니다. 병합 부트스트랩 키를 사용하여 간이 부트스트랩 키를 사용하는 경우보다 추가적인 메모리가 사용되지만 더 좋은 성능을 가집니다. 엔진이 부트스트랩용으로 생성된 경우에만 사용할 수 있습니다.
- 인풋:
- ciphertext1: Ciphertext
- 부트스트랩을 수행할 첫 번째 암호문입니다. 실수 값만을 포함해야 합니다. 값이 -1 에서 1 이내의 값이어야 합니다.
- ciphertext2: Ciphertext
- 부트스트랩을 수행할 두 번째 암호문입니다. 실수 값만을 포함해야 합니다. 값이 -1 에서 1 이내의 값이어야 합니다.
- RelinearizationKey
- ConjugationKey
- MergeBootstrapKey
- ciphertext1: Ciphertext
- 아웃풋:
- (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
- 부트스트랩이 수행된 암호문 쌍입니다. 기본 레벨은 10 레벨 입니다. 부트스트랩 키 생성에 사용된 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)
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)- 곱셈 횟수를 다시 늘려줍니다. 간이 부트스트랩 키를 사용하여 메모리 사용이 적지만 느립니다. 엔진이 부트스트랩용으로 생성된 경우에만 사용할 수 있습니다.
- 인풋:
- ciphertext1: Ciphertext
- 부트스트랩을 수행할 첫 번째 암호문입니다. 실수 값만을 포함해야 합니다. 값이 -1 에서 1 이내의 값이어야 합니다.
- ciphertext2: Ciphertext
- 부트스트랩을 수행할 두 번째 암호문입니다. 실수 값만을 포함해야 합니다. 값이 -1 에서 1 이내의 값이어야 합니다.
- RelinearizationKey
- ConjugationKey
- RotationKey
- SmallBootstrapKey
- stage_count: optional
- 부트스트래핑 알고리즘의 coefficient to slot, slot to coefficient 단계에서 사용될 곱셈 횟수를 지정합니다. 기본값은 3이고, 3 ~ 5를 지원합니다. 클수록 부트스트래핑이 빠르지만 최종 결과값의 곱셈 횟수가 줄어듭니다. 14 레벨 부트스트랩 파라미터는 3만 지원합니다.
- ciphertext1: Ciphertext
- 아웃풋:
- (bootstrapped1, bootstrapped2) : tuple of Ciphertexts
- 부트스트랩이 수행된 암호문 쌍입니다. 기본 레벨은 10 레벨 입니다. 부트스트랩 키 생성에 사용된 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 = 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
기본적으로 3, 4, 5를 지원합니다. 희소 부트스트랩의 경우 다음 값들을 지원합니다.
| 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 | ✅ | ✅ |