Skip to content

Commit

Permalink
Merge pull request #292 from relic-toolkit/pairing192
Browse files Browse the repository at this point in the history
Refactor pairing+elliptic curve code, especially targeting the 192-bit security level.
  • Loading branch information
dfaranha authored Apr 1, 2024
2 parents 6f7e8e3 + 911ed2a commit 9164382
Show file tree
Hide file tree
Showing 146 changed files with 6,402 additions and 5,810 deletions.
1 change: 1 addition & 0 deletions .github/workflows/gmp-sec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
gcc
cmake
gmp
gmp-devel
update: true

- name: Run CMake (MingW)
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/gmp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ jobs:
gcc
cmake
gmp
gmp-devel
update: true

- name: Run CMake (MingW)
Expand Down
12 changes: 6 additions & 6 deletions bench/bench_dv.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,16 +67,16 @@ static void copy(void) {
BENCH_ADD(dv_copy(a, b, RLC_DV_DIGS));
} BENCH_END;

BENCH_RUN("dv_copy_cond") {
BENCH_RUN("dv_copy_sec") {
rand_bytes((uint8_t *)a, RLC_DV_DIGS * sizeof(dig_t));
rand_bytes((uint8_t *)b, RLC_DV_DIGS * sizeof(dig_t));
BENCH_ADD(dv_copy_cond(a, b, RLC_DV_DIGS, 1));
BENCH_ADD(dv_copy_sec(a, b, RLC_DV_DIGS, 1));
} BENCH_END;

BENCH_RUN("dv_swap_cond") {
BENCH_RUN("dv_swap_sec") {
rand_bytes((uint8_t *)a, RLC_DV_DIGS * sizeof(dig_t));
rand_bytes((uint8_t *)b, RLC_DV_DIGS * sizeof(dig_t));
BENCH_ADD(dv_swap_cond(a, b, RLC_DV_DIGS, 1));
BENCH_ADD(dv_swap_sec(a, b, RLC_DV_DIGS, 1));
} BENCH_END;

BENCH_RUN("dv_cmp") {
Expand All @@ -85,10 +85,10 @@ static void copy(void) {
BENCH_ADD(dv_cmp(a, b, RLC_DV_DIGS));
} BENCH_END;

BENCH_RUN("dv_cmp_const") {
BENCH_RUN("dv_cmp_sec") {
rand_bytes((uint8_t *)a, RLC_DV_DIGS * sizeof(dig_t));
rand_bytes((uint8_t *)b, RLC_DV_DIGS * sizeof(dig_t));
BENCH_ADD(dv_cmp_const(a, b, RLC_DV_DIGS));
BENCH_ADD(dv_cmp_sec(a, b, RLC_DV_DIGS));
} BENCH_END;

dv_free(a);
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_eb.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void util(void) {

BENCH_RUN("eb_rhs") {
eb_rand(p);
BENCH_ADD(eb_rhs(q->x, p));
BENCH_ADD(eb_rhs(q->x, p->x));
} BENCH_END;

BENCH_RUN("eb_tab (4)") {
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_ed.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ static void util(void) {

BENCH_RUN("ed_rhs") {
ed_rand(p);
BENCH_ADD(ed_rhs(q->x, p));
BENCH_ADD(ed_rhs(q->x, p->x));
} BENCH_END;

BENCH_RUN("ed_tab (4)") {
Expand Down
2 changes: 1 addition & 1 deletion bench/bench_ep.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ static void util(void) {

BENCH_RUN("ep_rhs") {
ep_rand(p);
BENCH_ADD(ep_rhs(q->x, p));
BENCH_ADD(ep_rhs(q->x, p->x));
} BENCH_END;

BENCH_RUN("ep_tab (4)") {
Expand Down
91 changes: 81 additions & 10 deletions bench/bench_epx.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,8 +240,7 @@ static void arith2(void) {
ep2_rand(p);
ep2_add_projc(q, q, p);
BENCH_ADD(ep2_add_projc(r, p, q));
}
BENCH_END;
} BENCH_END;

BENCH_RUN("ep2_add_projc (z2 = 1)") {
ep2_rand(p);
Expand All @@ -250,17 +249,44 @@ static void arith2(void) {
ep2_rand(q);
ep2_norm(q, q);
BENCH_ADD(ep2_add_projc(r, p, q));
}
BENCH_END;
} BENCH_END;

BENCH_RUN("ep2_add_projc (z1,z2 = 1)") {
ep2_rand(p);
ep2_norm(p, p);
ep2_rand(q);
ep2_norm(q, q);
BENCH_ADD(ep2_add_projc(r, p, q));
}
BENCH_END;
} BENCH_END;
#endif

#if EP_ADD == JACOB || !defined(STRIP)
BENCH_RUN("ep2_add_jacob") {
ep2_rand(p);
ep2_rand(q);
ep2_add_jacob(p, p, q);
ep2_rand(q);
ep2_rand(p);
ep2_add_jacob(q, q, p);
BENCH_ADD(ep2_add_jacob(r, p, q));
} BENCH_END;

BENCH_RUN("ep2_add_jacob (z2 = 1)") {
ep2_rand(p);
ep2_rand(q);
ep2_add_jacob(p, p, q);
ep2_rand(q);
ep2_norm(q, q);
BENCH_ADD(ep2_add_jacob(r, p, q));
} BENCH_END;

BENCH_RUN("ep2_add_jacob (z1,z2 = 1)") {
ep2_rand(p);
ep2_norm(p, p);
ep2_rand(q);
ep2_norm(q, q);
BENCH_ADD(ep2_add_jacob(r, p, q));
} BENCH_END;
#endif

BENCH_RUN("ep2_sub") {
Expand Down Expand Up @@ -302,15 +328,28 @@ static void arith2(void) {
ep2_rand(q);
ep2_add_projc(p, p, q);
BENCH_ADD(ep2_dbl_projc(r, p));
}
BENCH_END;
} BENCH_END;

BENCH_RUN("ep2_dbl_projc (z1 = 1)") {
ep2_rand(p);
ep2_norm(p, p);
BENCH_ADD(ep2_dbl_projc(r, p));
}
BENCH_END;
} BENCH_END;
#endif

#if EP_ADD == JACOB || !defined(STRIP)
BENCH_RUN("ep2_dbl_jacob") {
ep2_rand(p);
ep2_rand(q);
ep2_add_jacob(p, p, q);
BENCH_ADD(ep2_dbl_jacob(r, p));
} BENCH_END;

BENCH_RUN("ep2_dbl_jacob (z1 = 1)") {
ep2_rand(p);
ep2_norm(p, p);
BENCH_ADD(ep2_dbl_jacob(r, p));
} BENCH_END;
#endif

BENCH_RUN("ep2_neg") {
Expand Down Expand Up @@ -357,6 +396,14 @@ static void arith2(void) {
} BENCH_END;
#endif

#if EP_MUL == LWREG || !defined(STRIP)
BENCH_RUN("ep2_mul_lwreg") {
bn_rand_mod(k, n);
ep2_rand(p);
BENCH_ADD(ep2_mul_lwreg(q, p, k));
} BENCH_END;
#endif

BENCH_RUN("ep2_mul_gen") {
bn_rand_mod(k, n);
BENCH_ADD(ep2_mul_gen(q, k));
Expand Down Expand Up @@ -902,6 +949,14 @@ static void arith3(void) {
} BENCH_END;
#endif

#if EP_MUL == LWREG || !defined(STRIP)
BENCH_RUN("ep3_mul_lwreg") {
bn_rand_mod(k, n);
ep3_rand(p);
BENCH_ADD(ep3_mul_lwreg(q, p, k));
} BENCH_END;
#endif

BENCH_RUN("ep3_mul_gen") {
bn_rand_mod(k, n);
BENCH_ADD(ep3_mul_gen(q, k));
Expand Down Expand Up @@ -1396,6 +1451,14 @@ static void arith4(void) {
} BENCH_END;
#endif

#if EP_MUL == LWREG || !defined(STRIP)
BENCH_RUN("ep4_mul_lwreg") {
bn_rand_mod(k, n);
ep4_rand(p);
BENCH_ADD(ep4_mul_lwreg(q, p, k));
} BENCH_END;
#endif

BENCH_RUN("ep4_mul_gen") {
bn_rand_mod(k, n);
BENCH_ADD(ep4_mul_gen(q, k));
Expand Down Expand Up @@ -1890,6 +1953,14 @@ static void arith8(void) {
} BENCH_END;
#endif

#if EP_MUL == LWREG || !defined(STRIP)
BENCH_RUN("ep8_mul_lwreg") {
bn_rand_mod(k, n);
ep8_rand(p);
BENCH_ADD(ep8_mul_lwreg(q, p, k));
} BENCH_END;
#endif

BENCH_RUN("ep8_mul_gen") {
bn_rand_mod(k, n);
BENCH_ADD(ep8_mul_gen(q, k));
Expand Down
12 changes: 12 additions & 0 deletions bench/bench_fp.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,18 @@ static void util(void) {
}
BENCH_END;

BENCH_RUN("fp_copy_sec (0)") {
fp_rand(a);
BENCH_ADD(fp_copy_sec(b, a, 0));
}
BENCH_END;

BENCH_RUN("fp_copy_sec (1)") {
fp_rand(a);
BENCH_ADD(fp_copy_sec(b, a, 1));
}
BENCH_END;

BENCH_RUN("fp_zero") {
fp_rand(a);
BENCH_ADD(fp_zero(a));
Expand Down
Loading

0 comments on commit 9164382

Please sign in to comment.