Skip to content

Commit

Permalink
Fix GMP backends.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Apr 20, 2024
1 parent 00bed5b commit d89a710
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 17 deletions.
15 changes: 7 additions & 8 deletions src/low/gmp-sec/relic_bn_add_low.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

#include <gmp.h>

#include "relic_dv.h"
#include "relic_bn.h"
#include "relic_bn_low.h"
#include "relic_alloc.h"
Expand Down Expand Up @@ -63,12 +64,10 @@ dig_t bn_subn_low(dig_t *c, const dig_t *a, const dig_t *b, size_t size) {
}

void bn_negs_low(dig_t *c, const dig_t *a, dig_t sa, size_t size) {
dig_t carry = sa & 1;

sa = -sa;
for (int i = 0; i < size; i++) {
c[i] = (a[i] ^ sa) + carry;
carry = (c[i] < carry);
}
bn_add1_low(a, )
dig_t *t = RLC_ALLOCA(dig_t, size);
mpn_com(t, a, size);
bn_add1_low(t, t, sa, size);
dv_copy(c, a, size);
dv_copy_sec(c, t, size, sa);
RLC_FREE(t);
}
18 changes: 9 additions & 9 deletions src/low/gmp/relic_bn_add_low.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@

#include <gmp.h>

#include "relic_dv.h"
#include "relic_bn.h"
#include "relic_bn_low.h"
#include "relic_alloc.h"

/*============================================================================*/
/* Public definitions */
Expand All @@ -56,12 +58,10 @@ dig_t bn_subn_low(dig_t *c, const dig_t *a, const dig_t *b, size_t size) {
}

void bn_negs_low(dig_t *c, const dig_t *a, dig_t sa, size_t size) {
dig_t carry = sa & 1;

sa = -sa;
for (int i = 0; i < size; i++) {
c[i] = (a[i] ^ sa) + carry;
carry = (c[i] < carry);
}
bn_add1_low(a, )
}
dig_t *t = RLC_ALLOCA(dig_t, size);
mpn_com(t, a, size);
bn_add1_low(t, t, sa, size);
dv_copy(c, a, size);
dv_copy_sec(c, t, size, sa);
RLC_FREE(t);
}

0 comments on commit d89a710

Please sign in to comment.