data61 / python-paillier

A library for Partially Homomorphic Encryption in Python
Other
599 stars 134 forks source link

`EncryptedNumber.decrease_exponent_to` does not play nice with custom BASE #76

Open wilko77 opened 5 years ago

wilko77 commented 5 years ago

decrease_exponent_to contains this line: https://github.com/n1analytics/python-paillier/blob/955f8c0bfa9623be15b75462b121d28acf70f04b/phe/paillier.py#L592

It basically just uses the default EncodedNumber.BASE, irrespective of the actual base that was used to encode that particular encrypted number.

See also the problem raised in issue #75: If you run the alternative_base.py example with numbers that have a non-zero exponent, then the addition will produce a wrong result.