Skip to content

Commit

Permalink
Unify with inversion code where delta is negative.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed May 20, 2024
1 parent 37d180b commit ae4084d
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/fp/relic_fp_smb.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,15 +181,15 @@ static dis_t jumpdivstep(dis_t m[4], dig_t *k, dis_t delta, dis_t y, dis_t x,
ai += t1 & c1;
bi += t2 & c1;

/* delta = RLC_SEL(delta + 1, -delta, c0) */
/* delta = RLC_SEL(2 + delta, 2 - delta, c0) */
y += x & c0;
ci += ai & c0;
di += bi & c0;

x >>= 1;
ci <<= 1;
di <<= 1;
delta = (delta ^ c0) + 1;
delta = (delta ^ c0) - 1;

u += ((yi & y) ^ (y >> 1)) & 2;
u += (u & 1) ^ RLC_SIGN(ci);
Expand All @@ -207,15 +207,15 @@ static dis_t jumpdivstep(dis_t m[4], dig_t *k, dis_t delta, dis_t y, dis_t x,
ai += t1 & c1;
bi += t2 & c1;

/* delta = RLC_SEL(delta + 1, -delta, c0) */
/* delta = RLC_SEL(2 + delta, 2 - delta, c0) */
y += x & c0;
ci += ai & c0;
di += bi & c0;

x >>= 1;
ci <<= 1;
di <<= 1;
delta = (delta ^ c0) + 1;
delta = (delta ^ c0) - 1;

u += ((yi & y) ^ (y >> 1)) & 2;
u += (u & 1) ^ RLC_SIGN(ci);
Expand Down Expand Up @@ -468,7 +468,7 @@ int fp_smb_divst(const fp_t a) {
#if FP_SMB == JMPDS || !defined(STRIP)

int fp_smb_jmpds(const fp_t a) {
dis_t m[4], d = 1;
dis_t m[4], d = -1;
/* Iterations taken directly from https://github.com/sipa/safegcd-bounds */
const int iterations = (45907 * FP_PRIME + 26313) / 19929;
int loops, precision, i, r = 0, s = RLC_DIG - 2;
Expand Down

0 comments on commit ae4084d

Please sign in to comment.