Closed SahithiVulisi closed 3 years ago
Unfortunately, that's not possible, because the Paillier cryptosystem is based on integers.
Maybe a "good enough" solution could be to use rounded float values. You can use quite big integers, so you could multiply your float value by 1000 or 10000 or something - depending on the accuracy you want to reach - and divide it by the same number afterwards.
I hope that helps, otherwise I'm happy to review and merge your PR, if you have a better idea. :)
We have used this library for encryption of signed numbers and we tested some scenarios. Case 1: Encrypted & decrypted the same number For negative value ---> Decrypted value is varying. For positive value ----> Always Correct. Case 2: We have tested the following cases: -ve & +ve, +ve & -ve, -ve & -ve, +ve & +ve And we find out that, if the difference between two numbers are -ve, its decrypted value is varying. And if the difference between two numbers are +ve, its decrypted value is always correct.
Anyone can help me out ?
@nimmisumith Unfortunately, only unsigned integers are supported. This is a limitation of the Paillier cryptosystem. When using BigInt
, it requires BigUInt
type, so you shouldn't even be able to use unsigned integers. This works only when using Bignum
, but actually it shouldn't be possible.
If you know the smallest possible number, you could always add this number before using SwiftPaillier, and subtract that exact number again afterwards. That's what I was doing to always only have unsigned integers.
We want to pass Float values is it possible with this SwiftPailier code ?