Skip to content

Commit

Permalink
remove affine\iterative_affine
Browse files Browse the repository at this point in the history
Signed-off-by: mgqa34 <[email protected]>
  • Loading branch information
mgqa34 committed Dec 30, 2021
1 parent 99673ba commit 194e63c
Show file tree
Hide file tree
Showing 37 changed files with 34 additions and 902 deletions.
2 changes: 0 additions & 2 deletions doc/federatedml_component/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@ provide:

- [Encrypt](secureprotol.md#encrypt)
- [Paillier encryption](secureprotol.md#paillier-encryption)
- [Affine Homomorphic Encryption](secureprotol.md#affine-homomorphic-encryption)
- [IterativeAffine Homomorphic Encryption](secureprotol.md#iterativeaffine-homomorphic-encryption)
- [RSA encryption](secureprotol.md#rsa-encryption)
- [Hash](secureprotol.md#hash-factory)
- [Diffne Hellman Key Exchange](secureprotol.md#diffne-hellman-key-exchange)
Expand Down
2 changes: 0 additions & 2 deletions doc/federatedml_component/README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,6 @@ Federatedml模块包括许多常见机器学习算法联邦化实现。所有模

- [Encrypt](secureprotol.md#encrypt)
- [Paillier encryption](secureprotol.md#paillier-encryption)
- [Affine Homomorphic Encryption](secureprotol.md#affine-homomorphic-encryption)
- [IterativeAffine Homomorphic Encryption](secureprotol.md#iterativeaffine-homomorphic-encryption)
- [RSA encryption](secureprotol.md#rsa-encryption)
- [Hash](secureprotol.md#hash-factory)
- [Diffne Hellman Key Exchange](secureprotol.md#diffne-hellman-key-exchange)
Expand Down
1 change: 0 additions & 1 deletion doc/federatedml_component/ensemble.md
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ Hetero SecureBoost supports the following applications.
- Support missing value in train and predict process
- Support evaluate training and validate data during training process
- Support another homomorphic encryption method called "Iterative
Affine" since FATE-1.1
- Support early stopping in FATE-1.4, to use early stopping, see
[Boosting Tree Param](../../python/federatedml/param/boosting_param.py)
- Support sparse data optimization in FATE-1.5. You can activate it by
Expand Down
56 changes: 0 additions & 56 deletions doc/federatedml_component/secureprotol.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,62 +46,6 @@ belongs to probabilistic asymmetric algorithm.

Please refer to the links above with encrypt step for details.

### Affine Homomorphic Encryption

Affine homomorphic encryption is another kind of addition homomorphic
encryption.

- keygen

First generate a big integer $n$, then generate another three big
integers $$ a, a^{-1}, b, $$
where $(a, n) = 1$, and $a * a^{-1}\equiv 1\pmod{n}$.

- Encrypt

$$ E(x) = (a * x + b)\pmod{n}, $$
recorded as pair $(E(x), 1)$, $E(x)$ is ciphertext, 1 means the bias $b$ is 1.

- Addition and Scalar Multiplication
$$ E(x + y) = (E(x), 1) + (E(y), 1) = ((a * x + b) + (a * y + b), 1 + 1) = ((a * (x + y) + 2 * b), 2) = (E(x + y), 2) $$
$$ Scalar * E(x) = Scalar * (E(x), 1) = (E(scalar * x), scalar * 1) $$

- Decrypt
Decrypt $(E(x), k)$:
remember that
$$ (E(x), k) = a * x + k * b $$
$$ \begin{align} Dec((E(x), k) &= a^{-1} * (E(x) - k * b) \pmod{n} \\
&= a^{-1} * (a * x) \pmod{n}\\
&= x \pmod{n} \end{align}$$

### IterativeAffine Homomorphic Encryption

Iterative Affine homomorphic encryption is another kind of addition
homomorphic encryption.

- keygen
Generate an key-tuple array, the element in the array is a tuple
$$ (a, a^{-1}, n), $$
where $(a, n) = 1$, $a^{-1} * a \equiv 1\pmod{n}$. The array is sorted by $n$.

- Encrypt
$$ E(x) = (Enc_n \circ\dots\circ Enc_1)(x) $$

where $Enc_r(x) = a_r * x % n_r. a_r$, $n_r$ is the r-th element
of key-tuple array.

- Addition and Scalar Multiplication

$$ E(x + y) = E(x) + E(y) = (Enc_n \circ\dots\circ Enc_1)(x + y) $$

$$ \begin{align} scalar * E(x) &= scalar * ((Enc_n\circ\dots\circ Enc_1)(x))\\
&= (Enc_n\circ\dots\circ Enc_1)(scalar * x) \end{align}$$

- Decrypt
$$ Dec(E(x)) = (Dec_1 \circ Dec_2 \circ \dots \circ Dec_n)(x) $$

where $Dec_r(x) = a_r^{-1} * (a_r * x) \pmod{n_r} = x \pmod{n_r}$

### RSA encryption

This encryption method generates three very large positive integers
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
"roc"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"guest_depth": 2,
"host_depth": 3,
Expand All @@ -86,4 +86,4 @@
}
}
}
}
}
1 change: 0 additions & 1 deletion examples/dsl/v2/hetero_secureboost/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@

This example also contains another two feature since FATE-1.1.
(1) evaluate data during training process, check the "validation_freqs" field in runtime_config
(2) another homomorphic encryption method "Iterative Affine", check "encrypt_param" field in runtime_config.

6. Early stopping example

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"num_trees": 3,
"validation_freqs": 1,
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"tree_param": {
"max_depth": 3
Expand Down Expand Up @@ -95,4 +95,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"num_trees": 3,
"validation_freqs": 1,
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"tree_param": {
"max_depth": 3
Expand Down Expand Up @@ -99,4 +99,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"validation_freqs": 1,
"random_seed": 1000,
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"tree_param": {
"max_depth": 3
Expand Down Expand Up @@ -63,4 +63,4 @@
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"ks"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"early_stopping_rounds": 5,
"tree_param": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@
"ks"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"early_stopping_rounds": 5,
"tree_param": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"ks"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"early_stopping_rounds": 5,
"tree_param": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"ks"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"early_stopping_rounds": 5,
"tree_param": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
"ks"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"early_stopping_rounds": 5,
"tree_param": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@
"ks"
],
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"early_stopping_rounds": 5,
"tree_param": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def main(config="../../config.yaml", namespace=""):
"objective": "cross_entropy"
},
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"predict_param": {
"threshold": 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ def main(config="../../config.yaml", namespace=""):
"objective": "cross_entropy"
},
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"predict_param": {
"threshold": 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ def main(config="../../config.yaml", namespace=""):
"objective": "cross_entropy"
},
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"predict_param": {
"threshold": 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def main(config="../../config.yaml", namespace=""):
"objective": "cross_entropy"
},
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"predict_param": {
"threshold": 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def main(config="../../config.yaml", namespace=""):
"objective": "cross_entropy"
},
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"predict_param": {
"threshold": 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"num_trees": 3,
"validation_freqs": 1,
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"tree_param": {
"max_depth": 3
Expand Down
2 changes: 1 addition & 1 deletion examples/pipeline/demo/pipeline-quick-demo.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
bin_num=16,
task_type="classification",
objective_param={"objective": "cross_entropy"},
encrypt_param={"method": "iterativeAffine"},
encrypt_param={"method": "paillier"},
tree_param={"max_depth": 3})

# To show the evaluation result, an "Evaluation" component is needed.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def main(config="../../config.yaml", namespace=""):
"objective": "cross_entropy"
},
"encrypt_param": {
"method": "iterativeAffine"
"method": "paillier"
},
"predict_param": {
"threshold": 0.5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main(config="../../config.yaml", namespace=""):
num_trees=3,
task_type="classification",
objective_param={"objective": "cross_entropy"},
encrypt_param={"method": "iterativeAffine"},
encrypt_param={"method": "paillier"},
tree_param={"max_depth": 3},
validation_freqs=1,
work_mode='mix',
Expand Down Expand Up @@ -134,4 +134,4 @@ def get_local_baseline(idx):
if args.config is not None:
main(args.config)
else:
main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main(config="../../config.yaml", namespace=""):
num_trees=3,
task_type="classification",
objective_param={"objective": "cross_entropy"},
encrypt_param={"method": "iterativeAffine"},
encrypt_param={"method": "paillier"},
tree_param={"max_depth": 3},
validation_freqs=1)

Expand Down Expand Up @@ -121,4 +121,4 @@ def get_local_baseline(idx):
if args.config is not None:
main(args.config)
else:
main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def main(config="../../config.yaml", namespace=""):
num_trees=3,
task_type="classification",
objective_param={"objective": "cross_entropy"},
encrypt_param={"method": "iterativeAffine"},
encrypt_param={"method": "paillier"},
tree_param={"max_depth": 3},
validation_freqs=1)

Expand Down Expand Up @@ -128,4 +128,4 @@ def get_local_baseline(idx):
if args.config is not None:
main(args.config)
else:
main()
main()
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import numpy as np
from federatedml.cipher_compressor.compressor import PackingCipherTensor
from federatedml.secureprotol import PaillierEncrypt, IterativeAffineEncrypt
from federatedml.secureprotol import PaillierEncrypt


class TestXgboostCriterion(unittest.TestCase):
Expand Down Expand Up @@ -57,4 +57,4 @@ def test_cipher_add_sub_mul(self):


if __name__ == '__main__':
unittest.main()
unittest.main()
15 changes: 1 addition & 14 deletions python/federatedml/ensemble/test/gh_packing_compressing_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import math
from fate_arch.session import computing_session as session
from federatedml.ensemble.basic_algorithms.decision_tree.tree_core.g_h_optim import PackedGHCompressor, GHPacker, fix_point_precision
from federatedml.secureprotol.encrypt import IterativeAffineEncrypt, PaillierEncrypt, FakeEncrypt
from federatedml.secureprotol.encrypt import PaillierEncrypt, FakeEncrypt
from federatedml.ensemble.basic_algorithms.decision_tree.tree_core.splitter import SplitInfo
from federatedml.secureprotol.encrypt_mode import EncryptModeCalculator
from federatedml.util import consts
Expand Down Expand Up @@ -117,11 +117,6 @@ def setUpClass(cls):
# classification data
cls.g, cls.h = generate_bin_gh(cls.max_sample_num)

cls.iter_en = IterativeAffineEncrypt()
cls.iter_en.generate_key(key_length)
cls.iter_packer, cls.iter_en_g_l, cls.iter_en_h_l, cls.iter_en_table, cls.iter_collected_gh = \
cls.prepare_testing_data(cls.g, cls.h, cls.iter_en, cls.max_sample_num, sample_id, consts.CLASSIFICATION)

cls.p_en = PaillierEncrypt()
cls.p_en.generate_key(key_length)

Expand Down Expand Up @@ -185,14 +180,6 @@ def test_pack_gh_accumulate(self):

# test the correctness of gh packing(in comparision to plaintext)

# Iterative Affine
self.run_gh_accumulate_test(self.test_num, self.iter_collected_gh, self.iter_en_g_l, self.iter_en_h_l, self.iter_packer,
self.iter_en, self.g, self.h)

print('*'*30)
print('test iter done')
print('*'*30)

# Paillier
self.run_gh_accumulate_test(self.test_num, self.p_collected_gh, self.p_en_g_l, self.p_en_h_l, self.p_packer,
self.p_en, self.g, self.h)
Expand Down
4 changes: 2 additions & 2 deletions python/federatedml/secureprotol/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
# limitations under the License.
#

from federatedml.secureprotol.encrypt import RsaEncrypt, PaillierEncrypt, FakeEncrypt, AffineEncrypt, IterativeAffineEncrypt
from federatedml.secureprotol.encrypt import RsaEncrypt, PaillierEncrypt, FakeEncrypt
from federatedml.secureprotol.encrypt_mode import EncryptModeCalculator

__all__ = ['RsaEncrypt', 'PaillierEncrypt', 'FakeEncrypt', 'EncryptModeCalculator', 'AffineEncrypt', 'IterativeAffineEncrypt']
__all__ = ['RsaEncrypt', 'PaillierEncrypt', 'FakeEncrypt', 'EncryptModeCalculator']
Loading

0 comments on commit 194e63c

Please sign in to comment.