Skip to content

Commit cdfe7e2

Browse files
committed
Fixed overflow by converting int_rep into python int
1 parent 4ebb504 commit cdfe7e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

phe/encoding.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,8 +188,8 @@ def encode(cls, public_key, scalar, precision=None, max_exponent=None):
188188
exponent = min(max_exponent, prec_exponent)
189189

190190
# Use rationals instead of floats to avoid overflow.
191-
int_rep = round(fractions.Fraction(scalar)
192-
* fractions.Fraction(cls.BASE) ** -exponent)
191+
int_rep = int(round(fractions.Fraction(scalar)
192+
* fractions.Fraction(cls.BASE) ** -exponent))
193193

194194
if abs(int_rep) > public_key.max_int:
195195
raise ValueError('Integer needs to be within +/- %d but got %d'

0 commit comments

Comments
 (0)