Skip to content

Commit

Permalink
Make sure points are in affine coordintes when mixed is used.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Jan 4, 2024
1 parent fd9def9 commit 7c55868
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 3 deletions.
4 changes: 2 additions & 2 deletions src/ep/relic_ep_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,6 @@ static void ep_add_projc_imp(ep_t r, const ep_t p, const ep_t q) {
return;
}
#endif

fp_t t0, t1, t2, t3, t4, t5;

fp_null(t0);
Expand Down Expand Up @@ -568,7 +567,7 @@ static void ep_add_jacob_mix(ep_t r, const ep_t p, const ep_t q) {
fp_free(t6);
}
}

#include <assert.h>
/**
* Adds two points represented in Jacobian coordinates on an ordinary prime
* elliptic curve.
Expand All @@ -581,6 +580,7 @@ static void ep_add_jacob_imp(ep_t r, const ep_t p, const ep_t q) {
#if defined(EP_MIXED) && defined(STRIP)
/* If code size is a problem, leave only the mixed version. */
ep_add_jacob_mix(r, p, q);
assert(q->coord == BASIC);
#else /* General addition. */

#if defined(EP_MIXED) || !defined(STRIP)
Expand Down
6 changes: 5 additions & 1 deletion src/ep/relic_ep_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,15 +202,19 @@ void ep_tab(ep_t *t, const ep_t p, int w) {
#if defined(EP_MIXED)
ep_norm(t[0], t[0]);
#endif
ep_add(t[1], t[0], p);
ep_add(t[1], p, t[0]);
for (int i = 2; i < (1 << (w - 2)); i++) {
ep_add(t[i], t[i - 1], t[0]);
}
#if defined(EP_MIXED)
ep_norm_sim(t + 1, (const ep_t *)t + 1, (1 << (w - 2)) - 1);
#endif
}
#if defined(EP_MIXED)
ep_norm(t[0], p);
#else
ep_copy(t[0], p);
#endif
}

void ep_print(const ep_t p) {
Expand Down
4 changes: 4 additions & 0 deletions src/epx/relic_ep2_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,11 @@ void ep2_tab(ep2_t *t, const ep2_t p, int w) {
ep2_norm_sim(t + 1, t + 1, (1 << (w - 2)) - 1);
#endif
}
#if defined(EP_MIXED)
ep2_norm(t[0], p);
#else
ep2_copy(t[0], p);
#endif
}

void ep2_print(const ep2_t p) {
Expand Down
4 changes: 4 additions & 0 deletions src/epx/relic_ep3_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ void ep3_tab(ep3_t *t, const ep3_t p, int w) {
ep3_norm_sim(t + 1, t + 1, (1 << (w - 2)) - 1);
#endif
}
#if defined(EP_MIXED)
ep3_norm(t[0], p);
#else
ep3_copy(t[0], p);
#endif
}

void ep3_print(const ep3_t p) {
Expand Down
4 changes: 4 additions & 0 deletions src/epx/relic_ep4_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ void ep4_tab(ep4_t *t, const ep4_t p, int w) {
ep4_norm_sim(t + 1, t + 1, (1 << (w - 2)) - 1);
#endif
}
#if defined(EP_MIXED)
ep4_norm(t[0], p);
#else
ep4_copy(t[0], p);
#endif
}

void ep4_print(const ep4_t p) {
Expand Down
4 changes: 4 additions & 0 deletions src/epx/relic_ep8_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,11 @@ void ep8_tab(ep8_t *t, const ep8_t p, int w) {
ep8_norm_sim(t + 1, t + 1, (1 << (w - 2)) - 1);
#endif
}
#if defined(EP_MIXED)
ep8_norm(t[0], p);
#else
ep8_copy(t[0], p);
#endif
}

void ep8_print(const ep8_t p) {
Expand Down

0 comments on commit 7c55868

Please sign in to comment.