bootstrap
Engine.bootstrap(ciphertext, relinearization_key, conjugation_key, bootstrap_key)
- 곱셈 횟수를 다시 늘려줍니다.
부트스트랩 키를 사용하여 회전 키를 사용하는 경우보다 추가적인 메모리가 사용되지만 더 좋은 성능을 가집니다.
엔진이 부트스트랩용으로 생성된 경우에만 사용할 수 있습니다.
- 인풋:
- Ciphertext: 값이 -1 에서 1 이내의 값이어야 합니다.
- RelinearizationKey
- ConjugationKey
- BootstrapKey
- 아웃풋:
- Ciphertext: 기본레벨은 10 레벨 입니다. 부트스트랩 키 생성에 사용된 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)
- 곱셈 횟수를 다시 늘려줍니다. 회전 키를 사용하여 메모리 사용이 적지만 느립니다. 엔진이 부트스트랩용으로 생성된 경우에만 사용할 수 있습니다.
- 인풋:
- Ciphertext: 값이 -1 에서 1 이내의 값이어야 합니다.
- RelinearizationKey
- ConjugationKey
- RotationKey
- SmallBootstrapKey
- stage_count: optional
- 부트스트래핑 알고리즘의 coefficient to slot, slot to coefficient 단계에서 사용될 곱셈 횟수를 지정합니다. 기본값은 3이고, 권장값은 3 ~ 5입니다. 클수록 부트스트래핑이 빠르지만 최종 결과값의 곱셈 횟수가 줄어듭니다.
- 아웃풋:
- Ciphertext: 기본레벨은 10 레벨 입니다. 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,
)