Skip to content

Commit

Permalink
Rename ep_param_embed to ep_curve_embed.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Apr 1, 2024
1 parent 63f24c9 commit e52d043
Show file tree
Hide file tree
Showing 11 changed files with 214 additions and 81 deletions.
26 changes: 13 additions & 13 deletions bench/bench_fpx.c
Original file line number Diff line number Diff line change
Expand Up @@ -2060,7 +2060,7 @@ static void arith12(void) {
}
BENCH_END;

if (ep_curve_is_pairf() && ep_param_embed() == 12) {
if (ep_curve_is_pairf() && ep_curve_embed() == 12) {
BENCH_RUN("fp12_exp_cyc (gls)") {
fp12_rand(a);
fp12_conv_cyc(a, a);
Expand Down Expand Up @@ -2347,7 +2347,7 @@ static void arith16(void) {
}
BENCH_END;

if (ep_curve_is_pairf() && ep_param_embed() == 16) {
if (ep_curve_is_pairf() && ep_curve_embed() == 16) {
BENCH_RUN("fp16_exp_cyc (gls)") {
fp16_rand(a);
fp16_conv_cyc(a, a);
Expand Down Expand Up @@ -2717,7 +2717,7 @@ static void arith18(void) {
}
BENCH_END;

if (ep_curve_is_pairf() && ep_param_embed() == 18) {
if (ep_curve_is_pairf() && ep_curve_embed() == 18) {
BENCH_RUN("fp18_exp_cyc (gls)") {
fp18_rand(a);
fp18_conv_cyc(a, a);
Expand Down Expand Up @@ -3050,7 +3050,7 @@ static void arith24(void) {
}
BENCH_END;

if (ep_curve_is_pairf() && ep_param_embed() == 24) {
if (ep_curve_is_pairf() && ep_curve_embed() == 24) {
BENCH_RUN("fp24_exp_cyc (gls)") {
fp24_rand(a);
fp24_conv_cyc(a, a);
Expand Down Expand Up @@ -3428,7 +3428,7 @@ static void arith48(void) {
}
BENCH_END;

if (ep_curve_is_pairf() && ep_param_embed() == 48) {
if (ep_curve_is_pairf() && ep_curve_embed() == 48) {
BENCH_RUN("fp48_exp_cyc (gls)") {
fp48_rand(a);
fp48_conv_cyc(a, a);
Expand Down Expand Up @@ -3922,7 +3922,7 @@ int main(void) {
arith6();
}

if (fp_prime_get_qnr() && (ep_param_embed() >= 8)) {
if (fp_prime_get_qnr() && (ep_curve_embed() >= 8)) {
util_banner("Octic extension:", 0);
util_banner("Utilities:", 1);
memory8();
Expand All @@ -3931,7 +3931,7 @@ int main(void) {
arith8();
}

if (fp_prime_get_cnr() && (ep_param_embed() >= 9)) {
if (fp_prime_get_cnr() && (ep_curve_embed() >= 9)) {
util_banner("Nonic extension:", 0);
util_banner("Utilities:", 1);
memory9();
Expand All @@ -3940,7 +3940,7 @@ int main(void) {
arith9();
}

if (fp_prime_get_qnr() && fp_prime_get_cnr() && (ep_param_embed() >= 12)) {
if (fp_prime_get_qnr() && fp_prime_get_cnr() && (ep_curve_embed() >= 12)) {
util_banner("Dodecic extension:", 0);
util_banner("Utilities:", 1);
memory12();
Expand All @@ -3949,7 +3949,7 @@ int main(void) {
arith12();
}

if (fp_prime_get_qnr() && (ep_param_embed() >= 16)) {
if (fp_prime_get_qnr() && (ep_curve_embed() >= 16)) {
util_banner("Sextadecic extension:", 0);
util_banner("Utilities:", 1);
memory16();
Expand All @@ -3959,7 +3959,7 @@ int main(void) {
arith16();
}

if (fp_prime_get_cnr() && (ep_param_embed() >= 18)) {
if (fp_prime_get_cnr() && (ep_curve_embed() >= 18)) {
util_banner("Octdecic extension:", 0);
util_banner("Utilities:", 1);
memory18();
Expand All @@ -3969,7 +3969,7 @@ int main(void) {
arith18();
}

if (fp_prime_get_qnr() && (ep_param_embed() >= 24)) {
if (fp_prime_get_qnr() && (ep_curve_embed() >= 24)) {
util_banner("Extension of degree 24:", 0);
util_banner("Utilities:", 1);
memory24();
Expand All @@ -3978,7 +3978,7 @@ int main(void) {
arith24();
}

if (fp_prime_get_qnr() && (ep_param_embed() >= 48)) {
if (fp_prime_get_qnr() && (ep_curve_embed() >= 48)) {
util_banner("Extension of degree 48:", 0);
util_banner("Utilities:", 1);
memory48();
Expand All @@ -3987,7 +3987,7 @@ int main(void) {
arith48();
}

if (fp_prime_get_cnr() && (ep_param_embed() >= 54)) {
if (fp_prime_get_cnr() && (ep_curve_embed() >= 54)) {
util_banner("Extension of degree 54:", 0);
util_banner("Utilities:", 1);
memory54();
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_pc.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@ static void util(void) {
BENCH_ADD(gt_read_bin(a, bin, l));
} BENCH_END;

if (ep_param_embed() == 12) {
if (ep_curve_embed() == 12) {
BENCH_RUN("gt_write_bin (1)") {
gt_rand(a);
l = gt_size_bin(a, 1);
Expand Down
16 changes: 8 additions & 8 deletions bench/bench_pp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1345,35 +1345,35 @@ int main(void) {
ep_param_print();
util_banner("Arithmetic:", 1);

if (ep_param_embed() == 2) {
if (ep_curve_embed() == 2) {
pairing2();
}

if (ep_param_embed() == 8) {
if (ep_curve_embed() == 8) {
pairing8();
}

if (ep_param_embed() == 12) {
if (ep_curve_embed() == 12) {
pairing12();
}

if (ep_param_embed() == 16) {
if (ep_curve_embed() == 16) {
pairing16();
}

if (ep_param_embed() == 18) {
if (ep_curve_embed() == 18) {
pairing18();
}

if (ep_param_embed() == 48) {
if (ep_curve_embed() == 48) {
pairing24();
}

if (ep_param_embed() == 48) {
if (ep_curve_embed() == 48) {
pairing48();
}

if (ep_param_embed() == 54) {
if (ep_curve_embed() == 54) {
pairing54();
}

Expand Down
2 changes: 1 addition & 1 deletion include/relic_ep.h
Original file line number Diff line number Diff line change
Expand Up @@ -744,7 +744,7 @@ int ep_param_level(void);
/**
* Returns the embedding degree of the currently configured elliptic curve.
*/
int ep_param_embed(void);
int ep_curve_embed(void);

/**
* Tests if a point on a prime elliptic curve is at the infinity.
Expand Down
4 changes: 2 additions & 2 deletions include/relic_label.h
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@
#undef ep_param_get
#undef ep_param_print
#undef ep_param_level
#undef ep_param_embed
#undef ep_curve_embed
#undef ep_is_infty
#undef ep_set_infty
#undef ep_copy
Expand Down Expand Up @@ -1037,7 +1037,7 @@
#define ep_param_get RLC_PREFIX(ep_param_get)
#define ep_param_print RLC_PREFIX(ep_param_print)
#define ep_param_level RLC_PREFIX(ep_param_level)
#define ep_param_embed RLC_PREFIX(ep_param_embed)
#define ep_curve_embed RLC_PREFIX(ep_curve_embed)
#define ep_is_infty RLC_PREFIX(ep_is_infty)
#define ep_set_infty RLC_PREFIX(ep_set_infty)
#define ep_copy RLC_PREFIX(ep_copy)
Expand Down
30 changes: 30 additions & 0 deletions src/ep/relic_ep_curve.c
Original file line number Diff line number Diff line change
Expand Up @@ -521,3 +521,33 @@ void ep_curve_set_endom(const fp_t a, const fp_t b, const ep_t g, const bn_t r,
}

#endif


int ep_curve_embed(void) {
switch (core_get()->ep_is_pairf) {
case EP_K1:
return 1;
case EP_SS2:
return 2;
case EP_GMT8:
return 8;
case EP_BN:
case EP_B12:
return 12;
case EP_N16:
case EP_FM16:
case EP_K16:
return 16;
case EP_K18:
case EP_FM18:
case EP_SG18:
return 18;
case EP_B24:
return 24;
case EP_B48:
return 48;
case EP_SG54:
return 54;
}
return 0;
}
29 changes: 0 additions & 29 deletions src/ep/relic_ep_param.c
Original file line number Diff line number Diff line change
Expand Up @@ -1863,32 +1863,3 @@ int ep_param_level(void) {
}
return 0;
}

int ep_param_embed(void) {
switch (core_get()->ep_is_pairf) {
case EP_K1:
return 1;
case EP_SS2:
return 2;
case EP_GMT8:
return 8;
case EP_BN:
case EP_B12:
return 12;
case EP_N16:
case EP_FM16:
case EP_K16:
return 16;
case EP_K18:
case EP_FM18:
case EP_SG18:
return 18;
case EP_B24:
return 24;
case EP_B48:
return 48;
case EP_SG54:
return 54;
}
return 0;
}
2 changes: 1 addition & 1 deletion src/fpx/relic_fpx_cyc.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ void fp12_exp_cyc_sim(fp12_t e, const fp12_t a, const bn_t b, const fp12_t c,
}
bn_rec_frb(_d, 4, _d[0], x, n, ep_curve_is_pairf() == EP_BN);

if (ep_curve_is_pairf() && ep_param_embed() == 12) {
if (ep_curve_is_pairf() && ep_curve_embed() == 12) {
for (i = 0; i < 4; i++) {
fp12_frb(t[i], a, i);
fp12_frb(u[i], c, i);
Expand Down
Loading

0 comments on commit e52d043

Please sign in to comment.