Skip to content

Commit

Permalink
Setup batch experimental module on cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Eunovo committed Nov 7, 2024
1 parent 43a4768 commit 7e3aba2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 8 deletions.
12 changes: 11 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -138,13 +138,22 @@ elseif(SECP256K1_ASM)
endif()
endif()

option(SECP256K1_EXPERIMENTAL "Allow experimental configuration options." OFF)
option(SECP256K1_EXPERIMENTAL "Allow experimental configuration options." ON)
if(NOT SECP256K1_EXPERIMENTAL)
if(SECP256K1_ASM STREQUAL "arm32")
message(FATAL_ERROR "ARM32 assembly is experimental. Use -DSECP256K1_EXPERIMENTAL=ON to allow.")
endif()
endif()

option(SECP256K1_ENABLE_MODULE_BATCH "Enable batch verification module." ON)
if(SECP256K1_ENABLE_MODULE_BATCH)
if(DEFINED SECP256K1_EXPERIMENTAL AND NOT SECP256K1_EXPERIMENTAL)
message(FATAL_ERROR "Batch verification module is experimental")
endif()
set(SECP256K1_ENABLE_MODULE_BATCH ON)
add_compile_definitions(ENABLE_MODULE_BATCH=1)
endif()

set(SECP256K1_VALGRIND "AUTO" CACHE STRING "Build with extra checks for running inside Valgrind. [default=AUTO]")
set_property(CACHE SECP256K1_VALGRIND PROPERTY STRINGS "AUTO" "OFF" "ON")
check_string_option_value(SECP256K1_VALGRIND)
Expand Down Expand Up @@ -306,6 +315,7 @@ message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOV
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
message(" ElligatorSwift ...................... ${SECP256K1_ENABLE_MODULE_ELLSWIFT}")
message(" Batch ............................... ${SECP256K1_ENABLE_MODULE_BATCH}")
message("Parameters:")
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
message(" ecmult gen table size ............... ${SECP256K1_ECMULT_GEN_KB} KiB")
Expand Down
4 changes: 4 additions & 0 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,7 @@ endif()
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
add_example(ellswift)
endif()

if(SECP256K1_ENABLE_MODULE_BATCH)
add_example(batch)
endif()
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,9 @@ if(SECP256K1_INSTALL)
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_ellswift.h")
endif()
if(SECP256K1_ENABLE_MODULE_BATCH)
list(APPEND ${PROJECT_NAME}_headers "${PROJECT_SOURCE_DIR}/include/secp256k1_batch.h" "${PROJECT_SOURCE_DIR}/include/secp256k1_schnorrsig_batch.h" "${PROJECT_SOURCE_DIR}/include/secp256k1_tweak_check_batch.h")
endif()
install(FILES ${${PROJECT_NAME}_headers}
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
Expand Down
2 changes: 1 addition & 1 deletion src/modules/batch/main_impl.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#ifndef SECP256K1_MODULE_BATCH_MAIN_H
#define SECP256K1_MODULE_BATCH_MAIN_H

#include "include/secp256k1_batch.h"
#include "../../../include/secp256k1_batch.h"

/* Maximum number of scalar-point pairs on the batch
* for which `secp256k1_batch_verify` remains efficient */
Expand Down
6 changes: 3 additions & 3 deletions src/modules/extrakeys/batch_add_impl.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef SECP256K1_MODULE_EXTRAKEYS_BATCH_ADD_IMPL_H
#define SECP256K1_MODULE_EXTRAKEYS_BATCH_ADD_IMPL_H

#include "include/secp256k1_extrakeys.h"
#include "include/secp256k1_tweak_check_batch.h"
#include "src/modules/batch/main_impl.h"
#include "../../../include/secp256k1_extrakeys.h"
#include "../../../include/secp256k1_tweak_check_batch.h"
#include "../batch/main_impl.h"

/* The number of scalar-point pairs allocated on the scratch space
* by `secp256k1_batch_add_xonlypub_tweak_check` */
Expand Down
6 changes: 3 additions & 3 deletions src/modules/schnorrsig/batch_add_impl.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
#ifndef SECP256K1_MODULE_SCHNORRSIG_BATCH_ADD_IMPL_H
#define SECP256K1_MODULE_SCHNORRSIG_BATCH_ADD_IMPL_H

#include "include/secp256k1_schnorrsig.h"
#include "include/secp256k1_schnorrsig_batch.h"
#include "src/modules/batch/main_impl.h"
#include "../../../include/secp256k1_schnorrsig.h"
#include "../../../include/secp256k1_schnorrsig_batch.h"
#include "../batch/main_impl.h"

/* The number of scalar-point pairs allocated on the scratch space
* by `secp256k1_batch_add_schnorrsig` */
Expand Down

0 comments on commit 7e3aba2

Please sign in to comment.