Skip to content

Commit

Permalink
Fix precision issue.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Dec 29, 2024
1 parent 0e8c901 commit f14f84d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/bn/relic_bn_rec.c
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ void bn_rec_rtnaf(int8_t *tnaf, size_t *len, const bn_t k, int8_t u, size_t m,

void bn_rec_reg(int8_t *naf, size_t *len, const bn_t k, size_t n, size_t w) {
int i, l;
dig_t mask, t[RLC_FP_DIGS + 1] = { 0 };
dig_t mask, t[RLC_BN_DIGS] = { 0 };
int8_t u_i;

mask = RLC_MASK(w);
Expand All @@ -720,15 +720,15 @@ void bn_rec_reg(int8_t *naf, size_t *len, const bn_t k, size_t n, size_t w) {
u_i = (t[0] & mask) - 2;
t[0] -= u_i;
naf[i] = u_i;
bn_rsh1_low(t, t, RLC_FP_DIGS + 1);
bn_rsh1_low(t, t, RLC_BN_DIGS);
}
naf[i] = t[0];
} else {
for (i = 0; i < l; i++) {
u_i = (t[0] & mask) - (1 << (w - 1));
t[0] -= u_i;
naf[i] = u_i;
bn_rshb_low(t, t, RLC_FP_DIGS + 1, w - 1);
bn_rshb_low(t, t, RLC_BN_DIGS, w - 1);
}
naf[i] = t[0];
}
Expand Down

0 comments on commit f14f84d

Please sign in to comment.