Closed xhuan28 closed 1 year ago
No. Paillier encryption is ONLY defined for NON-negative integers.
(btw, the integer should less than n
)
Well, if that is the case, I need to find a way to handle negative integers on higher level. Currently, what I am doing is,
ipcl::PlainText res = kp.priv_key->decrypt(ct);
if (res > n / 2) {
res -= n;
}
So far, it works fine. It would be great if negative values can be handled in IPCL in future.
If you want to do CT - CT
, you can do something like this:
output:
I tried to encrypt a negative value and then decrypt it. However, inconsistent values are obtained. See the code snippet as follows:
The output is:
So my question is, does ipcl support encrypt a negative value?