diff --git a/src/eb/relic_eb_util.c b/src/eb/relic_eb_util.c index 21669ae00..fc44b7096 100644 --- a/src/eb/relic_eb_util.c +++ b/src/eb/relic_eb_util.c @@ -204,7 +204,11 @@ void eb_tab(eb_t *t, const eb_t p, int w) { eb_norm_sim(t + 1, (const eb_t *)t + 1, (1 << (w - 2)) - 1); #endif } +#if defined(EB_MIXED) + eb_norm(t[0], p); +#else eb_copy(t[0], p); +#endif } #endif /* EB_PLAIN */ diff --git a/src/ep/relic_ep_add.c b/src/ep/relic_ep_add.c index 0f2fcf73c..e8694421c 100644 --- a/src/ep/relic_ep_add.c +++ b/src/ep/relic_ep_add.c @@ -567,7 +567,7 @@ static void ep_add_jacob_mix(ep_t r, const ep_t p, const ep_t q) { fp_free(t6); } } -#include + /** * Adds two points represented in Jacobian coordinates on an ordinary prime * elliptic curve. @@ -580,7 +580,6 @@ 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) diff --git a/src/pc/relic_pc_util.c b/src/pc/relic_pc_util.c index d3a7fe1a9..c6072137a 100644 --- a/src/pc/relic_pc_util.c +++ b/src/pc/relic_pc_util.c @@ -104,7 +104,7 @@ int g1_is_valid(const g1_t a) { } else { fp_prime_get_par(n); switch (ep_curve_is_pairf()) { -#if defined(EP_ENDOM) && !defined(STRIP) +#if defined(EP_ENDOM) /* Formulas from "Co-factor clearing and subgroup membership * testing on pairing-friendly curves" by El Housni, Guillevic, * Piellard. https://eprint.iacr.org/2022/352.pdf */ @@ -294,7 +294,7 @@ int g2_is_valid(const g2_t a) { fp_prime_get_par(n); switch (ep_curve_is_pairf()) { -#if defined(EP_ENDOM) && !defined(STRIP) +#if defined(EP_ENDOM) /* Formulas from "Co-factor clearing and subgroup membership * testing on pairing-friendly curves" by El Housni, Guillevic, * Piellard. https://eprint.iacr.org/2022/352.pdf */ diff --git a/test/test_pc.c b/test/test_pc.c index 7890526b3..cf06c9300 100644 --- a/test/test_pc.c +++ b/test/test_pc.c @@ -106,6 +106,7 @@ int util1(void) { TEST_ASSERT(g1_cmp(c, a) == RLC_EQ, end); TEST_ASSERT(g1_cmp(a, c) == RLC_EQ, end); g1_neg(b, a); + g1_norm(b, b); g1_add(a, a, b); g1_set_infty(b); TEST_ASSERT(g1_cmp(a, b) == RLC_EQ, end); @@ -579,6 +580,7 @@ static int validity1(void) { TEST_CASE("blinding is consistent") { g1_rand(a); g1_blind(a, a); + g1_norm(a, a); TEST_ASSERT(g1_is_valid(a), end); } TEST_END; } @@ -1169,6 +1171,7 @@ static int validity2(void) { TEST_CASE("blinding is consistent") { g2_rand(a); g2_blind(a, a); + g2_norm(a, a); TEST_ASSERT(g2_is_valid(a), end); } TEST_END; } diff --git a/test/test_pp.c b/test/test_pp.c index b7846fae2..6af9e2bab 100644 --- a/test/test_pp.c +++ b/test/test_pp.c @@ -3586,6 +3586,7 @@ static int doubling54(void) { ep_curve_get_ord(n); +#if EP_ADD == BASIC || !defined(STRIP) TEST_CASE("miller doubling is correct") { ep_rand(p); fp9_copy(rx, qx); @@ -3599,7 +3600,6 @@ static int doubling54(void) { TEST_ASSERT(fp9_cmp(rx, qx) == RLC_EQ && fp9_cmp(ry, qy) == RLC_EQ, end); } TEST_END; -#if EP_ADD == BASIC || !defined(STRIP) TEST_CASE("miller doubling in affine coordinates is correct") { ep_rand(p); fp9_copy(rx, qx); @@ -3727,6 +3727,7 @@ static int addition54(void) { ep_curve_get_ord(n); +#if EP_ADD == BASIC || !defined(STRIP) TEST_CASE("miller addition is correct") { ep_rand(p); fp9_copy(rx, qx); @@ -3752,7 +3753,6 @@ static int addition54(void) { TEST_ASSERT(fp9_cmp(rx, e1[0][0]) == RLC_EQ && fp9_cmp(ry, e1[0][1]) == RLC_EQ, end); } TEST_END; -#if EP_ADD == BASIC || !defined(STRIP) TEST_CASE("miller addition in affine coordinates is correct") { ep_rand(p); fp9_copy(rx, qx);