|
|
@@ -27,19 +27,19 @@ def eval_logistic_example():
|
|
|
cc.Enable(PKESchemeFeature.LEVELEDSHE)
|
|
|
cc.Enable(PKESchemeFeature.ADVANCEDSHE)
|
|
|
|
|
|
- keyPair = cc.KeyGen()
|
|
|
- cc.EvalMultKeyGen(keyPair.secretKey)
|
|
|
+ key_pair = cc.KeyGen()
|
|
|
+ cc.EvalMultKeyGen(key_pair.secretKey)
|
|
|
|
|
|
input = [-4, -3, -2, -1, 0, 1, 2, 3, 4]
|
|
|
encoded_length = len(input)
|
|
|
plaintext = cc.MakeCKKSPackedPlaintext(input)
|
|
|
- ciphertext = cc.Encrypt(keyPair.publicKey, plaintext)
|
|
|
+ ciphertext = cc.Encrypt(key_pair.publicKey, plaintext)
|
|
|
|
|
|
lower_bound = -4
|
|
|
upper_bound = 4
|
|
|
result = cc.EvalLogistic(ciphertext, lower_bound, upper_bound, poly_degree)
|
|
|
|
|
|
- plaitext_dec = Decrypt(result, keyPair.secretKey)
|
|
|
+ plaitext_dec = Decrypt(result, key_pair.secretKey)
|
|
|
plaitext_dec.SetLength(encoded_length)
|
|
|
|
|
|
expected_output = [0.0179885, 0.0474289, 0.119205, 0.268936, 0.5, 0.731064, 0.880795, 0.952571, 0.982011]
|
|
|
@@ -70,19 +70,19 @@ def eval_function_example():
|
|
|
cc.Enable(PKESchemeFeature.LEVELEDSHE)
|
|
|
cc.Enable(PKESchemeFeature.ADVANCEDSHE)
|
|
|
|
|
|
- keyPair = cc.KeyGen()
|
|
|
- cc.EvalMultKeyGen(keyPair.secretKey)
|
|
|
+ key_pair = cc.KeyGen()
|
|
|
+ cc.EvalMultKeyGen(key_pair.secretKey)
|
|
|
|
|
|
input = [1, 2, 3, 4, 5, 6, 7, 8, 9]
|
|
|
encoded_length = len(input)
|
|
|
plaintext = cc.MakeCKKSPackedPlaintext(input)
|
|
|
- ciphertext = cc.Encrypt(keyPair.publicKey, plaintext)
|
|
|
+ ciphertext = cc.Encrypt(key_pair.publicKey, plaintext)
|
|
|
|
|
|
lower_bound = 1
|
|
|
upper_bound = 9
|
|
|
result = cc.EvalChebyshevFunction(math.sqrt,ciphertext, lower_bound, upper_bound, poly_degree)
|
|
|
|
|
|
- plaintext_dec = Decrypt(result, keyPair.secretKey)
|
|
|
+ plaintext_dec = Decrypt(result, key_pair.secretKey)
|
|
|
plaintext_dec.SetLength(encoded_length)
|
|
|
|
|
|
expected_output = [1, 1.414213, 1.732050, 2, 2.236067, 2.449489, 2.645751, 2.828427, 3]
|