Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmake cleanup + cosmetics #227

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 4 additions & 32 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,10 @@ if(NOT CMAKE_WORKSPACE_NAME OR NOT ("${CMAKE_WORKSPACE_NAME}" STREQUAL "crypto3"
cm_workspace(crypto3)
endif()

macro(cm_find_package NAME)
foreach(ITERATOR ${CMAKE_WORKSPACE_LIST})
if(NOT "${NAME}" MATCHES "^${ITERATOR}_.*$" AND NOT "${NAME}" STREQUAL CM)
find_package(${ARGV})
else()
set(${ARGV0}_FOUND ON CACHE BOOL "")
endif()
endforeach()
endmacro()

cm_project(assigner WORKSPACE_NAME ${CMAKE_WORKSPACE_NAME} LANGUAGES C CXX)

if(NOT Boost_FOUND AND NOT CMAKE_CROSSCOMPILING)
cm_find_package(Boost COMPONENTS REQUIRED filesystem log log_setup program_options thread system)
find_package(Boost COMPONENTS REQUIRED filesystem log log_setup program_options thread system)
endif()

cm_find_package(CM)
Expand Down Expand Up @@ -80,33 +70,15 @@ target_link_libraries(${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME} INTERFACE
LLVMIRReader
LLVMCore
LLVMSupport

${Boost_LIBRARIES}

crypto3::algebra
crypto3::block
crypto3::blueprint
crypto3::codec
crypto3::math
crypto3::multiprecision
crypto3::pkpad
crypto3::pubkey
crypto3::random
crypto3::zk

marshalling::core
marshalling::crypto3_algebra
marshalling::crypto3_multiprecision
marshalling::crypto3_zk)
crypto3::all)

cm_deploy(TARGETS ${CMAKE_WORKSPACE_NAME}_${CURRENT_PROJECT_NAME}
INCLUDE include
NAMESPACE ${CMAKE_WORKSPACE_NAME}::)


if(BUILD_TESTS)
add_subdirectory(test)
endif()
include(CMTest)
cm_add_test_subdirectory(test)

if(BUILD_EXAMPLES)
add_subdirectory(example)
Expand Down
2 changes: 1 addition & 1 deletion include/nil/blueprint/component_mockups/comparison.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
// #ifndef CRYPTO3_BLUEPRINT_PLONK_COMPARISON_HPP
// #define CRYPTO3_BLUEPRINT_PLONK_COMPARISON_HPP

// #include <nil/crypto3/multiprecision/cpp_int/literals.hpp>
// #include <nil/crypto3/multiprecision/cpp_int_modular/literals.hpp>
// #include <nil/crypto3/algebra/matrix/matrix.hpp>
// #include <nil/crypto3/algebra/fields/pallas/base_field.hpp>
// #include <nil/crypto3/algebra/fields/vesta/base_field.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/nil/blueprint/component_mockups/h2c.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef ZKLLVM_ASSIGNER_INCLUDE_NIL_BLUEPRINT_COMPONENT_MOCKUPS_H2C_HPP_
#define ZKLLVM_ASSIGNER_INCLUDE_NIL_BLUEPRINT_COMPONENT_MOCKUPS_H2C_HPP_

#include <nil/crypto3/multiprecision/cpp_int/literals.hpp>
#include <nil/crypto3/multiprecision/cpp_int_modular/literals.hpp>
#include <nil/crypto3/algebra/matrix/matrix.hpp>
#include <nil/crypto3/algebra/fields/pallas/base_field.hpp>
#include <nil/crypto3/algebra/fields/vesta/base_field.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/nil/blueprint/component_mockups/is_in_g1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef ZKLLVM_ASSIGNER_INCLUDE_NIL_BLUEPRINT_COMPONENT_MOCKUPS_IS_IN_G1_HPP_
#define ZKLLVM_ASSIGNER_INCLUDE_NIL_BLUEPRINT_COMPONENT_MOCKUPS_IS_IN_G1_HPP_

#include <nil/crypto3/multiprecision/cpp_int/literals.hpp>
#include <nil/crypto3/multiprecision/cpp_int_modular/literals.hpp>
#include <nil/crypto3/algebra/matrix/matrix.hpp>
#include <nil/crypto3/algebra/fields/pallas/base_field.hpp>
#include <nil/crypto3/algebra/fields/vesta/base_field.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/nil/blueprint/component_mockups/is_in_g2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
#ifndef ZKLLVM_ASSIGNER_INCLUDE_NIL_BLUEPRINT_COMPONENT_MOCKUPS_IS_IN_G2_HPP_
#define ZKLLVM_ASSIGNER_INCLUDE_NIL_BLUEPRINT_COMPONENT_MOCKUPS_IS_IN_G2_HPP_

#include <nil/crypto3/multiprecision/cpp_int/literals.hpp>
#include <nil/crypto3/multiprecision/cpp_int_modular/literals.hpp>
#include <nil/crypto3/algebra/matrix/matrix.hpp>
#include <nil/crypto3/algebra/fields/pallas/base_field.hpp>
#include <nil/crypto3/algebra/fields/vesta/base_field.hpp>
Expand Down
12 changes: 8 additions & 4 deletions test/input_reader_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ program_memory<var> memory(100);
stack_frame<var> frame;
std::nullptr_t empty_assignmnt;
boost::json::array empty_private_input;
InputReader<BlueprintFieldType, var, std::nullptr_t> input_reader(frame, memory, empty_assignmnt, layout_resolver, internal_storage);
InputReader<BlueprintFieldType, var, std::nullptr_t>
input_reader(frame, memory, empty_assignmnt, layout_resolver, internal_storage);
logger test_logger;

boost::json::array read_json_string(std::string json_string) {
Expand Down Expand Up @@ -86,7 +87,8 @@ struct LLVMDataFixture {

void test_correct_input(llvm::Function *func,
const char *input_string,
const column_type<BlueprintFieldType> expected_result) {
const column_type<BlueprintFieldType>
expected_result) {
auto input_array = read_json_string(input_string);
BOOST_TEST_REQUIRE(input_reader.fill_public_input(*func, input_array, empty_private_input, test_logger));
BOOST_TEST(check_vector_equality(input_reader.get_public_input(), expected_result));
Expand Down Expand Up @@ -129,7 +131,8 @@ BOOST_AUTO_TEST_CASE(input_reader_legacy_format) {
BOOST_AUTO_TEST_CASE(input_reader_mixed_format) {

column_type<BlueprintFieldType> expected = {0x12345678901234567890_cppui255, 2, 3, 4, 5, 6, 7, 8};
const char *input_string = R"([ {"array": [{"field":"0x12345678901234567890"}, {"field": 2}, {"field<pallas_base>" :3} ]},
const char *input_string =
R"([ {"array": [{"field":"0x12345678901234567890"}, {"field": 2}, {"field<pallas_base>" :3} ]},
{"array<field<pallas_base>>": [ 4, 5, 6, 7, 8]}])";
test_correct_input(arrays_func, input_string, expected);
}
Expand Down Expand Up @@ -199,7 +202,8 @@ BOOST_AUTO_TEST_CASE(input_reader_fields_wrong_amount) {
{"curve<ed25519>": [6, 7]},
{"curve<bls12381>": [5, 5]}
])";
const char *expected_error = R"(Too many values in the input files, public + private input sizes must be equal to passed argument size)";
const char *expected_error =
R"(Too many values in the input files, public + private input sizes must be equal to passed argument size)";
test_error_message(fields_curves_func, input_string_wrong_amount, expected_error);
}

Expand Down
17 changes: 9 additions & 8 deletions test/signature_parser_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@ BOOST_AUTO_TEST_CASE(input_signature_parser_simple) {
BOOST_TEST(signature_parser().parse("struct<int>"));
BOOST_TEST(signature_parser().parse("struct<int, field<pallas_base>>"));
BOOST_TEST(signature_parser().parse("array<struct<field<pallas_base>>>"));
BOOST_TEST(signature_parser().parse("struct"
"<"
"vector<int>,"
"array"
"<"
"struct<field<ed25519_scalar>, string>"
">"
">"));
BOOST_TEST(
signature_parser().parse("struct"
"<"
"vector<int>,"
"array"
"<"
"struct<field<ed25519_scalar>, string>"
">"
">"));

BOOST_TEST(signature_parser().parse("struct<int>>") == false);
BOOST_TEST(signature_parser().parse("field<pa") == false);
Expand Down