diff --git a/include/group.h b/include/group.h index bd0a3dbfce1ba9994929eb10b51e37f6f79eb7f9..8cb84e417bcc978d1159d12291f1d4028e24cd03 100644 --- a/include/group.h +++ b/include/group.h @@ -3,15 +3,15 @@ #include "field.h" -typedef g1_t g; -typedef gt_t gt; +typedef g1_t g_sym; +typedef gt_t gt_sym; -void gen(g x); +void gen(g_sym x); -void g_mul(g r, g x, ZP y); +void g_mul(g_sym r, g_sym x, ZP y); -void gt_raise(gt r, gt x, ZP y); +void gt_raise(gt_sym r, gt_sym x, ZP y); -void bp_map(g a, g b, gt r); +void bp_map(g_sym a, g_sym b, gt_sym r); #endif //PPANN_GROUP_H \ No newline at end of file diff --git a/include/ipre.h b/include/ipre.h index 10d3b1812d1248062b9d3ef5bd059422ffe0ec6a..78c73ff0d140d9260c2d741cbb8472cebe0b4a50 100644 --- a/include/ipre.h +++ b/include/ipre.h @@ -10,8 +10,8 @@ struct Key { zp_mat A; zp_mat B; zp_mat Bi; - g base; - gt t_base; + g_sym base; + gt_sym t_base; bn_t modular; }; diff --git a/include/matrix.h b/include/matrix.h index 2d64931714771287540da85c0d6efcd8fee72fad..4694036a74b8af6a6572d1ed4e2ed0a9aa7136d1 100644 --- a/include/matrix.h +++ b/include/matrix.h @@ -2,7 +2,6 @@ #define PPANN_MATRIX_H #include "field.h" -#include "group.h" typedef ZP *zp_mat; diff --git a/include/vector.h b/include/vector.h index 453a6f886d806cda903f2e7efdd39dfdb4c7ed16..038bf2728e751645fe55e19e3f2a6c4bd1862566 100644 --- a/include/vector.h +++ b/include/vector.h @@ -5,7 +5,7 @@ #include "group.h" typedef ZP *zp_vec; -typedef g *g_vec; +typedef g_sym *g_vec; zp_vec vector_zp_from_int(const int *int_vec, int size, bn_t modular); @@ -15,8 +15,8 @@ zp_vec vector_merge(zp_vec a, zp_vec b, int size_a, int size_b); zp_vec vector_add(zp_vec a, zp_vec b, int size); -g_vec vector_raise(g base, zp_vec x, int size); +g_vec vector_raise(g_sym base, zp_vec x, int size); -void inner_product(gt r, g_vec a, g_vec b, int size); +void inner_product(gt_sym r, g_vec a, g_vec b, int size); #endif //PPANN_VECTOR_H \ No newline at end of file diff --git a/src/ipre.cpp b/src/ipre.cpp index fb01a068ad6cf5275f455bee62b5ec94bfc0c910..ebd09f2143579ad96243f86d840ec615e3842bf4 100644 --- a/src/ipre.cpp +++ b/src/ipre.cpp @@ -50,7 +50,7 @@ Ct enc(Key key, const int *message, int size) { int eval(Key key, Ct x, Ct y, int size, int bound) { // Decrypt components. - gt xy, ct; + gt_sym xy, ct; inner_product(xy, x.ctx, y.ctx, size); inner_product(ct, x.ctc, y.ctk, B_SIZE); @@ -59,7 +59,7 @@ int eval(Key key, Ct x, Ct y, int size, int bound) { gt_mul(xy, xy, ct); // Get a target group element holder. - gt output; + gt_sym output; // Iterate through a loop to find correct answer. for (int i = 1; i <= bound; i++) { diff --git a/src/vector.cpp b/src/vector.cpp index e34bddb6e7a6d9fd7c9cda70c89be3cd98beaeee..56015e51faad13b992835c738de0f6d4c2107107 100644 --- a/src/vector.cpp +++ b/src/vector.cpp @@ -29,15 +29,15 @@ zp_vec vector_add(zp_vec a, zp_vec b, int size) { return r; } -g_vec vector_raise(g base, zp_vec x, int size) { +g_vec vector_raise(g_sym base, zp_vec x, int size) { g_vec r; - r = (g_vec) malloc(sizeof(g) * size); + r = (g_vec) malloc(sizeof(g_sym) * size); for (int i = 0; i < size; i++) g_mul(r[i], base, x[i]); return r; } -void inner_product(gt r, g_vec a, g_vec b, int size) { - gt temp; +void inner_product(gt_sym r, g_vec a, g_vec b, int size) { + gt_sym temp; gt_set_unity(r); for (int i = 0; i < size; i++) { pc_map(temp, a[i], b[i]); gt_mul(r, r, temp); diff --git a/tests/test_group.cpp b/tests/test_group.cpp index 57786da03d3c4283f97fb0ca7999163ae149b2bd..d73f4fcd220903f2cdfb35e6776a450e21454870 100644 --- a/tests/test_group.cpp +++ b/tests/test_group.cpp @@ -1,7 +1,7 @@ #include "group.h" int test_generator() { - g x; + g_sym x; gen(x); return g1_is_valid(x); } @@ -12,21 +12,21 @@ int test_all(bn_st *N) { ZP n = zp_from_int(25, N); // Declare variables. - g a, b; - gt x, y, z; + g_sym a, b; + gt_sym x, y, z; - // Get generator g and find g^5. + // Get generator g_sym and find g_sym^5. gen(a); g_mul(b, a, m); - // Get e(g, g) and e(g^5, g^5). + // Get e(g_sym, g_sym) and e(g_sym^5, g_sym^5). bp_map(a, a, x); bp_map(b, b, y); - // Get e(g, g)^25. + // Get e(g_sym, g_sym)^25. gt_raise(z, x, n); - // Compare e(g^5, g^5) with e(g, g)^25. + // Compare e(g_sym^5, g_sym^5) with e(g_sym, g_sym)^25. return gt_cmp(y, z); } diff --git a/tests/test_vector.cpp b/tests/test_vector.cpp index f74581ec83db382a7d19cab92e88b121b0ba6f9d..e9ab4835803350629aa565c77e95b60b71dfd48e 100644 --- a/tests/test_vector.cpp +++ b/tests/test_vector.cpp @@ -30,13 +30,13 @@ int test_inner_product(bn_st *N) { zp_vec x = vector_zp_from_int(int_vec_x, 3, N); zp_vec y = vector_zp_from_int(int_vec_y, 3, N); - g base; + g_sym base; g_vec gx, gy; gen(base); gx = vector_raise(base, x, 3); gy = vector_raise(base, y, 3); - gt b, r; + gt_sym b, r; inner_product(r, gx, gy, 3); bp_map(base, base, b); gt_exp_dig(b, b, 32);