From 5237da4427e9f51e9b313e9fb6c2d363bed89c58 Mon Sep 17 00:00:00 2001 From: Weiqi <weltch1997@gmail.com> Date: Wed, 15 Nov 2023 00:35:12 -0500 Subject: [PATCH] More refactoring --- include/asym_field.h | 34 ------------------ include/asym_field.hpp | 38 +++++++++++++++++++++ include/asym_group.h | 19 ----------- include/asym_group.hpp | 21 ++++++++++++ include/sym_group.hpp | 2 +- src/asym_field.cpp | 42 +++++++++++------------ src/asym_group.cpp | 14 ++++---- src/ipre.cpp | 4 +-- src/sym_group.cpp | 6 ++-- tests/CMakeLists.txt | 10 ++++++ tests/test_asym_field.cpp | 72 +++++++++++++++++++++++++++++++++++++++ tests/test_asym_group.cpp | 26 ++++++++++++++ tests/test_field_asym.cpp | 72 --------------------------------------- tests/test_group_asym.cpp | 47 ------------------------- tests/test_sym_field.cpp | 16 ++++----- tests/test_sym_group.cpp | 6 ++-- tests/test_sym_matrix.cpp | 12 +++---- tests/test_sym_vector.cpp | 10 +++--- 18 files changed, 223 insertions(+), 228 deletions(-) delete mode 100644 include/asym_field.h create mode 100644 include/asym_field.hpp delete mode 100644 include/asym_group.h create mode 100644 include/asym_group.hpp create mode 100644 tests/test_asym_field.cpp create mode 100644 tests/test_asym_group.cpp delete mode 100644 tests/test_field_asym.cpp delete mode 100644 tests/test_group_asym.cpp diff --git a/include/asym_field.h b/include/asym_field.h deleted file mode 100644 index 6eba2b5..0000000 --- a/include/asym_field.h +++ /dev/null @@ -1,34 +0,0 @@ -#pragma once - -#include <gmp.h> - -extern "C" { -#include "relic_asym/relic.h" -} - -struct ZP_ASYM { - bn_t point{}; - bn_t modular{}; -}; - -ZP_ASYM rand_zp(bn_t modular); - -ZP_ASYM zp_zero(bn_t modular); - -ZP_ASYM zp_one(bn_t modular); - -ZP_ASYM zp_copy(ZP_ASYM x); - -ZP_ASYM zp_from_int(int x, bn_t modular); - -ZP_ASYM zp_add(ZP_ASYM x, ZP_ASYM y); - -ZP_ASYM zp_neg(ZP_ASYM x); - -ZP_ASYM zp_mul(ZP_ASYM x, ZP_ASYM y); - -ZP_ASYM zp_inv(ZP_ASYM x); - -int zp_cmp(ZP_ASYM x, ZP_ASYM y); - -int zp_cmp_int(ZP_ASYM x, int y); \ No newline at end of file diff --git a/include/asym_field.hpp b/include/asym_field.hpp new file mode 100644 index 0000000..4d74626 --- /dev/null +++ b/include/asym_field.hpp @@ -0,0 +1,38 @@ +#pragma once + +#include <gmp.h> + +extern "C" { +#include "relic_asym/relic.h" +} + +// Set specific asym data types. +typedef bn_t asymPoint; +struct asymZp { + asymPoint point{}; + asymPoint modular{}; +}; + +namespace asym { + asymZp rand_zp(asymPoint modular); + + asymZp zp_zero(asymPoint modular); + + asymZp zp_one(asymPoint modular); + + asymZp zp_copy(asymZp x); + + asymZp zp_from_int(int x, asymPoint modular); + + asymZp zp_add(asymZp x, asymZp y); + + asymZp zp_neg(asymZp x); + + asymZp zp_mul(asymZp x, asymZp y); + + asymZp zp_inv(asymZp x); + + int zp_cmp(asymZp x, asymZp y); + + int zp_cmp_int(asymZp x, int y); +} diff --git a/include/asym_group.h b/include/asym_group.h deleted file mode 100644 index 45b1c93..0000000 --- a/include/asym_group.h +++ /dev/null @@ -1,19 +0,0 @@ -#pragma once - -#include "asym_field.h" - -typedef g1_t g1_asym; -typedef g2_t g2_asym; -typedef gt_t gt_asym; - -void g1_gen(g1_asym x); - -void g2_gen(g2_asym x); - -void g1_mul(g1_asym r, g1_asym x, ZP_ASYM y); - -void g2_mul(g2_asym r, g2_asym x, ZP_ASYM y); - -void gt_raise(gt_asym r, gt_asym x, ZP_ASYM y); - -void bp_map(gt_asym r, g1_asym x, g2_asym y); \ No newline at end of file diff --git a/include/asym_group.hpp b/include/asym_group.hpp new file mode 100644 index 0000000..19287fb --- /dev/null +++ b/include/asym_group.hpp @@ -0,0 +1,21 @@ +#pragma once + +#include "asym_field.hpp" + +typedef g1_t asymG1; +typedef g2_t asymG2; +typedef gt_t asymGt; + +namespace asym { + void g1_gen(asymG1 x); + + void g2_gen(asymG2 x); + + void g1_mul(asymG1 r, asymG1 x, asymZp y); + + void g2_mul(asymG2 r, asymG2 x, asymZp y); + + void gt_raise(asymGt r, asymGt x, asymZp y); + + void bp_map(asymGt r, asymG1 x, asymG2 y); +} diff --git a/include/sym_group.hpp b/include/sym_group.hpp index 92d6bb5..8e13419 100644 --- a/include/sym_group.hpp +++ b/include/sym_group.hpp @@ -12,6 +12,6 @@ namespace sym { void gt_raise(symGt r, symGt x, symZp y); - void bp_map(symG a, symG b, symGt r); + void bp_map(symGt r, symG a, symG b); } diff --git a/src/asym_field.cpp b/src/asym_field.cpp index b7f0fa2..60bf35c 100644 --- a/src/asym_field.cpp +++ b/src/asym_field.cpp @@ -1,75 +1,75 @@ -#include "asym_field.h" +#include "asym_field.hpp" -ZP_ASYM rand_zp(bn_st *modular) { - ZP_ASYM result; +asymZp asym::rand_zp(asymPoint modular) { + asymZp result; bn_rand_mod(result.point, modular); bn_copy(result.modular, modular); return result; } -ZP_ASYM zp_zero(bn_st *modular) { - ZP_ASYM result; +asymZp asym::zp_zero(asymPoint modular) { + asymZp result; bn_set_dig(result.point, 0); bn_copy(result.modular, modular); return result; } -ZP_ASYM zp_one(bn_st *modular) { - ZP_ASYM result; +asymZp asym::zp_one(asymPoint modular) { + asymZp result; bn_set_dig(result.point, 1); bn_copy(result.modular, modular); return result; } -ZP_ASYM zp_copy(ZP_ASYM x) { - ZP_ASYM result; +asymZp asym::zp_copy(asymZp x) { + asymZp result; bn_copy(result.point, x.point); bn_copy(result.modular, x.modular); return result; } -ZP_ASYM zp_from_int(int x, bn_st *modular) { - ZP_ASYM result; +asymZp asym::zp_from_int(int x, asymPoint modular) { + asymZp result; bn_set_dig(result.point, x); bn_copy(result.modular, modular); return result; } -ZP_ASYM zp_add(ZP_ASYM x, ZP_ASYM y) { - ZP_ASYM result; +asymZp asym::zp_add(asymZp x, asymZp y) { + asymZp result; bn_add(result.point, x.point, y.point); bn_mod(result.point, result.point, x.modular); bn_copy(result.modular, x.modular); return result; } -ZP_ASYM zp_neg(ZP_ASYM x) { - ZP_ASYM result; +asymZp asym::zp_neg(asymZp x) { + asymZp result; bn_neg(result.point, x.point); bn_mod(result.point, result.point, x.modular); bn_copy(result.modular, x.modular); return result; } -ZP_ASYM zp_mul(ZP_ASYM x, ZP_ASYM y) { - ZP_ASYM result; +asymZp asym::zp_mul(asymZp x, asymZp y) { + asymZp result; bn_mul(result.point, x.point, y.point); bn_mod(result.point, result.point, x.modular); bn_copy(result.modular, x.modular); return result; } -ZP_ASYM zp_inv(ZP_ASYM x) { - ZP_ASYM result; +asymZp asym::zp_inv(asymZp x) { + asymZp result; bn_mod_inv(result.point, x.point, x.modular); bn_copy(result.modular, x.modular); return result; } -int zp_cmp(ZP_ASYM x, ZP_ASYM y) { +int asym::zp_cmp(asymZp x, asymZp y) { return bn_cmp(x.point, y.point) == RLC_EQ; } -int zp_cmp_int(ZP_ASYM x, int y) { +int asym::zp_cmp_int(asymZp x, int y) { return bn_cmp_dig(x.point, y) == RLC_EQ; } \ No newline at end of file diff --git a/src/asym_group.cpp b/src/asym_group.cpp index 5fd16ec..c89aefe 100644 --- a/src/asym_group.cpp +++ b/src/asym_group.cpp @@ -1,26 +1,26 @@ -#include "asym_group.h" +#include "asym_group.hpp" -void g1_gen(asym_ep_st *x) { +void asym::g1_gen(asymG1 x) { g1_get_gen(x); } -void g2_gen(asym_ep2_st *x) { +void asym::g2_gen(asymG2 x) { g2_get_gen(x); } -void g1_mul(asym_ep_st *r, asym_ep_st *x, ZP_ASYM y) { +void asym::g1_mul(asymG1 r, asymG1 x, asymZp y) { g1_mul(r, x, y.point); } -void g2_mul(asym_ep2_st *r, asym_ep2_st *x, ZP_ASYM y) { +void asym::g2_mul(asymG2 r, asymG2 x, asymZp y) { g2_mul(r, x, y.point); } -void gt_raise(asym_fp6_t *r, asym_fp6_t *x, ZP_ASYM y) { +void asym::gt_raise(asymGt r, asymGt x, asymZp y) { gt_exp(r, x, y.point); } -void bp_map(asym_fp6_t *r, asym_ep_st *x, asym_ep2_st *y) { +void asym::bp_map(asymGt r, asymG1 x, asymG2 y) { pc_map(r, x, y); } diff --git a/src/ipre.cpp b/src/ipre.cpp index a3bb5ef..0776baf 100644 --- a/src/ipre.cpp +++ b/src/ipre.cpp @@ -4,7 +4,7 @@ Key setup(int size) { Key key{}; pc_get_ord(key.modular); sym::g_gen(key.base); - sym::bp_map(key.base, key.base, key.t_base); + sym::bp_map(key.t_base, key.base, key.base); key.A = sym::matrix_zp_rand(2, size, key.modular); key.B = sym::matrix_zp_rand(B_SIZE, B_SIZE, key.modular); key.Bi = sym::matrix_transpose(sym::matrix_inverse(key.B, B_SIZE, key.modular), B_SIZE, B_SIZE); @@ -12,7 +12,7 @@ Key setup(int size) { } Ct enc(Key key, const int *message, int size) { - // Declare the returned ciphertext and convert message to ZP_ASYM. + // Declare the returned ciphertext and convert message to asymZp. Ct ct{}; symZpVec x = sym::vector_zp_from_int(message, size, key.modular); diff --git a/src/sym_group.cpp b/src/sym_group.cpp index d8b7301..fe5957c 100644 --- a/src/sym_group.cpp +++ b/src/sym_group.cpp @@ -4,14 +4,14 @@ void sym::g_gen(symG x) { g1_get_gen(x); } -void sym::g_mul(ep_st *r, ep_st *x, symZp y) { +void sym::g_mul(symG r, symG x, symZp y) { g1_mul(r, x, y.point); } -void sym::gt_raise(fp_t *r, fp_t *x, symZp y) { +void sym::gt_raise(symGt r, symGt x, symZp y) { gt_exp(r, x, y.point); } -void sym::bp_map(ep_st *a, ep_st *b, fp_t *r) { +void sym::bp_map(symGt r, symG a, symG b) { pc_map(r, a, b); } \ No newline at end of file diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index dd4d491..a486392 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -18,6 +18,16 @@ add_executable(test_sym_vector test_sym_vector.cpp) target_link_libraries(test_sym_vector PRIVATE ppann_lib) add_test(NAME test_sym_vector COMMAND test_sym_vector) +# ----------------------------------------------------- +add_executable(test_asym_field test_asym_field.cpp) +target_link_libraries(test_asym_field PRIVATE ppann_lib) +add_test(NAME test_asym_field COMMAND test_asym_field) + +# ----------------------------------------------------- +add_executable(test_asym_group test_asym_group.cpp) +target_link_libraries(test_asym_group PRIVATE ppann_lib) +add_test(NAME test_asym_group COMMAND test_asym_group) + ## Add tests as separate executables. diff --git a/tests/test_asym_field.cpp b/tests/test_asym_field.cpp new file mode 100644 index 0000000..f304635 --- /dev/null +++ b/tests/test_asym_field.cpp @@ -0,0 +1,72 @@ +#include "asym_field.hpp" + +int test_zp_zero(asymPoint N) { + asymZp x = asym::zp_zero(N); + return asym::zp_cmp_int(x, 0); +} + +int test_zp_one(asymPoint N) { + asymZp x = asym::zp_one(N); + return asym::zp_cmp_int(x, 1); +} + +int test_zp_copy(asymPoint N) { + asymZp x = asym::zp_from_int(10, N); + asymZp y = asym::zp_copy(x); + return asym::zp_cmp(x, y); +} + +int test_zp_from_int(asymPoint N) { + asymZp x = asym::zp_from_int(3, N); + return asym::zp_cmp_int(x, 3); +} + +int test_zp_add(asymPoint N) { + asymZp x = asym::zp_from_int(10, N); + asymZp y = asym::zp_from_int(20, N); + asymZp z = asym::zp_add(x, y); + return asym::zp_cmp_int(z, 30); +} + +int test_zp_neg(asymPoint N) { + asymZp x = asym::rand_zp(N); + asymZp y = asym::zp_neg(x); + asymZp z = asym::zp_add(x, y); + return asym::zp_cmp_int(z, 0); +} + +int test_zp_mul(asymPoint N) { + asymZp x = asym::zp_from_int(10, N); + asymZp y = asym::zp_from_int(20, N); + asymZp z = asym::zp_mul(x, y); + return asym::zp_cmp_int(z, 200); +} + +int test_zp_inv(asymPoint N) { + asymZp x = asym::rand_zp(N); + asymZp y = asym::zp_inv(x); + asymZp z = asym::zp_mul(x, y); + return asym::zp_cmp_int(z, 1); +} + +int main() { + // Init core and setup. + core_init(); + pc_param_set_any(); + + // Get order. + bn_t N; + pc_get_ord(N); + + // Perform tests. + if (test_zp_zero(N) != 1) return 1; + if (test_zp_one(N) != 1) return 1; + if (test_zp_copy(N) != 1) return 1; + if (test_zp_from_int(N) != 1) return 1; + if (test_zp_add(N) != 1) return 1; + if (test_zp_neg(N) != 1) return 1; + if (test_zp_mul(N) != 1) return 1; + if (test_zp_inv(N) != 1) return 1; + + return 0; +} \ No newline at end of file diff --git a/tests/test_asym_group.cpp b/tests/test_asym_group.cpp new file mode 100644 index 0000000..ecff778 --- /dev/null +++ b/tests/test_asym_group.cpp @@ -0,0 +1,26 @@ +#include "asym_group.hpp" + +int test_g1_generator() { + asymG1 x; + asym::g1_gen(x); + // Specifically this line goes wrong... I don't know how to further debug it. + return g1_is_valid(x); +} + +int main() { + // Init core and setup. + core_init(); + pc_param_set_any(); + + // Print the param used. + pc_param_print(); + + // Get order. + bn_t N; + pc_get_ord(N); + + // Perform tests. + if (test_g1_generator() != 1) return 1; + + return 0; +} \ No newline at end of file diff --git a/tests/test_field_asym.cpp b/tests/test_field_asym.cpp deleted file mode 100644 index 0c94261..0000000 --- a/tests/test_field_asym.cpp +++ /dev/null @@ -1,72 +0,0 @@ -#include "asym_field.h" - -int test_zp_zero(bn_st *N) { - ZP_ASYM x = zp_zero(N); - return zp_cmp_int(x, 0); -} - -int test_zp_one(bn_st *N) { - ZP_ASYM x = zp_one(N); - return zp_cmp_int(x, 1); -} - -int test_zp_copy(bn_st *N) { - ZP_ASYM x = zp_from_int(10, N); - ZP_ASYM y = zp_copy(x); - return zp_cmp(x, y); -} - -int test_zp_from_int(bn_st *N) { - ZP_ASYM x = zp_from_int(3, N); - return zp_cmp_int(x, 3); -} - -int test_zp_add(bn_st *N) { - ZP_ASYM x = zp_from_int(10, N); - ZP_ASYM y = zp_from_int(20, N); - ZP_ASYM z = zp_add(x, y); - return zp_cmp_int(z, 30); -} - -int test_zp_neg(bn_st *N) { - ZP_ASYM x = rand_zp(N); - ZP_ASYM y = zp_neg(x); - ZP_ASYM z = zp_add(x, y); - return zp_cmp_int(z, 0); -} - -int test_zp_mul(bn_st *N) { - ZP_ASYM x = zp_from_int(10, N); - ZP_ASYM y = zp_from_int(20, N); - ZP_ASYM z = zp_mul(x, y); - return zp_cmp_int(z, 200); -} - -int test_zp_inv(bn_st *N) { - ZP_ASYM x = rand_zp(N); - ZP_ASYM y = zp_inv(x); - ZP_ASYM z = zp_mul(x, y); - return zp_cmp_int(z, 1); -} - -int main() { - // Init core and setup. - core_init(); - pc_param_set_any(); - - // Get order. - bn_t N; - pc_get_ord(N); - - // Perform tests. - if (test_zp_zero(N) != 1) return 1; - if (test_zp_one(N) != 1) return 1; - if (test_zp_copy(N) != 1) return 1; - if (test_zp_from_int(N) != 1) return 1; - if (test_zp_add(N) != 1) return 1; - if (test_zp_neg(N) != 1) return 1; - if (test_zp_mul(N) != 1) return 1; - if (test_zp_inv(N) != 1) return 1; - - return 0; -} \ No newline at end of file diff --git a/tests/test_group_asym.cpp b/tests/test_group_asym.cpp deleted file mode 100644 index 8272552..0000000 --- a/tests/test_group_asym.cpp +++ /dev/null @@ -1,47 +0,0 @@ -#include "asym_group.h" - -//int test_all(bn_st *N) { -// // Set integers. -// ZP_ASYM a = zp_from_int(5, N); -// ZP_ASYM b = zp_from_int(6, N); -// ZP_ASYM c = zp_from_int(30, N); -// -// // Declare variables. -// g1_asym j, k; -// g2_asym m, n; -// gt_asym x, y, z; -// -// // -// g1_gen(j); -// g2_gen(m); -// -// asym_bn_t test; -// asym_bn_set_dig(test, 20); -// -// g1_mul(k, j, test); -// -// -// // Compare e(symG^5, symG^5) with e(symG, symG)^25. -// return RLC_EQ; -//} - -int main() { - core_clean(); - - // Init core and setup. - core_init(); - pc_param_set_any(); - - g1_asym p; - g1_new(p); - g1_get_gen(p); - - // Get order. -// bn_t N; -// pc_get_ord(N); - - // Perform tests. -// if (test_all(N) != RLC_EQ) return 1; - - return 0; -} \ No newline at end of file diff --git a/tests/test_sym_field.cpp b/tests/test_sym_field.cpp index 981227d..45c4397 100644 --- a/tests/test_sym_field.cpp +++ b/tests/test_sym_field.cpp @@ -1,48 +1,48 @@ #include "sym_field.hpp" -int test_zp_zero(bn_st *N) { +int test_zp_zero(symPoint N) { symZp x = sym::zp_zero(N); return sym::zp_cmp_int(x, 0); } -int test_zp_one(bn_st *N) { +int test_zp_one(symPoint N) { symZp x = sym::zp_one(N); return sym::zp_cmp_int(x, 1); } -int test_zp_copy(bn_st *N) { +int test_zp_copy(symPoint N) { symZp x = sym::zp_from_int(10, N); symZp y = sym::zp_copy(x); return sym::zp_cmp(x, y); } -int test_zp_from_int(bn_st *N) { +int test_zp_from_int(symPoint N) { symZp x = sym::zp_from_int(3, N); return sym::zp_cmp_int(x, 3); } -int test_zp_add(bn_st *N) { +int test_zp_add(symPoint N) { symZp x = sym::zp_from_int(10, N); symZp y = sym::zp_from_int(20, N); symZp z = sym::zp_add(x, y); return sym::zp_cmp_int(z, 30); } -int test_zp_neg(bn_st *N) { +int test_zp_neg(symPoint N) { symZp x = sym::zp_rand(N); symZp y = sym::zp_neg(x); symZp z = sym::zp_add(x, y); return sym::zp_cmp_int(z, 0); } -int test_zp_mul(bn_st *N) { +int test_zp_mul(symPoint N) { symZp x = sym::zp_from_int(10, N); symZp y = sym::zp_from_int(20, N); symZp z = sym::zp_mul(x, y); return sym::zp_cmp_int(z, 200); } -int test_zp_inv(bn_st *N) { +int test_zp_inv(symPoint N) { symZp x = sym::zp_rand(N); symZp y = sym::zp_inv(x); symZp z = sym::zp_mul(x, y); diff --git a/tests/test_sym_group.cpp b/tests/test_sym_group.cpp index 04ae5bf..6fa61be 100644 --- a/tests/test_sym_group.cpp +++ b/tests/test_sym_group.cpp @@ -6,7 +6,7 @@ int test_generator() { return g1_is_valid(x); } -int test_all(bn_st *N) { +int test_all(symPoint N) { // Set integers. symZp m = sym::zp_from_int(5, N); symZp n = sym::zp_from_int(25, N); @@ -20,8 +20,8 @@ int test_all(bn_st *N) { sym::g_mul(b, a, m); // Get e(symG, symG) and e(symG^5, symG^5). - sym::bp_map(a, a, x); - sym::bp_map(b, b, y); + sym::bp_map(x, a, a); + sym::bp_map(y, b, b); // Get e(symG, symG)^25. sym::gt_raise(z, x, n); diff --git a/tests/test_sym_matrix.cpp b/tests/test_sym_matrix.cpp index 45447a3..3822b11 100644 --- a/tests/test_sym_matrix.cpp +++ b/tests/test_sym_matrix.cpp @@ -1,25 +1,25 @@ #include "sym_matrix.hpp" -int test_zp_from_int(bn_st *N) { +int test_zp_from_int(symPoint N) { int int_mat[] = {1, 2, 3, 4, 5, 6, 7, 8, 9}; symZpMat x = sym::matrix_zp_from_int(int_mat, 3, 3, N); return sym::zp_cmp_int(x[8], 9); } -int test_transpose(bn_st *N) { +int test_transpose(symPoint N) { int row = 3, col = 3; symZpMat x = sym::matrix_zp_rand(row, col, N); symZpMat xt = sym::matrix_transpose(x, row, col); return sym::zp_cmp(xt[col - 1], x[2 * row]); } -int test_identity(bn_st *N) { +int test_identity(symPoint N) { int size = 10; symZpMat x = sym::matrix_identity(size, N); return sym::matrix_is_identity(x, size); } -int test_merge(bn_st *N) { +int test_merge(symPoint N) { int size = 10; symZpMat x = sym::matrix_zp_rand(size, size, N); symZpMat y = sym::matrix_identity(size, N); @@ -27,7 +27,7 @@ int test_merge(bn_st *N) { return sym::zp_cmp(x[2 * size + 1], xy[4 * size + 1]); } -int test_multiply_vector(bn_st *N) { +int test_multiply_vector(symPoint N) { int mat_x[5] = {1, 2, 3, 4, 5}; int mat_y[15] = { 10, 20, 30, @@ -43,7 +43,7 @@ int test_multiply_vector(bn_st *N) { return sym::zp_cmp_int(xy[2], 450); } -int test_inverse(bn_st *N) { +int test_inverse(symPoint N) { int size = 10; symZpMat x = sym::matrix_zp_rand(size, size, N); symZpMat xi = sym::matrix_inverse(x, size, N); diff --git a/tests/test_sym_vector.cpp b/tests/test_sym_vector.cpp index 50040bb..7873f3a 100644 --- a/tests/test_sym_vector.cpp +++ b/tests/test_sym_vector.cpp @@ -1,12 +1,12 @@ #include "sym_vector.hpp" -int test_zp_from_int(bn_st *N) { +int test_zp_from_int(symPoint N) { int int_vec[4] = {1, 2, 3, 4}; symZpVec x = sym::vector_zp_from_int(int_vec, 4, N); return sym::zp_cmp_int(x[3], 4); } -int test_merge_vector(bn_st *N) { +int test_merge_vector(symPoint N) { int int_vec_x[3] = {1, 2, 3}; int int_vec_y[3] = {11, 22, 33}; symZpVec x = sym::vector_zp_from_int(int_vec_x, 3, N); @@ -15,7 +15,7 @@ int test_merge_vector(bn_st *N) { return sym::zp_cmp_int(z[5], 33); } -int test_add_vector(bn_st *N) { +int test_add_vector(symPoint N) { int int_vec_x[3] = {1, 2, 3}; int int_vec_y[3] = {11, 22, 33}; symZpVec x = sym::vector_zp_from_int(int_vec_x, 3, N); @@ -24,7 +24,7 @@ int test_add_vector(bn_st *N) { return sym::zp_cmp_int(z[2], 36); } -int test_inner_product(bn_st *N) { +int test_inner_product(symPoint N) { int int_vec_x[3] = {1, 2, 3}; int int_vec_y[3] = {4, 5, 6}; symZpVec x = sym::vector_zp_from_int(int_vec_x, 3, N); @@ -38,7 +38,7 @@ int test_inner_product(bn_st *N) { symGt b, r; sym::inner_product(r, gx, gy, 3); - sym::bp_map(base, base, b); + sym::bp_map(b, base, base); gt_exp_dig(b, b, 32); return gt_cmp(b, r); -- GitLab