From 9000a34a609a68d754267fdba81d5214990cd08d Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Wed, 22 Jun 2022 18:38:59 -0300 Subject: [PATCH 01/18] Update secp256k1 from 2017 to 2022, that added Schnorr Signature on last year. - Edit CMakeList.txt to target precomputed library. - Edit libsecp256k1-config.h to undef and define VARS compilation. - Edit portfile.cmake to download new sources from repository, commit reference 44c2452fd387f7ca604ab42d73746e7d3a44d8a2 (bitcoin-core/secp256k1) - Edit vcpkg.json to new version portfile --- ports/secp256k1/CMakeLists.txt | 13 +++++++++++++ ports/secp256k1/libsecp256k1-config.h | 9 +++++++++ ports/secp256k1/portfile.cmake | 23 +++++++++++++++++++++-- ports/secp256k1/vcpkg.json | 4 ++-- 4 files changed, 45 insertions(+), 4 deletions(-) diff --git a/ports/secp256k1/CMakeLists.txt b/ports/secp256k1/CMakeLists.txt index a3af313b6e7109..3975e69cd43563 100644 --- a/ports/secp256k1/CMakeLists.txt +++ b/ports/secp256k1/CMakeLists.txt @@ -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 ) @@ -16,6 +18,11 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) target_include_directories(secp256k1 PUBLIC $ $) +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 $ $) + if(INSTALL_HEADERS) file(GLOB HEADERS include/*.h) install(FILES ${HEADERS} DESTINATION include) @@ -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 diff --git a/ports/secp256k1/libsecp256k1-config.h b/ports/secp256k1/libsecp256k1-config.h index 693d3ed25b015f..536d5ddc75f89a 100644 --- a/ports/secp256k1/libsecp256k1-config.h +++ b/ports/secp256k1/libsecp256k1-config.h @@ -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 + #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 + #endif /* SECP256K1_BASIC_CONFIG_H */ diff --git a/ports/secp256k1/portfile.cmake b/ports/secp256k1/portfile.cmake index 3bf158816ae426..f96b7dd47d5409 100644 --- a/ports/secp256k1/portfile.cmake +++ b/ports/secp256k1/portfile.cmake @@ -3,13 +3,32 @@ 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(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) + +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_configure_cmake( SOURCE_PATH ${SOURCE_PATH} PREFER_NINJA diff --git a/ports/secp256k1/vcpkg.json b/ports/secp256k1/vcpkg.json index 43a10ad02447bc..da8f57c0f75f8b 100644 --- a/ports/secp256k1/vcpkg.json +++ b/ports/secp256k1/vcpkg.json @@ -1,7 +1,7 @@ { "name": "secp256k1", - "version-string": "2017-19-10", - "port-version": 4, + "version-date": "2022-25-06", + "port-version": 5, "description": "Optimized C library for EC operations on curve", "homepage": "https://github.com/bitcoin-core/secp256k1" } From 6c195e2b4cfe45381493176e38b58527aa1bd545 Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Wed, 22 Jun 2022 18:41:07 -0300 Subject: [PATCH 02/18] Update secp256k1 from 2017 to 2022, that added Schnorr Signature on last year >> vcpkg x-add-version secp256k1 - Update secp256k1.json version - Update baseline.json version --- versions/baseline.json | 4 ++-- versions/s-/secp256k1.json | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/versions/baseline.json b/versions/baseline.json index 43c17f1b865f82..4e5cc4c1519a69 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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", diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index f6b28c37d4afa0..24e95d700823f1 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "0b4112bc5b8339e218a2390106d7a0c28ca106d7", + "version-date": "2022-25-06", + "port-version": 5 + }, { "git-tree": "a0ba39af9284d60d41166c4f546975e9f2b2d9df", "version-string": "2017-19-10", From 202b3be50119ee35272b9656ae1b30683eeaddbf Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Thu, 23 Jun 2022 13:01:53 -0300 Subject: [PATCH 03/18] Update ports/secp256k1/portfile.cmake Added JonLiu1993 suggestion. Put PREFER_NINJA to secp256k1/portfile.cmake Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com> --- ports/secp256k1/portfile.cmake | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/ports/secp256k1/portfile.cmake b/ports/secp256k1/portfile.cmake index f96b7dd47d5409..c3d883727371f4 100644 --- a/ports/secp256k1/portfile.cmake +++ b/ports/secp256k1/portfile.cmake @@ -29,9 +29,8 @@ file(REMOVE ${SOURCE_PATH}/examples/ecdsa.c) file(REMOVE ${SOURCE_PATH}/examples/schnorr.c) file(REMOVE ${SOURCE_PATH}/examples/random.h) -vcpkg_configure_cmake( - SOURCE_PATH ${SOURCE_PATH} - PREFER_NINJA +vcpkg_cmake_configure( + SOURCE_PATH "${SOURCE_PATH}" OPTIONS_DEBUG -DINSTALL_HEADERS=OFF ) From 0806ec6b9eaa9d223856168824bfa201c05e090b Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Thu, 23 Jun 2022 13:18:37 -0300 Subject: [PATCH 04/18] Update ports/secp256k1/vcpkg.json Added JonLiu1993 suggestion. Put dependencies to secp256k1/vcpkg.json Co-authored-by: JonLiu1993 <63675417+JonLiu1993@users.noreply.github.com> --- ports/secp256k1/vcpkg.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/ports/secp256k1/vcpkg.json b/ports/secp256k1/vcpkg.json index da8f57c0f75f8b..82be6f53fa75dd 100644 --- a/ports/secp256k1/vcpkg.json +++ b/ports/secp256k1/vcpkg.json @@ -3,5 +3,15 @@ "version-date": "2022-25-06", "port-version": 5, "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 + } + ] } From 0d64f93cfb97a2c282c120e49c7366ddcdedbdf8 Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Thu, 23 Jun 2022 13:24:55 -0300 Subject: [PATCH 05/18] Update port-version, REQUIRED to "x-add-version" >> vcpkg x-add-version secp256k1 --- versions/baseline.json | 4 ++-- versions/s-/secp256k1.json | 5 ----- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/versions/baseline.json b/versions/baseline.json index 4e5cc4c1519a69..43c17f1b865f82 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6477,8 +6477,8 @@ "port-version": 3 }, "secp256k1": { - "baseline": "2022-25-06", - "port-version": 5 + "baseline": "2017-19-10", + "port-version": 4 }, "selene": { "baseline": "0.3.1", diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index 24e95d700823f1..f6b28c37d4afa0 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,10 +1,5 @@ { "versions": [ - { - "git-tree": "0b4112bc5b8339e218a2390106d7a0c28ca106d7", - "version-date": "2022-25-06", - "port-version": 5 - }, { "git-tree": "a0ba39af9284d60d41166c4f546975e9f2b2d9df", "version-string": "2017-19-10", From 168209c0b1b4a200f7780805ffe17ce293361f0c Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Thu, 23 Jun 2022 13:28:55 -0300 Subject: [PATCH 06/18] Update port file to secp256k1 identation --- ports/secp256k1/portfile.cmake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/ports/secp256k1/portfile.cmake b/ports/secp256k1/portfile.cmake index c3d883727371f4..3348f3a9890523 100644 --- a/ports/secp256k1/portfile.cmake +++ b/ports/secp256k1/portfile.cmake @@ -30,9 +30,9 @@ 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 + SOURCE_PATH "${SOURCE_PATH}" + OPTIONS_DEBUG + -DINSTALL_HEADERS=OFF ) vcpkg_install_cmake() From 7f3cbf1c1a867169ba37803a233b42a9a1752067 Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Thu, 23 Jun 2022 13:30:31 -0300 Subject: [PATCH 07/18] Update vcpkg.json identation >> vcpkg format-manifest ports/secp256k1/vcpkg.json --- ports/secp256k1/vcpkg.json | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ports/secp256k1/vcpkg.json b/ports/secp256k1/vcpkg.json index 82be6f53fa75dd..33c09f84b016d3 100644 --- a/ports/secp256k1/vcpkg.json +++ b/ports/secp256k1/vcpkg.json @@ -5,13 +5,13 @@ "description": "Optimized C library for EC operations on curve", "homepage": "https://github.com/bitcoin-core/secp256k1", "dependencies": [ - { - "name": "vcpkg-cmake", - "host": true - }, - { - "name": "vcpkg-cmake-config", - "host": true - } + { + "name": "vcpkg-cmake", + "host": true + }, + { + "name": "vcpkg-cmake-config", + "host": true + } ] } From 3e6ebcf28ed804a588eebcd8d1cb47ea001e5a8b Mon Sep 17 00:00:00 2001 From: ROLL Software Brasil Date: Thu, 23 Jun 2022 13:31:14 -0300 Subject: [PATCH 08/18] Update x-add-version command vcpkg x-add-version secp256k1 --- versions/baseline.json | 4 ++-- versions/s-/secp256k1.json | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/versions/baseline.json b/versions/baseline.json index 43c17f1b865f82..4e5cc4c1519a69 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -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", diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index f6b28c37d4afa0..3e76ee8e2fb31f 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,5 +1,10 @@ { "versions": [ + { + "git-tree": "b6d3fc5a426448b7e3d480b8d7b8764c31865df8", + "version-date": "2022-25-06", + "port-version": 5 + }, { "git-tree": "a0ba39af9284d60d41166c4f546975e9f2b2d9df", "version-string": "2017-19-10", From a2c02f69b53264e97eb10c3f31a17529f9a549b7 Mon Sep 17 00:00:00 2001 From: Jonliu1993 <13720414433@163.com> Date: Mon, 4 Jul 2022 15:44:02 +0800 Subject: [PATCH 09/18] [secp256k1 ]Update secp256k1 from 2017 to 2022 --- ports/secp256k1/portfile.cmake | 40 +++++++++++++++++----------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/ports/secp256k1/portfile.cmake b/ports/secp256k1/portfile.cmake index 3348f3a9890523..30624c69aa375a 100644 --- a/ports/secp256k1/portfile.cmake +++ b/ports/secp256k1/portfile.cmake @@ -7,27 +7,27 @@ vcpkg_from_github( 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}") -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/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}/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) +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) -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) +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}" @@ -35,9 +35,9 @@ vcpkg_cmake_configure( -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) From b6420cf1a57660dfac6d8cbbb5ee93fad781b810 Mon Sep 17 00:00:00 2001 From: Jonliu1993 <13720414433@163.com> Date: Mon, 4 Jul 2022 15:44:36 +0800 Subject: [PATCH 10/18] update version --- versions/s-/secp256k1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index 3e76ee8e2fb31f..374e1caa080c8d 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "b6d3fc5a426448b7e3d480b8d7b8764c31865df8", + "git-tree": "a956f04dfda67573096b84602f268c9e189a325c", "version-date": "2022-25-06", "port-version": 5 }, From 26ee2f370c7c4cb09a81b3bb6c7d680fa5d968d4 Mon Sep 17 00:00:00 2001 From: Jonliu1993 <13720414433@163.com> Date: Mon, 4 Jul 2022 16:04:01 +0800 Subject: [PATCH 11/18] Add license --- ports/secp256k1/vcpkg.json | 1 + 1 file changed, 1 insertion(+) diff --git a/ports/secp256k1/vcpkg.json b/ports/secp256k1/vcpkg.json index 33c09f84b016d3..779f36dc31582e 100644 --- a/ports/secp256k1/vcpkg.json +++ b/ports/secp256k1/vcpkg.json @@ -4,6 +4,7 @@ "port-version": 5, "description": "Optimized C library for EC operations on curve", "homepage": "https://github.com/bitcoin-core/secp256k1", + "license": "MIT", "dependencies": [ { "name": "vcpkg-cmake", From 24cd4432013727a6cea39bbb87fc8bd281cedce5 Mon Sep 17 00:00:00 2001 From: Jonliu1993 <13720414433@163.com> Date: Mon, 4 Jul 2022 16:04:22 +0800 Subject: [PATCH 12/18] update version --- versions/s-/secp256k1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index 374e1caa080c8d..9ecd154a80944c 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "a956f04dfda67573096b84602f268c9e189a325c", + "git-tree": "96f20db83c563f9526b6033f0ad8168a40add313", "version-date": "2022-25-06", "port-version": 5 }, From dd9ced167a0fc89ce99c9ee0cb06fb2a5826e641 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 12 Jul 2022 03:11:57 -0700 Subject: [PATCH 13/18] Update, add features --- ports/secp256k1/CMakeLists.txt | 59 +++++++++++++++++++++----- ports/secp256k1/libsecp256k1-config.h | 38 ----------------- ports/secp256k1/portfile.cmake | 52 ++++++++++++----------- ports/secp256k1/secp256k1-config.cmake | 1 - ports/secp256k1/vcpkg.json | 12 +++++- 5 files changed, 86 insertions(+), 76 deletions(-) delete mode 100644 ports/secp256k1/libsecp256k1-config.h delete mode 100644 ports/secp256k1/secp256k1-config.cmake diff --git a/ports/secp256k1/CMakeLists.txt b/ports/secp256k1/CMakeLists.txt index 3975e69cd43563..0f86ca49529be2 100644 --- a/ports/secp256k1/CMakeLists.txt +++ b/ports/secp256k1/CMakeLists.txt @@ -2,47 +2,84 @@ cmake_minimum_required(VERSION 3.8) project(secp256k1 C) option(INSTALL_HEADERS "Install header files" ON) +option(BUILD_TOOLS "Build tools" OFF) +option(BUILD_EXAMPLES "Build examples" OFF) add_definitions( -DENABLE_MODULE_ECDH -DENABLE_MODULE_RECOVERY -DENABLE_MODULE_EXTRAKEYS -DENABLE_MODULE_SCHNORRSIG - -DHAVE_CONFIG_H ) file(GLOB SOURCES src/secp256k1.c) add_library(secp256k1 ${SOURCES}) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}/src) +target_include_directories(secp256k1 PUBLIC $ $) -target_include_directories(secp256k1 PUBLIC $ $) - -file(GLOB SOURCES_PRECOMP src/precomputed_ecmult_gen.c src/precomputed_ecmult.c) +file(GLOB SOURCES_PRECOMP src/precomputed_ecmult.c src/precomputed_ecmult_gen.c) add_library(secp256k1_precomputed ${SOURCES_PRECOMP}) -target_include_directories(secp256k1_precomputed PUBLIC $ $) +target_include_directories(secp256k1_precomputed PUBLIC $ $) + +if (BUILD_TOOLS) + add_executable(bench src/bench.c) + target_link_libraries(bench PRIVATE secp256k1 secp256k1_precomputed) + + add_executable(bench_internal src/bench_internal.c) + target_link_libraries(bench_internal PRIVATE secp256k1_precomputed) + + add_executable(bench_ecmult src/bench_ecmult.c) + target_link_libraries(bench_ecmult PRIVATE secp256k1_precomputed) + + install(TARGETS bench bench_internal bench_ecmult RUNTIME DESTINATION bin) +endif() + +if (BUILD_EXAMPLES) + add_executable(ecdsa_example examples/ecdsa.c) + target_include_directories(ecdsa_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_link_libraries(ecdsa_example PRIVATE secp256k1 secp256k1_precomputed) + if (WIN32) + target_link_libraries(ecdsa_example PRIVATE Bcrypt) + endif() + + add_executable(ecdh_example examples/ecdh.c) + target_include_directories(ecdh_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_link_libraries(ecdh_example PRIVATE secp256k1 secp256k1_precomputed) + if (WIN32) + target_link_libraries(ecdh_example PRIVATE Bcrypt) + endif() + + add_executable(schnorr_example examples/schnorr.c) + target_include_directories(schnorr_example PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/include) + target_link_libraries(schnorr_example PRIVATE secp256k1 secp256k1_precomputed) + if (WIN32) + target_link_libraries(schnorr_example PRIVATE Bcrypt) + endif() + + install(TARGETS ecdsa_example ecdh_example schnorr_example RUNTIME DESTINATION bin) +endif() if(INSTALL_HEADERS) file(GLOB HEADERS include/*.h) install(FILES ${HEADERS} DESTINATION include) endif() -install(TARGETS secp256k1 EXPORT unofficial-secp256k1-targets +install(TARGETS secp256k1 EXPORT unofficial-secp256k1-config RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) -install(TARGETS secp256k1_precomputed EXPORT unofficial-secp256k1-targets +install(TARGETS secp256k1_precomputed EXPORT unofficial-secp256k1-config RUNTIME DESTINATION bin ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) install( - EXPORT unofficial-secp256k1-targets - FILE unofficial-secp256k1-targets.cmake + EXPORT unofficial-secp256k1-config + FILE unofficial-secp256k1-config.cmake NAMESPACE unofficial:: DESTINATION share/unofficial-secp256k1 -) \ No newline at end of file +) diff --git a/ports/secp256k1/libsecp256k1-config.h b/ports/secp256k1/libsecp256k1-config.h deleted file mode 100644 index 536d5ddc75f89a..00000000000000 --- a/ports/secp256k1/libsecp256k1-config.h +++ /dev/null @@ -1,38 +0,0 @@ -/********************************************************************** - * Copyright (c) 2013, 2014 Pieter Wuille * - * Distributed under the MIT software license, see the accompanying * - * file COPYING or http://www.opensource.org/licenses/mit-license.php.* - **********************************************************************/ - -#ifndef SECP256K1_BASIC_CONFIG_H -#define SECP256K1_BASIC_CONFIG_H - -#undef USE_ASM_X86_64 -#undef USE_ENDOMORPHISM -#undef USE_FIELD_10X26 -#undef USE_FIELD_5X52 -#undef USE_FIELD_INV_BUILTIN -#undef USE_FIELD_INV_NUM -#undef USE_NUM_GMP -#undef USE_NUM_NONE -#undef USE_SCALAR_4X64 -#undef USE_SCALAR_8X32 -#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 - -#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 - -#endif /* SECP256K1_BASIC_CONFIG_H */ diff --git a/ports/secp256k1/portfile.cmake b/ports/secp256k1/portfile.cmake index 30624c69aa375a..d834803e43f2f2 100644 --- a/ports/secp256k1/portfile.cmake +++ b/ports/secp256k1/portfile.cmake @@ -2,42 +2,46 @@ vcpkg_check_linkage(ONLY_STATIC_LIBRARY) vcpkg_from_github( OUT_SOURCE_PATH SOURCE_PATH - REPO "bitcoin-core/secp256k1" - REF "44c2452fd387f7ca604ab42d73746e7d3a44d8a2" - SHA512 1c1969b663843c71cba0148b14430bd2417b63a6ca7d6940585844b73aee2642622b080541ad3a1712390640f305f5bb1e251985d59674e1ded9cb4688f7830d + REPO bitcoin-core/secp256k1 + REF 3efeb9da21368c02cad58435b2ccdf6eb4b359c3 + SHA512 6d792943f9277a1b4c36dad62389cb38e0b93efb570b6af6c41afdb936d10ca30d4c2e4e743fc0f113d1f9785891d1e9d1fe224d7b8abd4197a9f5febf0febd6 ) -file(COPY "${CURRENT_PORT_DIR}/libsecp256k1-config.h" DESTINATION "${SOURCE_PATH}") file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") +file(COPY "${CMAKE_CURRENT_LIST_DIR}/secp256k1-config.cmake" DESTINATION "${SOURCE_PATH}") -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) - -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_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS + FEATURES + tools BUILD_TOOLS + examples BUILD_EXAMPLES +) vcpkg_cmake_configure( SOURCE_PATH "${SOURCE_PATH}" + OPTIONS + ${FEATURE_OPTIONS} OPTIONS_DEBUG - -DINSTALL_HEADERS=OFF + -DINSTALL_HEADERS=OFF ) vcpkg_cmake_install() +vcpkg_copy_pdbs() + vcpkg_cmake_config_fixup(CONFIG_PATH "share/unofficial-${PORT}" PACKAGE_NAME unofficial-${PORT}) +if (BUILD_TOOLS OR BUILD_EXAMPLES) + set(SECP256K1_TOOLS "") + if (BUILD_TOOLS) + list(APPEND SECP256K1_TOOLS bench bench_internal bench_ecmult) + endif() + + if (BUILD_EXAMPLES) + list(APPEND SECP256K1_TOOLS ecdsa_example ecdh_example schnorr_example) + endif() + + vcpkg_copy_tools(TOOL_NAMES ${SECP256K1_TOOLS} AUTO_CLEAN) +endif() + 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) diff --git a/ports/secp256k1/secp256k1-config.cmake b/ports/secp256k1/secp256k1-config.cmake deleted file mode 100644 index 5cc40fe829a9ae..00000000000000 --- a/ports/secp256k1/secp256k1-config.cmake +++ /dev/null @@ -1 +0,0 @@ -include("${CMAKE_CURRENT_LIST_DIR}/unofficial-secp256k1-targets.cmake") diff --git a/ports/secp256k1/vcpkg.json b/ports/secp256k1/vcpkg.json index 779f36dc31582e..6fa9895a83a583 100644 --- a/ports/secp256k1/vcpkg.json +++ b/ports/secp256k1/vcpkg.json @@ -1,6 +1,6 @@ { "name": "secp256k1", - "version-date": "2022-25-06", + "version-date": "2022-07-11", "port-version": 5, "description": "Optimized C library for EC operations on curve", "homepage": "https://github.com/bitcoin-core/secp256k1", @@ -14,5 +14,13 @@ "name": "vcpkg-cmake-config", "host": true } - ] + ], + "features": { + "examples": { + "description": "Build examples" + }, + "tools": { + "description": "Build tools" + } + } } From d881cfa3de1af4ff3bf2d636b8f1f7c9daf23cf5 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 12 Jul 2022 03:12:38 -0700 Subject: [PATCH 14/18] version --- versions/baseline.json | 2 +- versions/s-/secp256k1.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/versions/baseline.json b/versions/baseline.json index 4e5cc4c1519a69..2e343abfc558b0 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6477,7 +6477,7 @@ "port-version": 3 }, "secp256k1": { - "baseline": "2022-25-06", + "baseline": "2022-07-11", "port-version": 5 }, "selene": { diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index 9ecd154a80944c..4ee401283d8943 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,8 +1,8 @@ { "versions": [ { - "git-tree": "96f20db83c563f9526b6033f0ad8168a40add313", - "version-date": "2022-25-06", + "git-tree": "354a2ed2d724a86399e31f26008b1590f3db3245", + "version-date": "2022-07-11", "port-version": 5 }, { From 56fff2a5abd94cf7fa4cd6cad90c00b8843ec1a1 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 12 Jul 2022 03:16:13 -0700 Subject: [PATCH 15/18] fix --- ports/secp256k1/portfile.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/secp256k1/portfile.cmake b/ports/secp256k1/portfile.cmake index d834803e43f2f2..4c63bebed88b23 100644 --- a/ports/secp256k1/portfile.cmake +++ b/ports/secp256k1/portfile.cmake @@ -8,7 +8,6 @@ vcpkg_from_github( ) file(COPY "${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt" DESTINATION "${SOURCE_PATH}") -file(COPY "${CMAKE_CURRENT_LIST_DIR}/secp256k1-config.cmake" DESTINATION "${SOURCE_PATH}") vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS FEATURES From 354f6623cc15e9e7dbf31f8a25a0a11b50e5c10b Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Tue, 12 Jul 2022 03:16:24 -0700 Subject: [PATCH 16/18] version --- versions/s-/secp256k1.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index 4ee401283d8943..3eaab94caab0bf 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,7 +1,7 @@ { "versions": [ { - "git-tree": "354a2ed2d724a86399e31f26008b1590f3db3245", + "git-tree": "157c3d6dbe7d0ca23e5a16c1baa03a8c4f3b3cc3", "version-date": "2022-07-11", "port-version": 5 }, From 5653612b1a557daee3414e979be55f11ca84f1d8 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 14 Jul 2022 23:02:43 -0700 Subject: [PATCH 17/18] clean port version --- ports/secp256k1/vcpkg.json | 1 - 1 file changed, 1 deletion(-) diff --git a/ports/secp256k1/vcpkg.json b/ports/secp256k1/vcpkg.json index 6fa9895a83a583..f5c05ffeec8107 100644 --- a/ports/secp256k1/vcpkg.json +++ b/ports/secp256k1/vcpkg.json @@ -1,7 +1,6 @@ { "name": "secp256k1", "version-date": "2022-07-11", - "port-version": 5, "description": "Optimized C library for EC operations on curve", "homepage": "https://github.com/bitcoin-core/secp256k1", "license": "MIT", From f991e6b72a8a8dd72cacf565140271385ab595d9 Mon Sep 17 00:00:00 2001 From: JackBoosY Date: Thu, 14 Jul 2022 23:03:17 -0700 Subject: [PATCH 18/18] version --- versions/baseline.json | 2 +- versions/s-/secp256k1.json | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/versions/baseline.json b/versions/baseline.json index 2e343abfc558b0..9021a390d028d5 100644 --- a/versions/baseline.json +++ b/versions/baseline.json @@ -6478,7 +6478,7 @@ }, "secp256k1": { "baseline": "2022-07-11", - "port-version": 5 + "port-version": 0 }, "selene": { "baseline": "0.3.1", diff --git a/versions/s-/secp256k1.json b/versions/s-/secp256k1.json index 3eaab94caab0bf..ec3131b275b1bf 100644 --- a/versions/s-/secp256k1.json +++ b/versions/s-/secp256k1.json @@ -1,9 +1,9 @@ { "versions": [ { - "git-tree": "157c3d6dbe7d0ca23e5a16c1baa03a8c4f3b3cc3", + "git-tree": "31de2b5d2286595ff7771a30dee3c68d04e78082", "version-date": "2022-07-11", - "port-version": 5 + "port-version": 0 }, { "git-tree": "a0ba39af9284d60d41166c4f546975e9f2b2d9df",