Skip to content

Commit

Permalink
Merge pull request #34 from jagerman/signer-optional
Browse files Browse the repository at this point in the history
Make Signer optional & make ecdsa_util.h private
  • Loading branch information
jagerman authored Sep 26, 2024
2 parents 33b31a9 + 1395d7d commit d4eb24a
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 22 deletions.
15 changes: 13 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,16 @@ target_link_libraries(
PUBLIC
nlohmann_json::nlohmann_json
oxenc::oxenc
secp256k1
ethyl-keccak
PRIVATE
cpr::cpr
oxen::logging
gmp
gmpxx
)
if(${PROJECT_NAME}_ENABLE_SIGNER)
target_link_libraries(${PROJECT_NAME} PUBLIC secp256k1)
endif()

verbose_message("Successfully added all dependencies and linked against them.")

Expand Down Expand Up @@ -147,10 +149,19 @@ message(STATUS "Finished building requirements for installing the package.\n")
if(${PROJECT_NAME}_INSTALL)
include(GNUInstallDirs)

set(header_exclude)
if(NOT ${PROJECT_NAME}_ENABLE_SIGNER)
set(header_exclude PATTERN "signer.hpp" EXCLUDE)
endif()


install(
DIRECTORY include/ethyl
TYPE INCLUDE
FILES_MATCHING PATTERN "*.hpp" PATTERN "*.h")
FILES_MATCHING
PATTERN "*.hpp"
PATTERN "*.h"
${header_exclude})

install(
TARGETS ${PROJECT_NAME}
Expand Down
11 changes: 4 additions & 7 deletions cmake/SourcesAndHeaders.cmake
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
set(sources
src/utils.cpp
src/provider.cpp
src/signer.cpp
src/transaction.cpp
)

set(headers
include/ethyl/utils.hpp
include/ethyl/provider.hpp
include/ethyl/signer.hpp
include/ethyl/transaction.hpp
)
if(${PROJECT_NAME}_ENABLE_SIGNER)
list(APPEND sources src/signer.cpp)
endif()


set(test_sources
src/basic.cpp
Expand Down
9 changes: 9 additions & 0 deletions cmake/StandardSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,15 @@ option(${PROJECT_NAME}_ENABLE_UNIT_TESTING "Enable unit tests for the projects (
#
option(${PROJECT_NAME}_ENABLE_CRYPTO_LIBRARY "Use the internal crypto library" ON)

#
# Whether to build secp256k1 + ethyl's Signer class
#
option(${PROJECT_NAME}_ENABLE_SIGNER "Build ethyl::Signer and secp256k1" ON)

if(${PROJECT_NAME}_ENABLE_UNIT_TESTING AND NOT ${PROJECT_NAME}_ENABLE_SIGNER)
message(FATAL_ERROR "Configuration error: ${PROJECT_NAME}_ENABLE_UNIT_TESTING requires ${PROJECT_NAME}_ENABLE_SIGNER")
endif()

#
# Static analyzers
#
Expand Down
24 changes: 13 additions & 11 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,19 @@ if(NOT TARGET cpr::cpr)
add_subdirectory(cpr EXCLUDE_FROM_ALL)
endif()

#
# SECP256k1
#
set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE)
set(SECP256K1_VALGRIND OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_EXHAUSTIVE_TESTS OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_CTIME_TESTS OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
system_or_submodule(SECP256K1 secp256k1 libsecp256k1>=0.2 secp256k1)
if(${PROJECT_NAME}_ENABLE_SIGNER)
#
# SECP256k1
#
set(SECP256K1_ENABLE_MODULE_RECOVERY ON CACHE BOOL "" FORCE)
set(SECP256K1_VALGRIND OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_BENCHMARK OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_TESTS OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_EXHAUSTIVE_TESTS OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_CTIME_TESTS OFF CACHE BOOL "" FORCE)
set(SECP256K1_BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
system_or_submodule(SECP256K1 secp256k1 libsecp256k1>=0.2 secp256k1)
endif()

#
# Catch2
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion src/signer.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "ethyl/signer.hpp"

#include "ethyl/ecdsa_util.h"
#include "ecdsa_util.h"
#include "ethyl/utils.hpp"
#include "ethyl/transaction.hpp"

Expand Down
2 changes: 1 addition & 1 deletion test/src/basic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

#include <secp256k1.h>

#include "ethyl/ecdsa_util.h"
#include "../../src/ecdsa_util.h"
#include <oxenc/hex.h>

#include <catch2/catch_test_macros.hpp>
Expand Down

0 comments on commit d4eb24a

Please sign in to comment.