Skip to content

Commit

Permalink
Update parallel version and transpiler #52
Browse files Browse the repository at this point in the history
  • Loading branch information
ETatuzova committed Oct 3, 2024
1 parent 6bcc982 commit b527c2f
Show file tree
Hide file tree
Showing 18 changed files with 115 additions and 111 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@

#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

using namespace nil::crypto3;

Expand Down
1 change: 1 addition & 0 deletions crypto3/libs/marshalling/zk/test/fri_commitment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@
#include <nil/crypto3/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/marshalling/zk/types/commitments/fri.hpp>

#include <nil/crypto3/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil::crypto3;
Expand Down
2 changes: 2 additions & 0 deletions crypto3/libs/marshalling/zk/test/lpc_commitment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@

#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>

#include <nil/crypto3/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil::crypto3;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <nil/crypto3/marshalling/zk/types/commitments/kzg.hpp>
#include <nil/crypto3/marshalling/zk/types/commitments/lpc.hpp>
#include <nil/crypto3/marshalling/zk/types/placeholder/preprocessed_public_data.hpp>

#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>
#include "./detail/circuits.hpp"

Expand Down
2 changes: 1 addition & 1 deletion crypto3/libs/marshalling/zk/test/placeholder_proof.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@
#include <nil/crypto3/zk/snark/arithmetization/plonk/params.hpp>
#include <nil/crypto3/zk/snark/systems/plonk/placeholder/detail/profiling.hpp>
#include <nil/crypto3/zk/snark/arithmetization/plonk/table_description.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include <nil/crypto3/marshalling/zk/types/commitments/eval_storage.hpp>
#include <nil/crypto3/marshalling/zk/types/commitments/kzg.hpp>
Expand All @@ -94,6 +93,7 @@
#include <nil/crypto3/math/algorithms/calculate_domain_set.hpp>

#include "./detail/circuits.hpp"
#include <nil/crypto3/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil;
Expand Down
2 changes: 2 additions & 0 deletions crypto3/libs/marshalling/zk/test/polys_evaluator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp> // contains class polys_evaluator

#include <nil/crypto3/test_tools/random_test_initializer.hpp>
#include <nil/crypto3/marshalling/zk/detail/random_test_data_generation.hpp>

using namespace nil::crypto3;
Expand Down
5 changes: 3 additions & 2 deletions parallel-crypto3/libs/parallel-zk/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/../../../test_tools/include>"
"$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/include>"

${Boost_INCLUDE_DIRS})

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
#include <nil/crypto3/hash/algorithm/hash.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
#include <nil/crypto3/hash/algorithm/hash.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
#include <nil/crypto3/zk/transcript/fiat_shamir.hpp>
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <nil/crypto3/algebra/fields/arithmetic_params/goldilocks64.hpp>

#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/hash/poseidon.hpp>

#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <nil/crypto3/zk/commitments/polynomial/kzg.hpp>
#include <nil/crypto3/zk/commitments/polynomial/kzg_v2.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>

#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
#include <nil/crypto3/zk/commitments/polynomial/fri.hpp>
#include <nil/crypto3/zk/commitments/polynomial/lpc.hpp>
#include <nil/crypto3/zk/commitments/batched_commitment.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include <nil/crypto3/algebra/fields/arithmetic_params/pallas.hpp>

#include <nil/crypto3/hash/keccak.hpp>
#include <nil/crypto3/zk/detail/random_test_initializer.hpp>
#include <nil/crypto3/test_tools/random_test_initializer.hpp>

#include "circuits.hpp"
#include "placeholder_test_runner.hpp"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
//---------------------------------------------------------------------------//
// Copyright (c) 2022 Mikhail Komarov <[email protected]>
// Copyright (c) 2022 Nikita Kaskov <[email protected]>
// Copyright (c) 2022 Ilia Shirobokov <[email protected]>
// Copyright (c) 2022 Alisa Cherniaeva <[email protected]>
// Copyright (c) 2023 Elena Tatuzova <[email protected]>
//
// 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 <boost/test/unit_test.hpp>
#include <regex>

#include <nil/crypto3/algebra/random_element.hpp>
#include <nil/crypto3/random/algebraic_random_device.hpp>
#include <nil/crypto3/random/algebraic_engine.hpp>


namespace nil {
namespace crypto3 {
namespace test_tools {

// *******************************************************************************
// * Randomness setup
// *******************************************************************************/
// Template structure to include algebraic random engines for multiple field types
template<typename... FieldTypes>
struct random_engine_container {
std::size_t seed;
std::tuple<nil::crypto3::random::algebraic_engine<FieldTypes>...> alg_rnd_engines;

explicit random_engine_container(std::size_t init_seed = 0)
: alg_rnd_engines(nil::crypto3::random::algebraic_engine<FieldTypes>(init_seed)...) {
}

// Template method to access a specific engine by type
template<typename FieldType>
nil::crypto3::random::algebraic_engine<FieldType>& get_alg_engine() {
return std::get<nil::crypto3::random::algebraic_engine<FieldType>>(alg_rnd_engines);
}
};

template<typename... FieldType>
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<FieldType...>(seed);
generic_random_engine = boost::random::mt11213b(seed);
}

std::size_t seed = 0;
random_engine_container<FieldType...> 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

0 comments on commit b527c2f

Please sign in to comment.