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

[secp256k1] Update secp256k1 from 2017 to 2022 #25398

Merged
merged 18 commits into from
Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from 10 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
13 changes: 13 additions & 0 deletions ports/secp256k1/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ option(INSTALL_HEADERS "Install header files" ON)
add_definitions(
-DENABLE_MODULE_ECDH
-DENABLE_MODULE_RECOVERY
-DENABLE_MODULE_EXTRAKEYS
-DENABLE_MODULE_SCHNORRSIG
-DHAVE_CONFIG_H
)

Expand All @@ -16,6 +18,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src)

target_include_directories(secp256k1 PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)

file(GLOB SOURCES_PRECOMP src/precomputed_ecmult_gen.c src/precomputed_ecmult.c)
add_library(secp256k1_precomputed ${SOURCES_PRECOMP})

target_include_directories(secp256k1_precomputed PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}> $<INSTALL_INTERFACE:include>)

if(INSTALL_HEADERS)
file(GLOB HEADERS include/*.h)
install(FILES ${HEADERS} DESTINATION include)
Expand All @@ -27,6 +34,12 @@ install(TARGETS secp256k1 EXPORT unofficial-secp256k1-targets
LIBRARY DESTINATION lib
)

install(TARGETS secp256k1_precomputed EXPORT unofficial-secp256k1-targets
RUNTIME DESTINATION bin
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
)

install(
EXPORT unofficial-secp256k1-targets
FILE unofficial-secp256k1-targets.cmake
Expand Down
9 changes: 9 additions & 0 deletions ports/secp256k1/libsecp256k1-config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,19 @@
#undef USE_SCALAR_INV_BUILTIN
#undef USE_SCALAR_INV_NUM

#undef USE_EXAMPLES
#undef USE_TESTS
#undef USE_EXHAUSTIVE_TESTS
#undef VALGRIND_ENABLED
#undef ENABLE_COVERAGE
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved

#define USE_NUM_NONE 1
#define USE_FIELD_INV_BUILTIN 1
#define USE_SCALAR_INV_BUILTIN 1
#define USE_FIELD_10X26 1
#define USE_SCALAR_8X32 1

#define ECMULT_WINDOW_SIZE 15
#define ECMULT_GEN_PREC_BITS 4
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved

#endif /* SECP256K1_BASIC_CONFIG_H */
42 changes: 30 additions & 12 deletions ports/secp256k1/portfile.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,41 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO "bitcoin-core/secp256k1"
REF "0b7024185045a49a1a6a4c5615bf31c94f63d9c4"
SHA512 54e0c446ae63105800dfaf23dc934734f196c91f275db0455e58a36926c29ecc51a13d9b1eb2e45bc86199120c3c472ec7b39086787a49ce388a4df462a870bc
REF "44c2452fd387f7ca604ab42d73746e7d3a44d8a2"
SHA512 1c1969b663843c71cba0148b14430bd2417b63a6ca7d6940585844b73aee2642622b080541ad3a1712390640f305f5bb1e251985d59674e1ded9cb4688f7830d
)

file(COPY ${CURRENT_PORT_DIR}/libsecp256k1-config.h DESTINATION ${SOURCE_PATH})
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
file(COPY "${CURRENT_PORT_DIR}/libsecp256k1-config.h" DESTINATION "${SOURCE_PATH}")
file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}")

vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
OPTIONS_DEBUG
-DINSTALL_HEADERS=OFF
file(REMOVE "${SOURCE_PATH}/src/bench.c")
file(REMOVE "${SOURCE_PATH}/src/bench.h")
file(REMOVE "${SOURCE_PATH}/src/bench_ecmult.c")
file(REMOVE "${SOURCE_PATH}/src/bench_internal.c")

file(REMOVE "${SOURCE_PATH}/src/tests.c")
file(REMOVE "${SOURCE_PATH}/src/tests_exhaustive.c")
file(REMOVE "${SOURCE_PATH}/src/valgrind_ctime_test.c")

file(REMOVE "${SOURCE_PATH}/contrib/lax_der_parsing.c)
file(REMOVE "${SOURCE_PATH}/contrib/lax_der_parsing.h)
file(REMOVE "${SOURCE_PATH}/contrib/lax_der_privatekey_parsing.c)
file(REMOVE "${SOURCE_PATH}/contrib/lax_der_privatekey_parsing.h)
JackBoosY marked this conversation as resolved.
Show resolved Hide resolved

file(REMOVE "${SOURCE_PATH}/examples/ecdh.c)
file(REMOVE "${SOURCE_PATH}/examples/ecdsa.c)
file(REMOVE "${SOURCE_PATH}/examples/schnorr.c)
file(REMOVE "${SOURCE_PATH}/examples/random.h)

vcpkg_cmake_configure(
SOURCE_PATH "${SOURCE_PATH}"
OPTIONS_DEBUG
-DINSTALL_HEADERS=OFF
)

vcpkg_install_cmake()
vcpkg_fixup_cmake_targets(CONFIG_PATH share/unofficial-${PORT} TARGET_PATH share/unofficial-${PORT})
vcpkg_cmake_install()
vcpkg_cmake_config_fixup(CONFIG_PATH "share/unofficial-${PORT}" PACKAGE_NAME unofficial-${PORT})

file(REMOVE_RECURSE "${CURRENT_PACKAGES_DIR}/debug/share")
configure_file(${CMAKE_CURRENT_LIST_DIR}/secp256k1-config.cmake ${CURRENT_PACKAGES_DIR}/share/unofficial-${PORT}/unofficial-secp256k1-config.cmake @ONLY)
file(INSTALL ${SOURCE_PATH}/COPYING DESTINATION ${CURRENT_PACKAGES_DIR}/share/${PORT} RENAME copyright)
file(INSTALL "${SOURCE_PATH}/COPYING" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}" RENAME copyright)
16 changes: 13 additions & 3 deletions ports/secp256k1/vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"name": "secp256k1",
"version-string": "2017-19-10",
"port-version": 4,
"version-date": "2022-25-06",
"port-version": 5,
JonLiu1993 marked this conversation as resolved.
Show resolved Hide resolved
"description": "Optimized C library for EC operations on curve",
"homepage": "https://github.com/bitcoin-core/secp256k1"
"homepage": "https://github.com/bitcoin-core/secp256k1",
"dependencies": [
{
"name": "vcpkg-cmake",
"host": true
},
{
"name": "vcpkg-cmake-config",
"host": true
}
]
}
4 changes: 2 additions & 2 deletions versions/baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -6477,8 +6477,8 @@
"port-version": 3
},
"secp256k1": {
"baseline": "2017-19-10",
"port-version": 4
"baseline": "2022-25-06",
"port-version": 5
},
"selene": {
"baseline": "0.3.1",
Expand Down
5 changes: 5 additions & 0 deletions versions/s-/secp256k1.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
{
"versions": [
{
"git-tree": "a956f04dfda67573096b84602f268c9e189a325c",
"version-date": "2022-25-06",
"port-version": 5
},
{
"git-tree": "a0ba39af9284d60d41166c4f546975e9f2b2d9df",
"version-string": "2017-19-10",
Expand Down