Skip to content

Commit

Permalink
More fixes to STRIP.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Jan 4, 2024
1 parent 7c55868 commit 498db51
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 6 deletions.
4 changes: 4 additions & 0 deletions src/eb/relic_eb_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */

Expand Down
3 changes: 1 addition & 2 deletions src/ep/relic_ep_add.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 <assert.h>

/**
* Adds two points represented in Jacobian coordinates on an ordinary prime
* elliptic curve.
Expand All @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions src/pc/relic_pc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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 */
Expand Down
3 changes: 3 additions & 0 deletions test/test_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions test/test_pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit 498db51

Please sign in to comment.