Skip to content

Commit b0eb530

Browse files
committed
fix bigint mod with negative numbers
1 parent 16aab00 commit b0eb530

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

3rdparty/libtommath/bn_mp_mod.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ mp_mod (mp_int * a, mp_int * b, mp_int * c)
3131
return res;
3232
}
3333

34-
if (t.sign != b->sign) {
35-
res = mp_add (b, &t, c);
36-
} else {
34+
if (mp_iszero(&t) || t.sign == b->sign) {
3735
res = MP_OKAY;
3836
mp_exch (&t, c);
37+
} else {
38+
res = mp_add (b, &t, c);
3939
}
4040

4141
mp_clear (&t);

0 commit comments

Comments
 (0)