Skip to content
Open
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
8 changes: 7 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -556,7 +556,13 @@ jobs:
- *CHECKOUT

- name: Generate buildsystem
run: cmake -E env CFLAGS="/WX ${{ matrix.configuration.cpp_flags }}" cmake -B build -DSECP256K1_ENABLE_MODULE_RECOVERY=ON -DSECP256K1_BUILD_EXAMPLES=ON ${{ matrix.configuration.cmake_options }}
run: |
cmake -E env CFLAGS="/WX ${{ matrix.configuration.cpp_flags }}" `
cmake -B build `
-DSECP256K1_BUILD_PRECOMPUTED=ON `
-DSECP256K1_ENABLE_MODULE_RECOVERY=ON `
-DSECP256K1_BUILD_EXAMPLES=ON `
${{ matrix.configuration.cmake_options }}

- name: Build
run: cmake --build build --config RelWithDebInfo -- /p:UseMultiToolTask=true /maxCpuCount
Expand Down
2 changes: 2 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ option(SECP256K1_BUILD_EXHAUSTIVE_TESTS "Build exhaustive tests." ON)
option(SECP256K1_BUILD_CTIME_TESTS "Build constant-time tests." ${SECP256K1_VALGRIND})
option(SECP256K1_BUILD_EXAMPLES "Build examples." OFF)

option(SECP256K1_BUILD_PRECOMPUTED "Recreate the precomputed files." OFF)

# Redefine configuration flags.
# We leave assertions on, because they are only used in the examples, and we want them always on there.
if(MSVC)
Expand Down
3 changes: 2 additions & 1 deletion CMakePresets.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"cacheVariables": {
"SECP256K1_EXPERIMENTAL": "ON",
"SECP256K1_ENABLE_MODULE_RECOVERY": "ON",
"SECP256K1_BUILD_EXAMPLES": "ON"
"SECP256K1_BUILD_EXAMPLES": "ON",
"SECP256K1_BUILD_PRECOMPUTED": "ON"
},
"warnings": {
"dev": true,
Expand Down
13 changes: 13 additions & 0 deletions cmake/Precompute.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
function(precompute base_name)
add_executable(secp256k1_precompute_${base_name} EXCLUDE_FROM_ALL precompute_${base_name}.c)
set_target_properties(secp256k1_precompute_${base_name} PROPERTIES
COMPILE_DEFINITIONS VERIFY
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
)
add_custom_command(
OUTPUT ${PROJECT_BINARY_DIR}/src/precomputed_${base_name}.c
COMMAND secp256k1_precompute_${base_name}
DEPENDS secp256k1_precompute_${base_name}
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
)
endfunction()
20 changes: 16 additions & 4 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,22 @@ if(SECP256K1_ENABLE_MODULE_ECDH)
set_property(TARGET secp256k1 APPEND PROPERTY PUBLIC_HEADER ${PROJECT_SOURCE_DIR}/include/secp256k1_ecdh.h)
endif()

add_library(secp256k1_precomputed OBJECT EXCLUDE_FROM_ALL
precomputed_ecmult.c
precomputed_ecmult_gen.c
)
add_library(secp256k1_precomputed OBJECT EXCLUDE_FROM_ALL)
if(SECP256K1_BUILD_PRECOMPUTED)
include(Precompute)
precompute(ecmult)
precompute(ecmult_gen)
target_sources(secp256k1_precomputed PRIVATE
${PROJECT_BINARY_DIR}/src/precomputed_ecmult.c
${PROJECT_BINARY_DIR}/src/precomputed_ecmult_gen.c
)
target_include_directories(secp256k1_precomputed PRIVATE ${CMAKE_CURRENT_LIST_DIR})
else()
target_sources(secp256k1_precomputed PRIVATE
${CMAKE_CURRENT_LIST_DIR}/precomputed_ecmult.c
${CMAKE_CURRENT_LIST_DIR}/precomputed_ecmult_gen.c
)
endif()

# Add objects explicitly rather than linking to the object libs to keep them
# from being exported.
Expand Down