|
@@ -12,20 +12,24 @@ def simple_bootstrap_example():
|
|
|
parameters.SetSecurityLevel(SecurityLevel.HEStd_NotSet)
|
|
|
parameters.SetRingDim(1<<12)
|
|
|
|
|
|
- rescale_tech = ScalingTechnique.FLEXIBLEAUTO
|
|
|
- dcrt_bits = 59
|
|
|
- first_mod = 60
|
|
|
+ if get_native_int()==128:
|
|
|
+ rescale_tech = ScalingTechnique.FIXEDAUTO
|
|
|
+ dcrt_bits = 78
|
|
|
+ first_mod = 89
|
|
|
+ else:
|
|
|
+ rescale_tech = ScalingTechnique.FLEXIBLEAUTO
|
|
|
+ dcrt_bits = 59
|
|
|
+ first_mod = 60
|
|
|
|
|
|
parameters.SetScalingModSize(dcrt_bits)
|
|
|
parameters.SetScalingTechnique(rescale_tech)
|
|
|
parameters.SetFirstModSize(first_mod)
|
|
|
|
|
|
level_budget = [4, 4]
|
|
|
- approx_bootstrapp_depth = 8
|
|
|
|
|
|
- levels_used_before_bootstrap = 10
|
|
|
+ levels_available_after_bootstrap = 10
|
|
|
|
|
|
- depth = levels_used_before_bootstrap + FHECKKSRNS.GetBootstrapDepth(approx_bootstrapp_depth, level_budget, secret_key_dist)
|
|
|
+ depth = levels_available_after_bootstrap + FHECKKSRNS.GetBootstrapDepth(level_budget, secret_key_dist)
|
|
|
|
|
|
parameters.SetMultiplicativeDepth(depth)
|
|
|
|
|
@@ -51,18 +55,18 @@ def simple_bootstrap_example():
|
|
|
x = [0.25, 0.5, 0.75, 1.0, 2.0, 3.0, 4.0, 5.0]
|
|
|
encoded_length = len(x)
|
|
|
|
|
|
- ptxt = cryptocontext.MakeCKKSPackedPlaintext(x)
|
|
|
+ ptxt = cryptocontext.MakeCKKSPackedPlaintext(x,1,depth-1)
|
|
|
ptxt.SetLength(encoded_length)
|
|
|
|
|
|
- print(f"Input: {x}")
|
|
|
+ print(f"Input: {ptxt}")
|
|
|
|
|
|
ciph = cryptocontext.Encrypt(key_pair.publicKey, ptxt)
|
|
|
|
|
|
- print(f"Initial number of levels remaining: {ciph.GetLevel()}")
|
|
|
+ print(f"Initial number of levels remaining: {depth - ciph.GetLevel()}")
|
|
|
|
|
|
ciphertext_after = cryptocontext.EvalBootstrap(ciph)
|
|
|
|
|
|
- print(f"Number of levels remaining after bootstrapping: {ciphertext_after.GetLevel()}")
|
|
|
+ print(f"Number of levels remaining after bootstrapping: {depth - ciphertext_after.GetLevel()}")
|
|
|
|
|
|
result = cryptocontext.Decrypt(ciphertext_after,key_pair.secretKey)
|
|
|
result.SetLength(encoded_length)
|