From ee509af900345062092561925153530ea7a51166 Mon Sep 17 00:00:00 2001 From: "e.tatuzova" Date: Thu, 3 Oct 2024 17:32:04 +0400 Subject: [PATCH] Update parallel version #52 --- .../libs/parallel-zk/test/CMakeLists.txt | 5 +- .../zk/test_tools/random_test_initializer.hpp | 98 ------------------- .../placeholder/placeholder_circuits.cpp | 2 +- .../plonk/placeholder/placeholder_curves.cpp | 2 +- .../placeholder/placeholder_gate_argument.cpp | 2 +- .../placeholder/placeholder_goldilocks.cpp | 2 +- .../plonk/placeholder/placeholder_hashes.cpp | 2 +- .../plonk/placeholder/placeholder_kzg.cpp | 2 +- .../placeholder_lookup_argument.cpp | 2 +- .../placeholder_permutation_argument.cpp | 2 +- ...placeholder_quotient_polynomial_chunks.cpp | 2 +- .../test_tools/random_test_initializer.hpp | 96 ++++++++++++++++++ 12 files changed, 108 insertions(+), 109 deletions(-) delete mode 100644 parallel-crypto3/libs/parallel-zk/test/include/nil/crypto3/zk/test_tools/random_test_initializer.hpp create mode 100644 parallel-crypto3/test_tools/include/nil/crypto3/test_tools/random_test_initializer.hpp diff --git a/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt b/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt index a17031e301..f9eea44abe 100644 --- a/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt +++ b/parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt @@ -30,8 +30,9 @@ macro(define_zk_test test) cm_test(NAME ${full_test_name} SOURCES ${test}.cpp) target_include_directories(${full_test_name} PRIVATE - "$" - "$" + "$" + "$" + "$" ${Boost_INCLUDE_DIRS}) diff --git a/parallel-crypto3/libs/parallel-zk/test/include/nil/crypto3/zk/test_tools/random_test_initializer.hpp b/parallel-crypto3/libs/parallel-zk/test/include/nil/crypto3/zk/test_tools/random_test_initializer.hpp deleted file mode 100644 index 2740db924c..0000000000 --- a/parallel-crypto3/libs/parallel-zk/test/include/nil/crypto3/zk/test_tools/random_test_initializer.hpp +++ /dev/null @@ -1,98 +0,0 @@ -//---------------------------------------------------------------------------// -// Copyright (c) 2022 Mikhail Komarov -// Copyright (c) 2022 Nikita Kaskov -// Copyright (c) 2022 Ilia Shirobokov -// Copyright (c) 2022 Alisa Cherniaeva -// Copyright (c) 2023 Elena Tatuzova -// -// MIT License -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in all -// copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -// SOFTWARE. -//---------------------------------------------------------------------------// - -#ifndef CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP -#define CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP - -#include -#include - -#include -#include -#include - - -namespace nil { - namespace crypto3 { - namespace zk { - namespace test_tools { - - // ******************************************************************************* - // * Randomness setup - // *******************************************************************************/ - // Template structure to include algebraic random engines for multiple field types - template - struct random_engine_container { - std::size_t seed; - std::tuple...> alg_rnd_engines; - - explicit random_engine_container(std::size_t init_seed = 0) - : alg_rnd_engines(nil::crypto3::random::algebraic_engine(init_seed)...) { - } - - // Template method to access a specific engine by type - template - nil::crypto3::random::algebraic_engine& get_alg_engine() { - return std::get>(alg_rnd_engines); - } - }; - - template - struct random_test_initializer { - random_test_initializer() { - for (std::size_t i = 0; i < std::size_t(boost::unit_test::framework::master_test_suite().argc - 1); i++) { - if (std::string(boost::unit_test::framework::master_test_suite().argv[i]) == "--seed") { - if (std::string(boost::unit_test::framework::master_test_suite().argv[i + 1]) == "random") { - std::random_device rd; - seed = rd(); - break; - } - if (std::regex_match(boost::unit_test::framework::master_test_suite().argv[i + 1], - std::regex(("((\\+|-)?[[:digit:]]+)(\\.(([[:digit:]]+)?))?")))) { - seed = atoi(boost::unit_test::framework::master_test_suite().argv[i + 1]); - break; - } - } - } - - BOOST_TEST_MESSAGE("seed = " << seed); - alg_random_engines = random_engine_container(seed); - generic_random_engine = boost::random::mt11213b(seed); - } - - std::size_t seed = 0; - random_engine_container alg_random_engines; - boost::random::mt11213b generic_random_engine; - }; - - } // namespace test_tools - } // namespace zk - } // namespace crypto3 -} // namespace nil - -#endif // CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_circuits.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_circuits.cpp index fdffd550bd..0e0c02f817 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_circuits.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_circuits.cpp @@ -38,7 +38,7 @@ #include #include -#include +#include #include "circuits.hpp" #include "placeholder_test_runner.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_curves.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_curves.cpp index 744d08ef38..f4c358a131 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_curves.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_curves.cpp @@ -53,7 +53,7 @@ #include #include -#include +#include #include "circuits.hpp" #include "placeholder_test_runner.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_gate_argument.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_gate_argument.cpp index 5578c3f0d6..6448147d94 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_gate_argument.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_gate_argument.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include "circuits.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_goldilocks.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_goldilocks.cpp index a2ad6fbf58..32d3d2e45e 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_goldilocks.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_goldilocks.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include "circuits.hpp" #include "placeholder_test_runner.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_hashes.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_hashes.cpp index 2c34838e17..09aa37808b 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_hashes.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_hashes.cpp @@ -44,7 +44,7 @@ #include #include -#include +#include #include "circuits.hpp" #include "placeholder_test_runner.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_kzg.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_kzg.cpp index 52e87b38c5..acfb535c6d 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_kzg.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_kzg.cpp @@ -62,7 +62,7 @@ #include #include #include -#include +#include #include "circuits.hpp" #include "placeholder_test_runner.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_lookup_argument.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_lookup_argument.cpp index 059dd61b82..6a37bbe055 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_lookup_argument.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_lookup_argument.cpp @@ -62,7 +62,7 @@ #include #include -#include +#include #include "circuits.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_permutation_argument.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_permutation_argument.cpp index e8b1e88a09..ea5133e9c6 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_permutation_argument.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_permutation_argument.cpp @@ -61,7 +61,7 @@ #include #include #include -#include +#include #include "circuits.hpp" diff --git a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_quotient_polynomial_chunks.cpp b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_quotient_polynomial_chunks.cpp index ae12452758..aeb5db7ffc 100644 --- a/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_quotient_polynomial_chunks.cpp +++ b/parallel-crypto3/libs/parallel-zk/test/systems/plonk/placeholder/placeholder_quotient_polynomial_chunks.cpp @@ -39,7 +39,7 @@ #include #include -#include +#include #include "circuits.hpp" #include "placeholder_test_runner.hpp" diff --git a/parallel-crypto3/test_tools/include/nil/crypto3/test_tools/random_test_initializer.hpp b/parallel-crypto3/test_tools/include/nil/crypto3/test_tools/random_test_initializer.hpp new file mode 100644 index 0000000000..64b42c7ab5 --- /dev/null +++ b/parallel-crypto3/test_tools/include/nil/crypto3/test_tools/random_test_initializer.hpp @@ -0,0 +1,96 @@ +//---------------------------------------------------------------------------// +// Copyright (c) 2022 Mikhail Komarov +// Copyright (c) 2022 Nikita Kaskov +// Copyright (c) 2022 Ilia Shirobokov +// Copyright (c) 2022 Alisa Cherniaeva +// Copyright (c) 2023 Elena Tatuzova +// +// MIT License +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//---------------------------------------------------------------------------// + +#ifndef CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP +#define CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP + +#include +#include + +#include +#include +#include + + +namespace nil { + namespace crypto3 { + namespace test_tools { + + // ******************************************************************************* + // * Randomness setup + // *******************************************************************************/ + // Template structure to include algebraic random engines for multiple field types + template + struct random_engine_container { + std::size_t seed; + std::tuple...> alg_rnd_engines; + + explicit random_engine_container(std::size_t init_seed = 0) + : alg_rnd_engines(nil::crypto3::random::algebraic_engine(init_seed)...) { + } + + // Template method to access a specific engine by type + template + nil::crypto3::random::algebraic_engine& get_alg_engine() { + return std::get>(alg_rnd_engines); + } + }; + + template + struct random_test_initializer { + random_test_initializer() { + for (std::size_t i = 0; i < std::size_t(boost::unit_test::framework::master_test_suite().argc - 1); i++) { + if (std::string(boost::unit_test::framework::master_test_suite().argv[i]) == "--seed") { + if (std::string(boost::unit_test::framework::master_test_suite().argv[i + 1]) == "random") { + std::random_device rd; + seed = rd(); + break; + } + if (std::regex_match(boost::unit_test::framework::master_test_suite().argv[i + 1], + std::regex(("((\\+|-)?[[:digit:]]+)(\\.(([[:digit:]]+)?))?")))) { + seed = atoi(boost::unit_test::framework::master_test_suite().argv[i + 1]); + break; + } + } + } + + BOOST_TEST_MESSAGE("seed = " << seed); + alg_random_engines = random_engine_container(seed); + generic_random_engine = boost::random::mt11213b(seed); + } + + std::size_t seed = 0; + random_engine_container alg_random_engines; + boost::random::mt11213b generic_random_engine; + }; + + } // namespace test_tools + } // namespace crypto3 +} // namespace nil + +#endif // CRYPTO3_ZK_TEST_TOOLS_RANDOM_TEST_INITIALIZER_HPP