Skip to content

Commit

Permalink
Add tests and benchmarks for single products of pairings.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfaranha committed Oct 16, 2024
1 parent a404fb7 commit fdf4729
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
16 changes: 16 additions & 0 deletions bench/bench_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1100,6 +1100,22 @@ static void pdprv(void) {
BENCH_RUN("cp_ambat_ver (AGGS)") {
BENCH_ADD(cp_ambat_ver(g, g, ls, e[0], AGGS));
} BENCH_END;

BENCH_RUN("cp_amprd_gen (AGGS)") {
BENCH_ADD(cp_amprd_gen(ls, rs, w2[0], r1, u1[0], u2[0], e[0], 1, AGGS));
} BENCH_END;

BENCH_RUN("cp_amprd_ask (AGGS)") {
BENCH_ADD(cp_amprd_ask(ks, ds, cs, fs, bs, v1[0], v2[0], ls, rs, w2[0], r1, p, q, u1[0], u2[0], e[0], 1, AGGS));
} BENCH_END;

BENCH_RUN("cp_amprd_ans (AGGS)") {
BENCH_ADD(cp_amprd_ans(g, ds, fs, bs, v1[0], v2[0], p, q, 1, AGGS));
} BENCH_END;

BENCH_RUN("cp_amprd_ver (AGGS)") {
BENCH_ADD(cp_amprd_ver(ts, g, ks, cs, e[0], 1));
} BENCH_END;

BENCH_RUN("cp_amprd_gen (AGGS²)") {
BENCH_ADD(cp_amprd_gen(ls, rs, w2[0], r1, u1[0], u2[0], e[0], AGGS, AGGS));
Expand Down
10 changes: 10 additions & 0 deletions test/test_cp.c
Original file line number Diff line number Diff line change
Expand Up @@ -1412,6 +1412,16 @@ static int pdprd(void) {
} TEST_END;

TEST_CASE("amortized delegated pairing product is correct") {
TEST_ASSERT(cp_amprd_gen(ls, rs, w2, x, u1, u2, e, 1, AGGS) == RLC_OK, end);
for (size_t i = 0; i < AGGS * AGGS; i++) {
g1_rand(p[i]);
g2_rand(q[i]);
}
TEST_ASSERT(cp_amprd_ask(ks, ds, cs, fs, bs, v1, v2, ls, rs, w2, x, p, q, u1, u2, e, 1, AGGS) == RLC_OK, end);
TEST_ASSERT(cp_amprd_ans(g, ds, fs, bs, v1, v2, p, q, 1, AGGS) == RLC_OK, end);
TEST_ASSERT(cp_amprd_ver(ts, g, ks, cs, e, 1) == 1, end);
pc_map_sim(g[0], p, q, AGGS);
TEST_ASSERT(gt_cmp(ts[0], g[0]) == RLC_EQ, end);
TEST_ASSERT(cp_amprd_gen(ls, rs, w2, x, u1, u2, e, AGGS, AGGS) == RLC_OK, end);
for (size_t i = 0; i < AGGS * AGGS; i++) {
g1_rand(p[i]);
Expand Down

0 comments on commit fdf4729

Please sign in to comment.