diff --git a/libraries/eosiolib/capi/eosio/crypto_bls_ext.h b/libraries/eosiolib/capi/eosio/crypto_bls_ext.h index 8071a16f91..323dbbe6c2 100644 --- a/libraries/eosiolib/capi/eosio/crypto_bls_ext.h +++ b/libraries/eosiolib/capi/eosio/crypto_bls_ext.h @@ -11,16 +11,10 @@ __attribute__((eosio_wasm_import)) int32_t bls_g2_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) -int32_t bls_g1_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len); +int32_t bls_g1_weighted_sum(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) -int32_t bls_g2_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len); - -__attribute__((eosio_wasm_import)) -int32_t bls_g1_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); - -__attribute__((eosio_wasm_import)) -int32_t bls_g2_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); +int32_t bls_g2_weighted_sum(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) int32_t bls_pairing(const char* g1_points, uint32_t g1_points_len, const char* g2_points, uint32_t g2_points_len, uint32_t n, char* res, uint32_t res_len); @@ -34,6 +28,12 @@ int32_t bls_g2_map(const char* e, uint32_t e_len, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) int32_t bls_fp_mod(const char* s, uint32_t s_len, char* res, uint32_t res_len); +__attribute__((eosio_wasm_import)) +int32_t bls_fp_mul(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len); + +__attribute__((eosio_wasm_import)) +int32_t bls_fp_exp(const char* base, uint32_t base_len, const char* exp, uint32_t exp_len, char* res, uint32_t res_len); + #ifdef __cplusplus } #endif diff --git a/libraries/eosiolib/core/eosio/crypto_bls_ext.hpp b/libraries/eosiolib/core/eosio/crypto_bls_ext.hpp index 7a62b57b1c..3676a1e829 100644 --- a/libraries/eosiolib/core/eosio/crypto_bls_ext.hpp +++ b/libraries/eosiolib/core/eosio/crypto_bls_ext.hpp @@ -18,16 +18,10 @@ namespace eosio { int32_t bls_g2_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) - int32_t bls_g1_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len); + int32_t bls_g1_weighted_sum(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) - int32_t bls_g2_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len); - - __attribute__((eosio_wasm_import)) - int32_t bls_g1_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); - - __attribute__((eosio_wasm_import)) - int32_t bls_g2_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); + int32_t bls_g2_weighted_sum(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len); __attribute__((eosio_wasm_import)) int32_t bls_pairing(const char* g1_points, uint32_t g1_points_len, const char* g2_points, uint32_t g2_points_len, uint32_t n, char* res, uint32_t res_len); @@ -40,6 +34,12 @@ namespace eosio { __attribute__((eosio_wasm_import)) int32_t bls_fp_mod(const char* s, uint32_t s_len, char* res, uint32_t res_len); + + __attribute__((eosio_wasm_import)) + int32_t bls_fp_mul(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len); + + __attribute__((eosio_wasm_import)) + int32_t bls_fp_exp(const char* base, uint32_t base_len, const char* exp, uint32_t exp_len, char* res, uint32_t res_len); } } @@ -47,114 +47,114 @@ namespace eosio { using bls_fp = std::array; using bls_s = std::array; using bls_fp2 = std::array; - using bls_g1 = std::array; - using bls_g2 = std::array; - using bls_gt = std::array; + using bls_g1 = std::array; + using bls_g2 = std::array; + using bls_gt = std::array; // group fp12 - int32_t bls_g1_add(const bls_g1& op1, const bls_g1& op2, bls_g1& res) { + inline int32_t bls_g1_add(const bls_g1& op1, const bls_g1& op2, bls_g1& res) { return internal_use_do_not_use::bls_g1_add( - op1.data(), - sizeof(bls_g1), - op2.data(), - sizeof(bls_g1), - res.data(), - sizeof(bls_g1) + op1.data(), op1.size(), + op2.data(), op2.size(), + res.data(), res.size() ); } - int32_t bls_g2_add(const bls_g2& op1, const bls_g2& op2, bls_g2& res) { + inline int32_t bls_g2_add(const bls_g2& op1, const bls_g2& op2, bls_g2& res) { return internal_use_do_not_use::bls_g2_add( - op1.data(), - sizeof(bls_g2), - op2.data(), - sizeof(bls_g2), - res.data(), - sizeof(bls_g2) + op1.data(), op1.size(), + op2.data(), op2.size(), + res.data(), res.size() ); } - int32_t bls_g1_mul(const bls_g1& point, const bls_scalar& scalar, bls_g1& res) { - return internal_use_do_not_use::bls_g1_mul( - point.data(), - sizeof(bls_g1), - scalar.data(), - sizeof(bls_scalar), - res.data(), - sizeof(bls_g1) - ); + inline int32_t bls_g1_weighted_sum(const bls_g1 g1_points[], const bls_scalar scalars[], uint32_t num, bls_g1& res) { + if (num > 0) { + return internal_use_do_not_use::bls_g1_weighted_sum( + g1_points[0].data(), num * g1_points[0].size(), + scalars[0].data(), num * scalars[0].size(), + num, + res.data(), res.size() + ); + } else { + return internal_use_do_not_use::bls_g1_weighted_sum( + nullptr, 0, + nullptr, 0, + 0, + res.data(), res.size() + ); + } } - int32_t bls_g2_mul(const bls_g2& point, const bls_scalar& scalar, bls_g2& res) { - return internal_use_do_not_use::bls_g2_mul( - point.data(), - sizeof(bls_g2), - scalar.data(), - sizeof(bls_scalar), - res.data(), - sizeof(bls_g2) - ); + inline int32_t bls_g2_weighted_sum(const bls_g2 g2_points[], const bls_scalar scalars[], uint32_t num, bls_g2& res) { + if (num > 0) { + return internal_use_do_not_use::bls_g2_weighted_sum( + g2_points[0].data(), num * g2_points[0].size(), + scalars[0].data(), num * scalars[0].size(), + num, + res.data(), res.size() + ); + } else { + return internal_use_do_not_use::bls_g2_weighted_sum( + nullptr, 0, + nullptr, 0, + 0, + res.data(), res.size() + ); + } } - int32_t bls_g1_exp(const bls_g1 points[], const bls_scalar scalars[], const uint32_t num, bls_g1& res) { - return internal_use_do_not_use::bls_g1_exp( - num ? points[0].data() : nullptr, - num * sizeof(bls_g1), - num ? scalars[0].data() : nullptr, - num * sizeof(bls_scalar), - num, - res.data(), - sizeof(bls_g1) - ); + inline int32_t bls_pairing(const bls_g1 g1_points[], const bls_g2 g2_points[], const uint32_t num, bls_gt& res) { + if (num > 0) { + return internal_use_do_not_use::bls_pairing( + g1_points[0].data(), num * g1_points[0].size(), + g2_points[0].data(), num * g2_points[0].size(), + num, + res.data(), res.size() + ); + } else { + return internal_use_do_not_use::bls_pairing( + nullptr, 0, + nullptr, 0, + 0, + res.data(), res.size() + ); + } } - int32_t bls_g2_exp(const bls_g2 points[], const bls_scalar scalars[], const uint32_t num, bls_g2& res) { - return internal_use_do_not_use::bls_g2_exp( - num ? points[0].data() : nullptr, - num * sizeof(bls_g2), - num ? scalars[0].data() : nullptr, - num * sizeof(bls_scalar), - num, - res.data(), - sizeof(bls_g2) + inline int32_t bls_g1_map(const bls_fp& e, bls_g1& res) { + return internal_use_do_not_use::bls_g1_map( + e.data(), e.size(), + res.data(), res.size() ); } - int32_t bls_pairing(const bls_g1 g1_points[], const bls_g2 g2_points[], const uint32_t num, bls_gt& res) { - return internal_use_do_not_use::bls_pairing( - num ? g1_points[0].data() : nullptr, - num * sizeof(bls_g1), - num ? g2_points[0].data() : nullptr, - num * sizeof(bls_g2), - num, - res.data(), - sizeof(bls_gt) + inline int32_t bls_g2_map(const bls_fp2& e, bls_g2& res) { + return internal_use_do_not_use::bls_g2_map( + e[0].data(), 2 * e[0].size(), + res.data(), res.size() ); } - int32_t bls_g1_map(const bls_fp& e, bls_g1& res) { - return internal_use_do_not_use::bls_g1_map( - e.data(), - sizeof(bls_fp), - res.data(), - sizeof(bls_g1) + inline int32_t bls_fp_mod(const bls_s& s, bls_fp& res) { + return internal_use_do_not_use::bls_fp_mod( + s.data(), s.size(), + res.data(), res.size() ); } - int32_t bls_g2_map(const bls_fp2& e, bls_g2& res) { - return internal_use_do_not_use::bls_g2_map( - e[0].data(), - sizeof(bls_fp2), - res.data(), - sizeof(bls_g2) + inline int32_t bls_fp_mul(const bls_fp& op1, const bls_fp& op2, bls_fp& res) { + return internal_use_do_not_use::bls_fp_mul( + op1.data(), op1.size(), + op2.data(), op2.size(), + res.data(), res.size() ); } - int32_t bls_fp_mod(const bls_s& s, bls_fp& res) { - return internal_use_do_not_use::bls_fp_mod( - s.data(), - sizeof(bls_s), - res.data(), - sizeof(bls_fp) + inline int32_t bls_fp_exp(const bls_fp& base, const bls_s& exp, bls_fp& res) { + return internal_use_do_not_use::bls_fp_exp( + base.data(), base.size(), + exp.data(), exp.size(), + res.data(), res.size() ); } } diff --git a/libraries/native/intrinsics.cpp b/libraries/native/intrinsics.cpp index a1db008f82..2eea8ab397 100644 --- a/libraries/native/intrinsics.cpp +++ b/libraries/native/intrinsics.cpp @@ -947,24 +947,14 @@ int32_t bls_g2_add(const char* op1, uint32_t op1_len, const char* op2, uint32_t return intrinsics::get().call(op1, op1_len, op2, op2_len, res, res_len); } -int32_t bls_g1_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len) +int32_t bls_g1_weighted_sum(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len) { - return intrinsics::get().call(point, point_len, scalar, scalar_len, res, res_len); + return intrinsics::get().call(points, points_len, scalars, scalars_len, n, res, res_len); } -int32_t bls_g2_mul(const char* point, uint32_t point_len, const char* scalar, uint32_t scalar_len, char* res, uint32_t res_len) +int32_t bls_g2_weighted_sum(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len) { - return intrinsics::get().call(point, point_len, scalar, scalar_len, res, res_len); -} - -int32_t bls_g1_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len) -{ - return intrinsics::get().call(points, points_len, scalars, scalars_len, n, res, res_len); -} - -int32_t bls_g2_exp(const char* points, uint32_t points_len, const char* scalars, uint32_t scalars_len, uint32_t n, char* res, uint32_t res_len) -{ - return intrinsics::get().call(points, points_len, scalars, scalars_len, n, res, res_len); + return intrinsics::get().call(points, points_len, scalars, scalars_len, n, res, res_len); } int32_t bls_pairing(const char* g1_points, uint32_t g1_points_len, const char* g2_points, uint32_t g2_points_len, uint32_t n, char* res, uint32_t res_len) @@ -986,3 +976,13 @@ int32_t bls_fp_mod(const char* s, uint32_t s_len, char* res, uint32_t res_len) { return intrinsics::get().call(s, s_len, res, res_len); } + +int32_t bls_fp_mul(const char* op1, uint32_t op1_len, const char* op2, uint32_t op2_len, char* res, uint32_t res_len) +{ + return intrinsics::get().call(op1, op1_len, op2, op2_len, res, res_len); +} + +int32_t bls_fp_exp(const char* base, uint32_t base_len, const char* exp, uint32_t exp_len, char* res, uint32_t res_len) +{ + return intrinsics::get().call(base, base_len, exp, exp_len, res, res_len); +} diff --git a/libraries/native/native/eosio/intrinsics_def.hpp b/libraries/native/native/eosio/intrinsics_def.hpp index 7affd102e0..4aac210997 100644 --- a/libraries/native/native/eosio/intrinsics_def.hpp +++ b/libraries/native/native/eosio/intrinsics_def.hpp @@ -176,14 +176,14 @@ intrinsic_macro(alt_bn128_pair) \ intrinsic_macro(mod_exp) \ intrinsic_macro(bls_g1_add) \ intrinsic_macro(bls_g2_add) \ -intrinsic_macro(bls_g1_mul) \ -intrinsic_macro(bls_g2_mul) \ -intrinsic_macro(bls_g1_exp) \ -intrinsic_macro(bls_g2_exp) \ +intrinsic_macro(bls_g1_weighted_sum) \ +intrinsic_macro(bls_g2_weighted_sum) \ intrinsic_macro(bls_pairing) \ intrinsic_macro(bls_g1_map) \ intrinsic_macro(bls_g2_map) \ -intrinsic_macro(bls_fp_mod) +intrinsic_macro(bls_fp_mod) \ +intrinsic_macro(bls_fp_mul) \ +intrinsic_macro(bls_fp_exp) diff --git a/tests/integration/bls_tests.cpp b/tests/integration/bls_tests.cpp index 91bc18ca34..446887c041 100644 --- a/tests/integration/bls_tests.cpp +++ b/tests/integration/bls_tests.cpp @@ -30,78 +30,83 @@ BOOST_AUTO_TEST_SUITE(bls_primitives_tests) BOOST_FIXTURE_TEST_CASE( g1_add_test, bls_primitives_tester ) try { push_action("eosio"_n, "testg1add"_n, "test"_n, mvo() - ("op1", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615") - ("op2", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615") - ("res", "2b90dabdf4613e10d269d70050e61bdc53c6d01ac517ad33cd8e82799d5515dfba05bc172fd280e2a73ff01aca77e30cbf82182b9005141106ef83a6d33dcda8bece738c9f9d6313f7e05945fd92c23a208efbe7a2048c6250f7f14df9f5c215e244ce19aa2759751dfb31f234c644189d4b0eae26beb2ba29a380a052b058a380b3005a7f18391cd44411a0f87d7817")); + ("op1", "aa83970268d80b50a68535d920954bd993217b9114cbe255e5c0b64e748c5683b6518071552148ec555cdb8fed0f07001e76e62761e8d828a74b81f216a0c5ebeb923550cafd110512cec20e33ec9b272c0ff2b88215953945153fc926691506") + ("op2", "e810c1d6ac7cbae0157a0fc958ef607c33e03dee20e72a97ae72de0dd9a0ef20d768ab4b659429255b87feda0be194062a77cd664976e6560b33c921d5968c19a5d5ae9e38c909690975c084c0a4e82481b01e4023b83d6a8ddcb9d38892f50f") + ("res", "145cae227562a69bbf270b8ec8d1783bed4ad0fd43e9c81ac5caa7d3e7feaa3acda07d6033ece1f7f0649d6b75009a03e83ab8f9b44f94c4ab762611266b7a530ce05092ad38b7554a95caa2b63ad0969a902d69f34531dbccf8a4f2e12cf60d")); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( g2_add_test, bls_primitives_tester ) try { push_action("eosio"_n, "testg2add"_n, "test"_n, mvo() - ("op1", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - ("op2", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - ("res", "1987cff592d8ae5c83ba9e9a1a016afd3a4e80d646e10a1274ba259b60a405c189945d07b3608d4d339a96429d60f80d8290d66f4e963c0e8c00e35db541ab46e93148fd7e41449f0be0a1883e36e4b56cf87121991d6d4778d499fdf1501c09a9220f11cdfe60560b15d7e6ec33825a8d9ce209fe8e20391d32210ba83dbd77ce4cd6019ca50465f8f5fed4a8a631048739c8d9b8fdc26a962b24f0306f8293a00d72d37fb2fb1b0643d9a8453cbf6a520463a54e25e8c42134d6798d7cce00949892c0f015e698b4386dbc3ef4f9b2b4c61454d90acdcfbf921adcd26bdf77454bdee1eb52a70fcab501fd1cfb0701ba60c9be25f9815bb9c32856144e543140d7c977d4585b0d75467b929db892f2da957948a1b02ecee537bcc742855716")); + ("op1", "a75a447bc0dd806bcdaee2cb429498193e409a4d370dfe0e9605c5a9ec4a09c0314c0321f2f918b72e5f37cf10ea7e0b69ac1a7fb3200e63e5cef9929cd2d9afde2fb957989e610c5b44649af8649d968baa0424b873b501be32c66ef040240b469127753f17ca28a072c2151b69d51fecff1ed0f4786b4e6fd4e52ec72f95ef73cf19fc2d6a28267bdf11a262b403110c2e901fb32d0e900082e4934a20c1c06c262533488fd7f9f47e4e2fde102fe98fb48344de25712d5e2e2887bc04d207") + ("op2", "11cc3115ad08c43ed0b7fc3945ca83c69d0a6663f05b25373ea3fdff14c722a7fddd7a1b4f1cf44290e1c480f50b6208419f6a208ea48a48cef5a345a35c052cf0db4a76c719eb90a5829a8f606e99c807a6ae71493f079c364d57f02cba7c124f344978bb539bea7c448eb96ccea9b6c7b7d2495212b88227fc269ac88391f4a6d23e2d47d4fe47e63f8e709b61450644ba13c08e29770bc397da41466cb26c9fa7a1ffd9b5dd5c51c3ddbfb88412998e41f72e63b7972dfd856b9f11530c01") + ("res", "d9458632a7cfcf59e72cf6d1ad70ec8d65d9e81edd0da77c2b10ec4d2a4169f1b0ac46419796d3ed6ef66b34eb76651288d916a5e5b44e75cc849ecd257a223398f92683f2318bf5fe7aa2b5d45e97dad6c415dac4b9cdc1c72071a4c9845c15096b203deb2e071d3856983cb26a101eb193cbfe914000ade94a62339b2e418c4a53578fb177af1986cc9dee3ce9ff0f9598925cb7e5a29af31404fa8cd9c22e17eb1a44b6b461dd9b7dc4d384ad60b82d94e431a389a244b1724a5441ac6009")); } FC_LOG_AND_RETHROW() -BOOST_FIXTURE_TEST_CASE( g1_mul_test, bls_primitives_tester ) try { - push_action("eosio"_n, "testg1mul"_n, "test"_n, mvo() - ("point", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615") - ("scalar", "2a000000000000002a000000000000002a000000000000002a00000000000000") - ("res", "de3e7eeee055abe12a480e58411508d51a356ff6692b14b43426d22cc354cd5d7469c41e0f1f5e40503c91e11419a30285cb057a62c93e2caaaff6c9c1dbc8f88c0a122157f51a617ce0e2890442cd9ce004a8ba972442e61bce9dabf1c6780c191984ae3c11ef21884a536f0d3450974df37295e9579d16cdb8dfdf9252091ca3cd9d05f4c6e645535add05ac197b08")); +BOOST_FIXTURE_TEST_CASE( g1_weighted_sum_test, bls_primitives_tester ) try { + push_action("eosio"_n, "testg1wsum"_n, "test"_n, mvo() + ("points", "7a63674c35f9f2be4f0ec092110b82fad24a283316a846d960843b9a6a8a98bfdabd7e897b7da774fbbb05d7ad95fb18940a5f7a7345e1821e0203e156d677e88445385bc0779d25f51b772be3c3a6ba0b09b2533a8ee66053b2f3c853994112e74a97324685e515c86d44ff5a3ef5218e53c6f29e7df49a546c79cd1fb9d14e63f68aaf6b2df1f6f56e6250fdd6f20dcc36499a5aea69f4c77a18774eccf8460e77ab6b0236ce2d85083faeacf0f3378a3dcc95e1d3b0ae282b9bbec1ecee1793e63ca4730ec63df496546c07094e848625610a514d99dd0a6dd9f58d15c4e4ed5aca65025562177ebd0a4c2c3ae8139d24be936dd5dbec6a54897ba2a98a68a9c43ea3199695896789c958bc289a7275550b5670a351b262c10166a48baa161f841df4255408abb7186f78647422313fbe3a0a35699a487dd71482b76b8adc20622f44bb32e04a78b98e4f2cd42f16a6d35ec2463a484906dbb655969b900a15cc8a47694b1961bd4b2e9f074afd79e4c04344d31dd8fcd56d5147a9a47712") + ("scalars", "2be3984dc7a5c9e6172df42c905be929ce5bb29d9aa31a03f3ed8816e7d1265a0669a674fef9254f0efffd3e89c30f1f05587472251d362e1acea03a76918d137b322778b8188c1bf68c36ef8e0ce933290c67f981611c13a286e42235f89855e49966a4e9ad8c64122f4f5e720986193e59771fa91aef113d8739642bdd6613") + ("num", 4) + ("res", "25038aea2d2d1c15dad2fa4c6e31162d1b79ca1b1bca608190a05dea451701e9fc95a8c441a25083df7fa56d54eae51241a8c9489719b9cc35852ce3d7e04b5ada5c65f45d1818f80ea161264b70ab6fa86e694691281b8110000d209aea5c17")); } FC_LOG_AND_RETHROW() -BOOST_FIXTURE_TEST_CASE( g2_mul_test, bls_primitives_tester ) try { - push_action("eosio"_n, "testg2mul"_n, "test"_n, mvo() - ("point", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - ("scalar", "2a000000000000002a000000000000002a000000000000002a00000000000000") - ("res", "aa25f3f539b6f3215318d81b22d14bf9108294790e8a50545a404ae2057278304d8c3b5844271202b757767d1555a106ede90a9967cdc27b527d4a5720efda79a68b17072ad9402ed373ce9a2d28f5496106fc4cd23234b083181e8325734417f8330d2ced14040b815a006f7f905361f654d483c45abb90b4a958b4ca20ee2bb97cc1c9b6ff45644539abb32149610f33858c88450dad3d2adb82df72f9ed9c42dc2ef78e17f5a2a1abd0468853d55f05f6458179fdf5671db784795a686c0ffae139afaed0212d18d615b0ff90a9deba090f723190521dc8c822621b0a7e70a03b9f3faaeb862846dccd418855d70406fc57e73783c2da92433c1a3873640217539ec7c01f3d354506d86db49fddad225e82421506d99c19b749170aa4f805")); - -} FC_LOG_AND_RETHROW() - -BOOST_FIXTURE_TEST_CASE( g1_exp_test, bls_primitives_tester ) try { - push_action("eosio"_n, "testg1exp"_n, "test"_n, mvo() - ("points", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615") - ("scalars", "2a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a00000000000000") - ("res", "9e80ed609e62978a3a7f0d6bf57e1df4070725c1bf4dab43a6b710adef7450fb41f0cf14a7895ec26fd8c830c327cc0e2c8fe7687d23ff84647b47bbad04cf77625dee1049e53ad5162fe772278e5fe3ceb0bdc472f31952343da7b75532f7016613af892092131ad77d13afc8c9192487ac19f8454ad932653145f06e25790d26b23ac6b83025326f3397efbd845511")); - -} FC_LOG_AND_RETHROW() - -BOOST_FIXTURE_TEST_CASE( g2_exp_test, bls_primitives_tester ) try { - push_action("eosio"_n, "testg2exp"_n, "test"_n, mvo() - ("points", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - ("scalars", "2a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a000000000000002a00000000000000") - ("res", "595a2cbaa4315ecc0dd9838a81712e0cfb88cb2c4468640ff382abb321b3a9bedebb0aad985a9057f664fc52eb52cd194b1c9611b25ef4281e439a52d1832813decd66c22440821f0288dcb7a82151386aa0240e943b6905e61619be2e11c208fa03df16e11a1b1368abac90598bb237f785701d5d1d5cb0af6934ed633d366de28703431b8d70899d92797689207c0cd35c345460f971dff5d648d9ddec8f5fabef99b15ea7c4440ac1564d6e0326076f32a4ec9cf0d10059593d64afd35c03d10f16794821628b565c9319f4af3c96b98c4fb11bc0c04172bb57372531f6e76798142d4b00488adbea850a2649a305b71fa389c3c226f2df4a58c8bce5d90698452f4126046be0c82d8817b64162a53787f1cb73af27d969adc626c1392716")); +BOOST_FIXTURE_TEST_CASE( g2_weighted_sum_test, bls_primitives_tester ) try { + push_action("eosio"_n, "testg2wsum"_n, "test"_n, mvo() + ("points", "556524e3e80fcf448c0befd659ad744c409cdd1111291a81949324a02688999ab88e6ccb3e9dcecf57ccfe9aa7ada21540ba5407c0700ce81578bcee892ed385dd1ed476c465fe48cea2dd7e37784d8ae795fba842ce0f88baa76857ec1c7c137163beed84ff2c6a159d486d10c7128b2cbb6f10c547d202d0f6e68fb43a9a6a18a01823c4e70b5dc25d38b9c33d4916510de467f10922f3b284855c4accc816f542fe74fd0b331b1884dac6918d3c38860b0725809a19b6101e5d3942b9f40eee6901e17a0c50187e6385767b7d1e54eaacbb3c1939e2e995ec79569dd0200583a937891035475e1e5a733a0446f7063e77f9d564c60dfc6dc25572369bf7fe51b2607f73fd0fa9eee9d27b127a81c63bbd7f08dd64237d082e9735018d96024c56d32b55e991e84f39c6ffc0d56ef17307e82fc200df9259f83b7bdae719124f7151d855b8f51f703e087ea1540900c4eba1592de051db895689aeb5233dec52ccb74f93acc8fc14bcde4413a14dceb0ec386623021ddf9ad1fce429e1780c5a6877b00b17af384fd49b7077434387672218967f4a7647174162c07e99d9007380be10a7bef367181ba886a0e40c160a4b36548826c30710ea8238b0c37ec06e331fe1d3aaf1b5a73ae0880794d0c0a9623b8498d9bbd4754e1a8c1e2346091fec42aaeddc40f2ae06456e8ad9059c61db437089a855af3d1bc2a6d68e9c01474bdbaabfa185a58dba9808f8e0b20a3c51c51c5bca629aa061dfa5ff238a43e1e90242df403635869743c723276c0eca711c6c91b94a65310b6b869ee556179ed113a2b406a52de2fe54f61f4589f510924b2e3f8b14ead1541af2e1cc9dd35a91f6cd4bbc02c58a844d9e4906a106197b8ab39a539561aeecd265762bcf5106344ae2fe0a62c7af1bbc846e9b39ebe38a046461d7c0c4901caddb0fd7c70b86246d53bf3124af629596f6367e86f3456cc954e3581bfea600b6d2818259332fedeb88ece673626ffd4d5935d0310e5cf2462055d5fa4b6cc4531f11cf0722c8647dbfc7364c9b2e24e0066ef5b0e3497ce38537a7230e02f7edc2f53e980f") + ("scalars", "e5a6afde5d144ed43bd1742b7ec7f5385a7d392f65465927e37afe7b9f0a9e368449cf52e36ca432b096f8562c98f318216d21a426b2d51f0a4db8fcafcd687326b548cd973f30d4fc47d79d853ec94239c620229ea0632b2570a1f8df08fe1ce323ef2cad610917a13d1157e25fac05ef6bafaa68e8ce265594d207a5d13c1e") + ("num", 4) + ("res", "889d8b750987cbce4aa4b872b29f22011752354e672b24ad4b229ca575ce14a8c081366db5cfd0f7a85ff68559bd4216b3cecfb6a2618a29c6c95b17147d083f28cc1fae5959fd7de74d986e7fd543ce1060cbdd8d4ae136910d8a15a1b3ee16d955657630d5f50aae107d13aa0c46040616e2d3018e5d07f9551e2a4c34565c9b59b8fd7751e025f473772120b4a511946e09fc93dcf9732399244c1fbb864fa09c2dd5d29543e794e64b6e1a2df39289245ff4b65dff0357a6621d151e4514")); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( pairing_test, bls_primitives_tester ) try { push_action("eosio"_n, "testpairing"_n, "test"_n, mvo() - ("g1_points", "160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615160c53fd9087b35cf5ff769967fc1778c1a13b14c7954f1547e7d0f3cd6aaef040f4db21cc6eceed75fb0b9e417701127122e70cd593acba8efd18791a63228cce250757135f59dd945140502958ac51c05900ad3f8c1c0e6aa20850fc3ebc0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615") - ("g2_points", "100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000100a9402a28ff2f51a96b48726fbf5b380e52a3eb593a8a1e9ae3c1a9d9994986b36631863b7676fd7bc50439291810506f6239e75c0a9a5c360cdbc9dc5a0aa067886e2187eb13b67b34185ccb61a1b478515f20eedb6c2f3ed6073092a92114a4c4960f80a734c5a9c365e1ffa7c595a630aaa6c85e6e75f490d6ee9b5efbba225eff075a9d307e5da807e8efd83005db064df92fcc0addc61142b0a27aa18a0ebe43b6aacad863aa33dc94e5c4979edca3ca4505817e7f21bde63a1c22b0bfdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000") - ("res", "af587ca8f5f0760b888e4ec66748623d1b13986547b5de2042ce89233c2c837bbb080329a505285c948d8bb4c88a5914ae216a64db582ba084178db4364a7b3843ef7fb9056a90526d27dc9e252b38600fc54ce7a5ec15771c555816edc26d0166e75d3315789c846387c8c234b1c98b50baf233b7312aa317ae56a2bfa170b1bc43f0e046b4a1f45cb7aacea7d0ae0320496e3960d4dbc2039027ba8cfe1ca120ea98fa94cf25034ccb5e74033f447b837a78b03affd44b87f865f3d713000de78ab5629dbde8d0c8b7a28941717be3ebd23924cf16897144bb69730f68bff5a109fc2e6d563b15e2eb883cf4becd11edcbc2ec4402c93249389ed612fa0396ed6eadcbe4d703667d46b0150ee3a5158caef956791e4f527e1312c8402f8509acf7001dc0dc311549d76398c247e79b737b614d0a6663f7dbdb314e5b51eace14457ee7b1f3f54d5987c16c8f89d1022d91d4649f5f6a204047077e5791a654cd2277506cd0af77f9ea789278b364c115ec07ba14390a9c22d59aa9c97a9c09ce025b5e14443f3c4e4cd602ef34105fadd82837fc5ce60a461e6ea11b13ae67b82e3366a2b2d1bbe78b2579173b3c0c5aed88b2949403060c3e065782bcb742c55c559e75e373293d80dec54120773d80144b21b353ead58dc8427e5b9cbd0c1431f1a74caf5f57c4b55b89810029cdd24ef4a029797ced68ff882492a8f55f31fe52217356366983e35d2a5640e818cc8bddf9274de0100e624a6bf03e2b9ff22f8dda09a46b50b1b305cb6adfa2ae775febbce4a2b507cd2390db968ceb13")); + ("g1_points", "af7d28fa69e9ff7cf98da7614f02faf91f8ae2888d522db1a225724394bedd8547ae93cb07b41f5f21092846c6c2950e43328c2e6aaa18cf735a703f4ee43a60658167b9c1bf895ddbc898dae5269a335699c595aa9dc4137103d5480320270f756a4c35700b847a02d4933be43e508139affb438b7bcf547debcf9904f1056d197ec8484283e2f194430e16443d250f0b4734d5380cac631d6287e2b45a6a12fb5fea3eed96a7b2cd3bac9a532e4bb6176b1e792964444798e5bf151e14c314277fa052e05911619c457335e708633aca11239a33686e56dd949e6f50e5fe79f1d069bbb01822566f992299184ddc06d08c662a5d2b37668c7821bef5177ff4df977799dc81ae15d0444be9a54db2195d41e316f7ebdb7d879f8f7b355cb416137401a36684f0ccbce51fd4d8b32f45d81f2c33bc95687ed777e7fcb181367e163d94356c96d239f193dabf01616d13936ba746ed9a64578a5a4b191238fe8472e4135525afcac4ed818c13e518864ce82de26a6bb1066b9c0771c021716603") + ("g2_points", "5528fc322669dcf2757583835b5ba5cc84f629db47e1d5e3ec78523fff567ec26100b7977ba038586c9e465abbaeb603554afef9cfe21ac33847b1d11796088cc6b18c7544355da3f996ddb0c0a15c8b1eeba2ec3a5cc8c7b4a8ecc7131e4609582cc42caa57f68017f95af50757bfc0d3c4d4327d1d40012af8f664da428f1984bf17c26d43b6fd65a8ce6c3d039d03f1247385a3f565108de722d4e08b0e9d23bba036646668167bdd41709ebe8bf5aadbd88ccc2af0c6d5940531c9fd50053e786ffe9011554db15fc7e130ea07cd254f21a86911fe758517274f96b89cb67e30c104186c4a6cb0d92cb82e39260245b68e74bdb828992697a1957be0564a9863f56eaf36bb5fc4d0869468b6ad4e36a1e7c550303c80c4ca0cbae773b309a61c6d4d6a4d2f17a4424c1987d294f195275581c8b8f88b7ce7fec5bc67e7bfd58bb747f39aa4dbc77d79cd18dd09142b10a45d49abc8fd544281f02a0e045062b72b25ead1a376e4f705ac83ad2385c84a8fd914d2f6a71d7eeb7126d677001013a0df759ff906a09fe4a3da307dd6cc17ee1fd72af8f7d953662be427cda2985cb1073563bbea492d9e6a96ca8a05ca5d45d349cb3e2f09cff6022a9916324eaa4fe5c543d46cafe5f82e81c5baddc2cc58100b03a20c2feaeed58cbd63019b8e3586d14193470d4ee9c1a0fc5e0a736e1ba94d7ad20ead3a3dacc4b2f3530ad751daffa944be4cb1969b3d2595058007d28d49e2fdebab68607c119b77d766785ed9e209582c737fce93b6ad0d4d795f86415238e0d3b70b9d8954d6a20ce85e7128588a849c505d5d2c81ff63bf12ea3ad52a316316ce49b2014dfbc486c9934dccb98db06089c03dc8f76ad70323ada12fe7e5b9f552c5b6cc073f72409a6e44f6634ca58bed30649b9840f177ea0039932f81574ea22b6da18b702f0e367f633e41d2b585d5166669f4c48d389f003eeecf06b5aa119d0df46de26adcb938d362e4410fdaa990a6fc4c2eca0f7bffee724789a0a47ba1b531bb4a3c95c129585ba5c9a6fe978a6915f4afedeb710ef6a55f153a5b21f943de6531680d") + ("res", "01cc207c7c76c65afc059d073106d545705af7c4e4ed78e6169c599bae1c9bf6358d5a2cdfeeae389cc64436dfe7b7192c733fe9e2d105c0eaec21589d8bb5ecd5c71a5fee083af47a1cbc3af2df8a13603a78956c39f55fd0663ed482846a047280f87426ecde4c535c0d30bdf4b95ff5aff45782129ee6c7a0fa20a632bc98e95bfb663685eb2443e4b1f518c40f00502303b3db49be61f36ef6af46b9097c83835a864ae6337ef07e40df617af1aacea98c0d75e96a104d41a3617e7a4f05fc1cdcec57ea40a0237ff387a5d9130b34c92cb57a3450080bbaa2f6f9e895851b05c05eec03abd2d5083c81c402a500d2bec4895cf0f58a9953e43ee9039a38ae73cc3ec325fa636777e1f597b69a2b6a62bd49fba5b163bc03ce73f277f818fad1c6681fa59be891c2baf85b6a5e908d96b6a6c4cf3d53b3de23fdade91b3dde7199648aca0fce1d2307253bf57b054a4c4dc276034f8d57017cddc0a84975c643f9ea808652f2cefea32f767fe8e6df58a837c47c3136ced7107e7dbd9711399605212e6a1b8da806a12636076f7da0629ca8173f0411ba2a1050d1bca61994e28f69f274ec94e016a3ba6f9a6b06cd17f570928b5e4b8c75a5d62a0a67bd54249702923b440355db775599ea7be7cd3c6d88ab8da7694e43352837b0080814880a1460bc61fae141d36f961db8393313f74a65c3eabcc38793b84062999364bb0c36a415445ec4318b59c16e850260a53e7aaaf72bcaa568b57b69b552bf827c3e1c116565122322d6c26e14354fd96dc4bb1161ede0ee36efeeae1a5503")); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( g1_map_test, bls_primitives_tester ) try { push_action("eosio"_n, "testg1map"_n, "test"_n, mvo() - ("e", "c93f817b159bdf8404dc378514f845192bbae4faac7f4a568924f2d9725125000489408fd796461c288900add00d4618") - ("res", "d8e09005badb694b1e5dba8476ba3012cd2bf0c472ee1811ac9b34c869638b47e669bce16933e98ce9b129f83d93d71890d6fd13b77d4ad8df1a5f1c6b81df2b3f305721b7b7874cd81eba23ca05e8bc974b14f7e4c2c77cbdf321c340ba4903a2a46af290abe078e426f913e492b8d9b997232dbe6198aea719a31e73b40e110c4efa9e42d737a42883e0ca5f344d02")); + ("e", "6de1c03023f2b4e454559b97266ebc1f96cd5510c4f48e2acafbe73a536a1477f2c8d1c9b5f6615d01968ea59ef4fd07") + ("res", "2c7390d4bfbe0ccbaae9699aab5458d62f6d1aa91938b0ab0717249ad89209cb14ee8ed764a8952415382dbbfdef2312d5b2988b1ed7e6907d73ef2335cba7f9263b63003effa44ab8d6805d6ed0f08d87919230f0cb45d9ec35b2e0615d920f")); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( g2_map_test, bls_primitives_tester ) try { push_action("eosio"_n, "testg2map"_n, "test"_n, mvo() - ("e", "d4f2cfec99387809574fcc2dba105603d950d490e2bebe0c212c05e16b784745ef4fe8e70b554d0a52fe0bed5ea6690ade2348eb8972a96740a430df162d920e175f5923a76d18650ea24a8ec06d414c6d1d218d673dac3619a1a5c142785708") - ("res", "9968ae9e9bf3d22ec6c9670efa64ea23d4966b41bb25f76ea2ef71b96fa35e031adb866b3df234065b9aa72d0b12ab14978678279eb944f05b5af53d91e700b57aa87076727def2e9f2fba3cf6784a25591ae1669c2cf15cdcf038b826d1e81178bd7b59b7e911e0c2d11d6805756222201e3364f8010fb651939eca63f7e77709042ee1030cd938f53905a714e815112a7dfeed207757d30382f69617014bc683a175d0dfbd74f2684de26c771f3f55a538e6d2f969eb282bddfec4fc08dd18f37df0889292f288dff631b02f07b88134410fd86526d234d75b9a329bc9a8b6e71c7ad516b87af9717d962cba5d2b19fd1b77746f1e484a54e6aec81ede148f01e2c8283c598a4976182d2ce287fe6888e23996ce03b03ce6709e4aa8e66416")); + ("e", "b4108d552274d175fd4e52dd766ff396a4f365c102e0ef7b4d266f220ec67eefab48ac15d1db0d98ba31cda435616e0bdeb51952b044ce0f64b5d42199d9560ed0175f3d2c58af07909d29db4480c1b417dfbf7f1af274648adb54b029e38f08") + ("res", "f74a6a357dc6a1fb33344f60898ab9eb29c68170727136b26d943249fbbd9393bd893846ea0d43250d4fd37737e49f1463d11827561e80cda0f6ead2cd3c84d4be6d99d61fa4cbc41cce534af2cf3d1b3fc31ccecc1259cfc7530a93c58e801951454f38f693d2d763e0f993c202151d873eefec3e90507cea6232cb3c0061f254a2f4b5872098b23362763a79d6c004333e0e02ad077c8a3683d63827becf20c88a9b7a63bbac739bc3a4f659d119df2f5853e371a25c803fc8301c393e7804")); + +} FC_LOG_AND_RETHROW() + +BOOST_FIXTURE_TEST_CASE( fp_mul_test, bls_primitives_tester ) try { + push_action("eosio"_n, "testfpmul"_n, "test"_n, mvo() + ("op1", "AAAAFFFFFFFFFEB9FFFF53B1FEFFAB1E24F6B0F6A0D23067BF1285F3844B7764D7AC4B43B6A71B4B9AE67F39EA11011A") + ("op2", "AAAAFFFFFFFFFEB9FFFF53B1FEFFAB1E24F6B0F6A0D23067BF1285F3844B7764D7AC4B43B6A71B4B9AE67F39EA11011A") + ("res", "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); + +} FC_LOG_AND_RETHROW() + +BOOST_FIXTURE_TEST_CASE( fp_exp_test, bls_primitives_tester ) try { + push_action("eosio"_n, "testfpexp"_n, "test"_n, mvo() + ("base", "AAAAFFFFFFFFFEB9FFFF53B1FEFFAB1E24F6B0F6A0D23067BF1285F3844B7764D7AC4B43B6A71B4B9AE67F39EA11011A") + ("exp", "AAAAFFFFFFFFFEB9FFFF53B1FEFFAB1E24F6B0F6A0D23067BF1285F3844B7764D7AC4B43B6A71B4B9AE67F39EA11011A00000000000000000000000000000000") + ("res", "010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000")); } FC_LOG_AND_RETHROW() BOOST_FIXTURE_TEST_CASE( sig_verify_test, bls_primitives_tester ) try { + // assumes signed message of std::vector msg = {51, 23, 56, 93, 212, 129, 128, 27, 251, 12, 42, 129, 210, 9, 34, 98}; + // vector seed(32, 0x30); array sk = secret_key(seed); g1 pk = g1::one().scale(sk).affine(); string pk_hex = to_hex(pk.toAffineBytesLE()); + // g2 sig = sign(sk, msg); string sig_hex = to_hex(sig.toAffineBytesLE()); push_action("eosio"_n, "verify"_n, "test"_n, mvo() - ("pk", "90ace8f520a5e056eab099d4e6a6f761a8f51301e1e15910908453007d94e33f8e86b834808dcb5323313153be066d01d49660f594a805ad9a4249d0af4190407e3e221e1d6fdad866e022308357776ed5e396777c7f7dfd020e7d736511ac06fdff02000000097602000cc40b00f4ebba58c7535798485f455752705358ce776dec56a2971a075c93e480fac35ef615") - ("sig", "3c38a59a6c016fb598d8da531e205e4d8e0953868675760f8333c7fee725d81ddf246db75792eb7cf0ab8aeba051800babf407ddd8ec721db83fe1b1098b9334bf45ad63f10cf5a6b56b60f74b391615d7373088d182711358a6032f8c31fe1694ff3f3254a7e02e3e2811ce0becdec6031b193b5541d577b49cdb6cf09f919917b09776b1f05c977ffa17c2de876205f402f7e4fb00896cb9b3df1a25f761239e5625ddaab4bfacce8e6c505c13eb73632b12cedd30b0804fe29f317015c307ec2dfe48cb5060d84fd2c2756f41ae79f4c0a3a37ba62b22877b23042bb30a063d4ad3255de844545e89f0886041b513410df52d380fac23c31277997381115651c02014a9aeeaaec85c34b81a93ee73cd712ce241f394dc860ea5e792b0f50e")); + ("pk", "c27efc440ed89d739ff80f1c7178d4672d5f71e8c8926a85785d0f84074e79c1662c522fdbd6fcaebd640d816dea6c0dc36c5d7e7a297afc960369e306d845fcad0e5fe2a88c0d3bbe854d4f9e3e6365c9c1003662f0e81b35fd9c6a11d0a10c") + ("sig", "e13a38c18dfad440a9af8d720bfb9ce0f388a25a5789a8cdc34b87204fe29db5cc16658a5d9f4fa4a7cc16b8ef8d2d0d1a5984e6b69ca228692f1920e9340f149024b4d856711656f11bb1e0c7d081e5bb80692638a9bace2d8f4d796b4887129c59fbb7901997cbbb681f709291a45315979f55b719dfc8757d3a878cf01e4a48a0e6647b837d0ea8aea5d41e121b0dd37fa20007aef4f51740d846cc8d6ab151dbd88964e7d19890a500d5537be81b881451b75f928a66f546441d45028603")); } FC_LOG_AND_RETHROW() diff --git a/tests/unit/test_contracts/bls_primitives_tests.cpp b/tests/unit/test_contracts/bls_primitives_tests.cpp index 1b97e8a338..12ef0b7ad6 100644 --- a/tests/unit/test_contracts/bls_primitives_tests.cpp +++ b/tests/unit/test_contracts/bls_primitives_tests.cpp @@ -198,35 +198,35 @@ class [[eosio::contract]] bls_primitives_tests : public contract{ } [[eosio::action]] - void testg1mul(const std::vector& point, const std::vector& scalar, const std::vector& res) { + void testg1wsum(const std::vector& points, const std::vector& scalars, const uint32_t num, const std::vector& res) + { + check(points.size() == std::tuple_size::value * num, "wrong points size passed"); + check(scalars.size() == std::tuple_size::value * num, "wrong scalars size passed"); + check(res.size() == std::tuple_size::value, "wrong res size passed"); bls_g1 r; - bls_g1_mul(*reinterpret_cast(point.data()), *reinterpret_cast(scalar.data()), r); - check(std::equal(res.begin(), res.end(), r.begin()), "bls_g1_mul test failed"); + int32_t error = bls_g1_weighted_sum( + reinterpret_cast(points.data()), + reinterpret_cast(scalars.data()), + num, + r + ); + check(std::equal(res.begin(), res.end(), r.begin()), "bls_g1_weighted_sum: Result does not match"); } [[eosio::action]] - void testg2mul(const std::vector& point, const std::vector& scalar, const std::vector& res) { + void testg2wsum(const std::vector& points, const std::vector& scalars, const uint32_t num, const std::vector& res) + { + check(points.size() == std::tuple_size::value * num, "wrong points size passed"); + check(scalars.size() == std::tuple_size::value * num, "wrong scalars size passed"); + check(res.size() == std::tuple_size::value, "wrong res size passed"); bls_g2 r; - bls_g2_mul(*reinterpret_cast(point.data()), *reinterpret_cast(scalar.data()), r); - check(std::equal(res.begin(), res.end(), r.begin()), "bls_g2_mul test failed"); - } - - [[eosio::action]] - void testg1exp(const std::vector& points, const std::vector& scalars, const std::vector& res) { - auto num = scalars.size()/sizeof(bls_scalar); - check(points.size()/sizeof(bls_g1) == num, "number of elements in points and scalars must be equal"); - bls_g1 r; - bls_g1_exp(reinterpret_cast(points.data()), reinterpret_cast(scalars.data()), num, r); - check(std::equal(res.begin(), res.end(), r.begin()), "bls_g1_exp test failed"); - } - - [[eosio::action]] - void testg2exp(const std::vector& points, const std::vector& scalars, const std::vector& res) { - auto num = scalars.size()/sizeof(bls_scalar); - check(points.size()/sizeof(bls_g2) == num, "number of elements in points and scalars must be equal"); - bls_g2 r; - bls_g2_exp(reinterpret_cast(points.data()), reinterpret_cast(scalars.data()), num, r); - check(std::equal(res.begin(), res.end(), r.begin()), "bls_g2_exp test failed"); + int32_t error = bls_g2_weighted_sum( + reinterpret_cast(points.data()), + reinterpret_cast(scalars.data()), + num, + r + ); + check(std::equal(res.begin(), res.end(), r.begin()), "bls_g2_weighted_sum: Result does not match"); } [[eosio::action]] @@ -245,6 +245,30 @@ class [[eosio::contract]] bls_primitives_tests : public contract{ check(std::equal(res.begin(), res.end(), r.begin()), "bls_g1_map test failed"); } + [[eosio::action]] + void testfpmul(const std::vector& op1, const std::vector& op2, const std::vector& res) + { + bls_fp r; + int32_t error = bls_fp_mul( + *reinterpret_cast(op1.data()), + *reinterpret_cast(op2.data()), + r + ); + check(std::equal(res.begin(), res.end(), r.begin()), "bls_fp_mul: Result does not match"); + } + + [[eosio::action]] + void testfpexp(const std::vector& base, const std::vector& exp, const std::vector& res) + { + bls_fp r; + int32_t error = bls_fp_exp( + *reinterpret_cast(base.data()), + *reinterpret_cast(exp.data()), + r + ); + check(std::equal(res.begin(), res.end(), r.begin()), "bls_fp_exp: Result does not match"); + } + [[eosio::action]] void testg2map(const std::vector& e, const std::vector& res) { bls_g2 r; @@ -336,13 +360,17 @@ class [[eosio::contract]] bls_primitives_tests : public contract{ } const std::string CIPHERSUITE_ID = "BLS_SIG_BLS12381G2_XMD:SHA-256_SSWU_RO_NUL_"; - const std::vector G1_ONE_NEG = {0x16, 0x0c, 0x53, 0xfd, 0x90, 0x87, 0xb3, 0x5c, 0xf5, 0xff, 0x76, 0x99, 0x67, 0xfc, 0x17, 0x78, 0xc1, 0xa1, 0x3b, 0x14, 0xc7, 0x95, 0x4f, 0x15, 0x47, 0xe7, 0xd0, 0xf3, 0xcd, 0x6a, 0xae, 0xf0, 0x40, 0xf4, 0xdb, 0x21, 0xcc, 0x6e, 0xce, 0xed, 0x75, 0xfb, 0x0b, 0x9e, 0x41, 0x77, 0x01, 0x12, 0x3a, 0x88, 0x18, 0xf3, 0x2a, 0x6c, 0x52, 0xff, 0x70, 0x02, 0x3b, 0x38, 0xe4, 0x9c, 0x89, 0x92, 0x55, 0xd0, 0xa9, 0x9f, 0x8d, 0x73, 0xd7, 0x89, 0x2a, 0xc1, 0x44, 0xa3, 0x5b, 0xf3, 0xca, 0x12, 0x17, 0x53, 0x4b, 0x96, 0x76, 0x1b, 0xff, 0x3c, 0x30, 0x44, 0x77, 0xe9, 0xed, 0xd2, 0x44, 0x0e, 0xfd, 0xff, 0x02, 0x00, 0x00, 0x00, 0x09, 0x76, 0x02, 0x00, 0x0c, 0xc4, 0x0b, 0x00, 0xf4, 0xeb, 0xba, 0x58, 0xc7, 0x53, 0x57, 0x98, 0x48, 0x5f, 0x45, 0x57, 0x52, 0x70, 0x53, 0x58, 0xce, 0x77, 0x6d, 0xec, 0x56, 0xa2, 0x97, 0x1a, 0x07, 0x5c, 0x93, 0xe4, 0x80, 0xfa, 0xc3, 0x5e, 0xf6, 0x15}; - const std::vector GT_ONE = {0xfd, 0xff, 0x02, 0x00, 0x00, 0x00, 0x09, 0x76, 0x02, 0x00, 0x0c, 0xc4, 0x0b, 0x00, 0xf4, 0xeb, 0xba, 0x58, 0xc7, 0x53, 0x57, 0x98, 0x48, 0x5f, 0x45, 0x57, 0x52, 0x70, 0x53, 0x58, 0xce, 0x77, 0x6d, 0xec, 0x56, 0xa2, 0x97, 0x1a, 0x07, 0x5c, 0x93, 0xe4, 0x80, 0xfa, 0xc3, 0x5e, 0xf6, 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - + // g1::one().negate().toAffineBytesLE() + const std::vector G1_ONE_NEG = {0xbb, 0xc6, 0x22, 0xdb, 0xa, 0xf0, 0x3a, 0xfb, 0xef, 0x1a, 0x7a, 0xf9, 0x3f, 0xe8, 0x55, 0x6c, 0x58, 0xac, 0x1b, 0x17, 0x3f, 0x3a, 0x4e, 0xa1, 0x5, 0xb9, 0x74, 0x97, 0x4f, 0x8c, 0x68, 0xc3, 0xf, 0xac, 0xa9, 0x4f, 0x8c, 0x63, 0x95, 0x26, 0x94, 0xd7, 0x97, 0x31, 0xa7, 0xd3, 0xf1, 0x17, 0xca, 0xc2, 0x39, 0xb9, 0xd6, 0xdc, 0x54, 0xad, 0x1b, 0x75, 0xcb, 0xe, 0xba, 0x38, 0x6f, 0x4e, 0x36, 0x42, 0xac, 0xca, 0xd5, 0xb9, 0x55, 0x66, 0xc9, 0x7, 0xb5, 0x1d, 0xef, 0x6a, 0x81, 0x67, 0xf2, 0x21, 0x2e, 0xcf, 0xc8, 0x76, 0x7d, 0xaa, 0xa8, 0x45, 0xd5, 0x55, 0x68, 0x1d, 0x4d, 0x11}; + // fp12::one().toBytesLE(); + const std::vector GT_ONE = []{ std::vector r(576, 0); r[0] = 1; return r; }(); + // caller of verify() must use this msg std::vector msg = {51, 23, 56, 93, 212, 129, 128, 27, 251, 12, 42, 129, 210, 9, 34, 98}; [[eosio::action]] void verify(const std::vector& pk, const std::vector& sig) { + check(pk.size() == std::tuple_size::value, "wrong pk size passed"); + check(sig.size() == std::tuple_size::value, "wrong sig size passed"); bls_g1 g1_points[2]; bls_g2 g2_points[2];