Skip to content

Commit 957eb03

Browse files
theStackjosibake
authored andcommitted
build: add skeleton for new silentpayments (BIP352) module
1 parent 7712a53 commit 957eb03

File tree

7 files changed

+62
-0
lines changed

7 files changed

+62
-0
lines changed

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,14 @@ option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." O
6060
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
6161
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
6262
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
63+
option(SECP256K1_ENABLE_MODULE_SILENTPAYMENTS "Enable Silent Payments module." OFF)
6364

6465
# Processing must be done in a topological sorting of the dependency graph
6566
# (dependent module first).
67+
if(SECP256K1_ENABLE_MODULE_SILENTPAYMENTS)
68+
add_compile_definitions(ENABLE_MODULE_SILENTPAYMENTS=1)
69+
endif()
70+
6671
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
6772
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
6873
endif()
@@ -301,6 +306,7 @@ message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOV
301306
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
302307
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
303308
message(" ElligatorSwift ...................... ${SECP256K1_ENABLE_MODULE_ELLSWIFT}")
309+
message(" Silent Payments ..................... ${SECP256K1_ENABLE_MODULE_SILENTPAYMENTS}")
304310
message("Parameters:")
305311
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
306312
message(" ecmult gen table size ............... ${SECP256K1_ECMULT_GEN_KB} KiB")

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -273,3 +273,7 @@ endif
273273
if ENABLE_MODULE_ELLSWIFT
274274
include src/modules/ellswift/Makefile.am.include
275275
endif
276+
277+
if ENABLE_MODULE_SILENTPAYMENTS
278+
include src/modules/silentpayments/Makefile.am.include
279+
endif

configure.ac

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ AC_ARG_ENABLE(module_ellswift,
188188
AS_HELP_STRING([--enable-module-ellswift],[enable ElligatorSwift module [default=yes]]), [],
189189
[SECP_SET_DEFAULT([enable_module_ellswift], [yes], [yes])])
190190

191+
AC_ARG_ENABLE(module_silentpayments,
192+
AS_HELP_STRING([--enable-module-silentpayments],[enable Silent Payments module [default=no]]), [],
193+
[SECP_SET_DEFAULT([enable_module_silentpayments], [no], [yes])])
194+
191195
AC_ARG_ENABLE(external_default_callbacks,
192196
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]), [],
193197
[SECP_SET_DEFAULT([enable_external_default_callbacks], [no], [no])])
@@ -394,6 +398,10 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
394398

395399
# Processing must be done in a reverse topological sorting of the dependency graph
396400
# (dependent module first).
401+
if test x"$enable_module_silentpayments" = x"yes"; then
402+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SILENTPAYMENTS=1"
403+
fi
404+
397405
if test x"$enable_module_ellswift" = x"yes"; then
398406
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ELLSWIFT=1"
399407
fi
@@ -455,6 +463,7 @@ AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"ye
455463
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
456464
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
457465
AM_CONDITIONAL([ENABLE_MODULE_ELLSWIFT], [test x"$enable_module_ellswift" = x"yes"])
466+
AM_CONDITIONAL([ENABLE_MODULE_SILENTPAYMENTS], [test x"$enable_module_silentpayments" = x"yes"])
458467
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
459468
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm32"])
460469
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
@@ -477,6 +486,7 @@ echo " module recovery = $enable_module_recovery"
477486
echo " module extrakeys = $enable_module_extrakeys"
478487
echo " module schnorrsig = $enable_module_schnorrsig"
479488
echo " module ellswift = $enable_module_ellswift"
489+
echo " module silentpayments = $enable_module_silentpayments"
480490
echo
481491
echo " asm = $set_asm"
482492
echo " ecmult window size = $set_ecmult_window"

include/secp256k1_silentpayments.h

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#ifndef SECP256K1_SILENTPAYMENTS_H
2+
#define SECP256K1_SILENTPAYMENTS_H
3+
4+
#include "secp256k1.h"
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
/* TODO: add module description */
11+
12+
/* TODO: add function API for sender side. */
13+
14+
/* TODO: add function API for receiver side. */
15+
16+
#ifdef __cplusplus
17+
}
18+
#endif
19+
20+
#endif /* SECP256K1_SILENTPAYMENTS_H */
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include_HEADERS += include/secp256k1_silentpayments.h
2+
noinst_HEADERS += src/modules/silentpayments/main_impl.h
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/***********************************************************************
2+
* Distributed under the MIT software license, see the accompanying *
3+
* file COPYING or https://www.opensource.org/licenses/mit-license.php.*
4+
***********************************************************************/
5+
6+
#ifndef SECP256K1_MODULE_SILENTPAYMENTS_MAIN_H
7+
#define SECP256K1_MODULE_SILENTPAYMENTS_MAIN_H
8+
9+
#include "../../../include/secp256k1.h"
10+
#include "../../../include/secp256k1_silentpayments.h"
11+
12+
/* TODO: implement functions for sender side. */
13+
14+
/* TODO: implement functions for receiver side. */
15+
16+
#endif

src/secp256k1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -833,3 +833,7 @@ int secp256k1_tagged_sha256(const secp256k1_context* ctx, unsigned char *hash32,
833833
#ifdef ENABLE_MODULE_ELLSWIFT
834834
# include "modules/ellswift/main_impl.h"
835835
#endif
836+
837+
#ifdef ENABLE_MODULE_SILENTPAYMENTS
838+
# include "modules/silentpayments/main_impl.h"
839+
#endif

0 commit comments

Comments
 (0)