-
Notifications
You must be signed in to change notification settings - Fork 21
Open
Description
We have an issue to encode a very large BigDecimal. For example, when I tried to encode 7.533938258014959827307132527342E+545 I got the following error:
Error com.n1analytics.paillier.EncodeException: Input value cannot be encoded.
at com.n1analytics.paillier.StandardEncodingScheme.encode(StandardEncodingScheme.java:115)
at com.n1analytics.paillier.StandardEncodingScheme.encode(StandardEncodingScheme.java:239)
...The reason why I got the error is as follows:
- The number is a BigDecimal, however because it doesn't have a fraction part, Javallier encodes the number as a BigInteger to prevent precision loss. (
StandardEncodingSchemeline 224-240) - When encoding a non-zero BigInteger, the number is repeatedly divided by the encoding base until the number is not divisible by the encoding base anymore. At each step, the exponent is incremented by one. (
StandardEncodingSchemeline 107-113) - If the resulting number is greater than the PaillierContext's
maxSignificandOR is less than theminSignificandthen EncodeException is thrown. In this case the number is greater thanmaxSignificand. (StandardEncodingSchemeline 114-116).
The problem is when encoding a BigInteger greater than maxSignificand OR less than the minSignificand, some of these numbers cannot be encoded either because the number is not divisible by the encoding base or the result of the repeat division (as mentioned in step 2 above) is not in the minSignificand to maxSignificand range.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels