Skip to content

Commit

Permalink
Faster membership testing in G1.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Feb 12, 2025
1 parent 7b8be9b commit de1468c
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/pc/relic_pc_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -114,19 +114,23 @@ int g1_is_valid(const g1_t a) {
case EP_B24:
case EP_B48:
/* Check [\psi(P) == [z^2 - 1]P. */
bn_sqr(n, n);
g1_mul_any(u, a, n);
g1_mul_any(u, u, n);
if (ep_curve_is_pairf() == EP_B24) {
/* Check [\psi(P) == [z^4 - 1]P. */
bn_sqr(n, n);
g1_mul_any(u, u, n);
g1_mul_any(u, u, n);
}
if (ep_curve_is_pairf() == EP_B48) {
/* Check [\psi(P) == [z^8 - 1]P. */
bn_sqr(n, n);
bn_sqr(n, n);
g1_mul_any(u, u, n);
g1_mul_any(u, u, n);
g1_mul_any(u, u, n);
g1_mul_any(u, u, n);
}
bn_sub_dig(n, n, 1);
g1_mul_any(u, a, n);
g1_neg(u, u);
ep_psi(v, a);
ep_psi(v, v);
r = g1_on_curve(a) && (g1_cmp(v, u) == RLC_EQ);
break;
/* if (u % 2) == 0, check (u**4)*\psi(P) == P
Expand Down

0 comments on commit de1468c

Please sign in to comment.