-
-
Notifications
You must be signed in to change notification settings - Fork 1
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
Paillier not working with scalar non-integer float #21
Comments
Float numbers are not invalid actually. They are converted to integers for that module. cs = LightPHE(algorithm_name = "Paillier")
m1 = 17
c1 = cs.encrypt(m1)
# increasing something 5%
k = 1.05
# scalar multiplication - private key is not required!
c4 = k * c1
# proof of work
assert cs.decrypt(c4) == k * m1 Besides, if you set your plaintext as tensor, then you are able to restore that float number. cs = LightPHE(algorithm_name = "Paillier")
m = [1.5]
c = cs.encrypt(m)
p = cs.decrypt(c)
assert p[0] == 1.5 |
`from lightphe import LightPHE assert validate(1) I guess the title of the bug report is completely wrong, though -- sorry about that. If I'd thought about it, I'd have realized something that works with integers can work with fractions of integers. |
They are all working for me. Are you using latest version? |
pip says this is version 0.0.6 |
would you please share all exception message? |
btw python version may be the root cause of your problem. i am using Python 3.9.16 |
Python 3.10.4 (tags/v3.10.4:9d38120, Mar 23 2022, 23:13:41) [MSC v.1929 64 bit (AMD64)] on win32
The result is a different large integer each time. One example: |
Actually, looking at the source, I might be able to submit an MR, but if you're not reproducing the issue ... that might be counterproductive. |
Yes please |
My quick fix of handling float like [float] broke a few other things. Fraction doesn't have value, and why can't we multiply a Fraction by a constant? Is there a quick way to convert between Ciphertext and Fraction? |
It does! https://github.com/serengil/LightPHE/blob/master/tests/test_tensors.py#L64 As seen this is checked in unit tests and run successfully in github actions. I think your problem is because of your python version. |
you cannot convert ciphertext to fraction. you can only convert a float value to fraction. then, you can encrypt its dividend and divisor separately as shown here: https://github.com/serengil/LightPHE/blob/master/lightphe/__init__.py#L178 |
Sorry, I misspoke. Multiply Ciphertext (of a constant) and Fraction. |
I'll have to deal with another fire, then get a better understanding of the class structure before I give this another go. |
@kostrom you may consider to make your python version same with me |
Closed due to inactivity |
If someone tries to work with float values in paillier, it doesn't work, but it works for integers. If it only supports integers, you may want to raise an exception, in keeping with how you handle some other illegal operations.
see https://stackoverflow.com/questions/78335087/the-sum-does-not-get-decrypted
The text was updated successfully, but these errors were encountered: