diff --git a/python/fate/arch/context/_cipher.py b/python/fate/arch/context/_cipher.py index e1cbf119df..2c1e0e7e3b 100644 --- a/python/fate/arch/context/_cipher.py +++ b/python/fate/arch/context/_cipher.py @@ -72,7 +72,7 @@ def setup(self, options: typing.Optional[dict] = None): sk, pk, coder = keygen(key_size) tensor_cipher = PHETensorCipher.from_raw_cipher(pk, coder, sk, evaluator) - return PHECipher(key_size, pk, sk, evaluator, coder, tensor_cipher, True, True, True) + return PHECipher(kind, key_size, pk, sk, evaluator, coder, tensor_cipher, True, True, True) if kind == "ou": from fate.arch.protocol.phe.ou import evaluator, keygen @@ -80,7 +80,7 @@ def setup(self, options: typing.Optional[dict] = None): sk, pk, coder = keygen(key_size) tensor_cipher = PHETensorCipher.from_raw_cipher(pk, coder, sk, evaluator) - return PHECipher(key_size, pk, sk, evaluator, coder, tensor_cipher, False, False, True) + return PHECipher(kind, key_size, pk, sk, evaluator, coder, tensor_cipher, False, False, True) elif kind == "mock": from fate.arch.protocol.phe.mock import evaluator, keygen @@ -88,7 +88,7 @@ def setup(self, options: typing.Optional[dict] = None): sk, pk, coder = keygen(key_size) tensor_cipher = PHETensorCipher.from_raw_cipher(pk, coder, sk, evaluator) - return PHECipher(key_size, pk, sk, evaluator, coder, tensor_cipher, True, False, False) + return PHECipher(kind, key_size, pk, sk, evaluator, coder, tensor_cipher, True, False, False) else: raise ValueError(f"Unknown PHE keygen kind: {self.kind}") @@ -97,6 +97,7 @@ def setup(self, options: typing.Optional[dict] = None): class PHECipher: def __init__( self, + kind, key_size, pk, sk, @@ -107,6 +108,7 @@ def __init__( can_support_squeeze, can_support_pack, ) -> None: + self._kind = kind self._key_size = key_size self._pk = pk self._sk = sk @@ -117,17 +119,21 @@ def __init__( self._can_support_squeeze = can_support_squeeze self._can_support_pack = can_support_pack + @property + def kind(self): + return self._kind + @property def can_support_negative_number(self): - return self._tensor_cipher.can_support_negative_number + return self._can_support_negative_number @property def can_support_squeeze(self): - return self._tensor_cipher.can_support_squeeze + return self._can_support_squeeze @property def can_support_pack(self): - return self._tensor_cipher.can_support_pack + return self._can_support_pack @property def key_size(self): diff --git a/python/fate/arch/protocol/phe/paillier/__init__.py b/python/fate/arch/protocol/phe/paillier/__init__.py deleted file mode 100644 index ae946a49c4..0000000000 --- a/python/fate/arch/protocol/phe/paillier/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -# -# Copyright 2019 The FATE Authors. All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License.