-
Notifications
You must be signed in to change notification settings - Fork 134
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Overflow when iterate and divide Encrypted number #74
Comments
Overflows are a consequence of the encoding scheme. The Paillier cryptosystem allows arithmetic over the integers modulo n. That is the numbers {0, 1, ..., n-1}. Our encoding scheme maps floating point numbers onto the integers in such a way that it preserves arithmetic. However, there is a big difference to conventional floating point arithmetic. The important observation here is that with every arithmetic operation, the mantissa will only grow. And as the mantissa is mapped onto an integer in the Paillier scheme, it will eventually be too big to be represented (a wrap around will occur). That's what we call an overflow. In your example, you repeatedly multiply, and after 55 iterations the mantissa grew so much that it could not be represented anymore within a Paillier ciphertext. |
Thanks @wilko77! import phe as paillier
if __name__ == "__main__":
public_key, private_key = paillier.generate_paillier_keypair()
encryp_number = public_key.encrypt(1.0)
for i in range(1, 100):
print(encryp_number.exponent)
encryp_number = encryp_number * 1.0
print(private_key.decrypt(encryp_number)) The exponent increase until raise Overflow error.
It's a expected behavoir? (iterating 100 times and only multiplying 1*1 each time) |
I have the same problem, so how can we solve it? |
Hello everyone. I am running in the same issue. I was trying to use the phe module in one of my project but apparently while looping for 3 times I receive the same overflow error. I did the calculations manually, and it should not overflow the system. I can very well encrypt and work with ciphertexts, but when it comes to the decryption I either get an error, or some completely random values. I tried to play with the precision parameter of the encrypt function, but yet no fortune. Thanks in advance |
Hi,
I try to run this example using phe and numpy, but have Overflow when iterate some loops
Can you help me?
Thanks!
The text was updated successfully, but these errors were encountered: