Skip to content

Commit 3582814

Browse files
jonasnickdeadalnix
authored andcommitted
extrakeys: Init empty experimental module
Summary: This is to prepare for xonly_pubkeys and keypairs. This is a partial backport of secp256k1 [[bitcoin-core/secp256k1#558 | PR558]] : bitcoin-core/secp256k1@47e6618 Test Plan: ninja check-secp256k1 And with the module on: cmake -GNinja .. -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=On ninja check-secp256k1 Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Subscribers: Fabien Differential Revision: https://reviews.bitcoinabc.org/D7638
1 parent e3550eb commit 3582814

File tree

9 files changed

+84
-0
lines changed

9 files changed

+84
-0
lines changed

CMakeLists.txt

+7
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ if(SECP256K1_ENABLE_MODULE_SCHNORR)
226226
list(APPEND SECP256K1_PUBLIC_HEADERS include/secp256k1_schnorr.h)
227227
endif()
228228

229+
# Extrakeys module
230+
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Build libsecp256k1's Extrakeys module" OFF)
231+
if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
232+
set(ENABLE_MODULE_EXTRAKEYS 1)
233+
list(APPEND SECP256K1_PUBLIC_HEADERS include/secp256k1_extrakeys.h)
234+
endif()
235+
229236
# External default callbacks
230237
option(SECP256K1_ENABLE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callbacks" OFF)
231238
if(SECP256K1_ENABLE_EXTERNAL_DEFAULT_CALLBACKS)

Makefile.am

+4
Original file line numberDiff line numberDiff line change
@@ -197,3 +197,7 @@ endif
197197
if ENABLE_MODULE_SCHNORR
198198
include src/modules/schnorr/Makefile.am.include
199199
endif
200+
201+
if ENABLE_MODULE_EXTRAKEYS
202+
include src/modules/extrakeys/Makefile.am.include
203+
endif

configure.ac

+15
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,11 @@ AC_ARG_ENABLE(module_schnorr,
146146
[enable_module_schnorr=$enableval],
147147
[enable_module_schnorr=yes])
148148

149+
AC_ARG_ENABLE(module_extrakeys,
150+
AS_HELP_STRING([--enable-module-extrakeys],[enable extrakeys module (experimental)]),
151+
[enable_module_extrakeys=$enableval],
152+
[enable_module_extrakeys=no])
153+
149154
AC_ARG_ENABLE(external_default_callbacks,
150155
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]),
151156
[use_external_default_callbacks=$enableval],
@@ -481,6 +486,10 @@ if test x"$enable_module_schnorr" = x"yes"; then
481486
AC_DEFINE(ENABLE_MODULE_SCHNORR, 1, [Define this symbol to enable the Schnorr signature module])
482487
fi
483488

489+
if test x"$enable_module_extrakeys" = x"yes"; then
490+
AC_DEFINE(ENABLE_MODULE_EXTRAKEYS, 1, [Define this symbol to enable the extrakeys module])
491+
fi
492+
484493
if test x"$use_external_asm" = x"yes"; then
485494
AC_DEFINE(USE_EXTERNAL_ASM, 1, [Define this symbol if an external (non-inline) assembly implementation is used])
486495
fi
@@ -494,6 +503,7 @@ if test x"$enable_experimental" = x"yes"; then
494503
AC_MSG_NOTICE([WARNING: experimental build])
495504
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
496505
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
506+
AC_MSG_NOTICE([Building extrakeys module: $enable_module_extrakeys])
497507
AC_MSG_NOTICE([******])
498508
else
499509
if test x"$enable_module_ecdh" = x"yes"; then
@@ -502,6 +512,9 @@ else
502512
if test x"$enable_module_multiset" = x"yes"; then
503513
AC_MSG_ERROR([Multiset module is experimental. Use --enable-experimental to allow.])
504514
fi
515+
if test x"$enable_module_extrakeys" = x"yes"; then
516+
AC_MSG_ERROR([extrakeys module is experimental. Use --enable-experimental to allow.])
517+
fi
505518
if test x"$set_asm" = x"arm"; then
506519
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
507520
fi
@@ -521,6 +534,7 @@ AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
521534
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
522535
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
523536
AM_CONDITIONAL([ENABLE_MODULE_MULTISET], [test x"$enable_module_multiset" = x"yes"])
537+
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
524538
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
525539
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"])
526540
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" = x"yes"])
@@ -546,6 +560,7 @@ echo " module ecdh = $enable_module_ecdh"
546560
echo " module recovery = $enable_module_recovery"
547561
echo " module multiset = $enable_module_multiset"
548562
echo " module schnorr = $enable_module_schnorr"
563+
echo " module extrakeys = $enable_module_extrakeys"
549564
echo
550565
echo " asm = $set_asm"
551566
echo " bignum = $set_bignum"

include/secp256k1_extrakeys.h

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#ifndef SECP256K1_EXTRAKEYS_H
2+
#define SECP256K1_EXTRAKEYS_H
3+
4+
#include "secp256k1.h"
5+
6+
#ifdef __cplusplus
7+
extern "C" {
8+
#endif
9+
10+
#ifdef __cplusplus
11+
}
12+
#endif
13+
14+
#endif /* SECP256K1_EXTRAKEYS_H */
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include_HEADERS += include/secp256k1_extrakeys.h
2+
noinst_HEADERS += src/modules/extrakeys/tests_impl.h
3+
noinst_HEADERS += src/modules/extrakeys/main_impl.h

src/modules/extrakeys/main_impl.h

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**********************************************************************
2+
* Copyright (c) 2020 Jonas Nick *
3+
* Distributed under the MIT software license, see the accompanying *
4+
* file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5+
**********************************************************************/
6+
7+
#ifndef _SECP256K1_MODULE_EXTRAKEYS_MAIN_
8+
#define _SECP256K1_MODULE_EXTRAKEYS_MAIN_
9+
10+
#include "include/secp256k1.h"
11+
#include "include/secp256k1_extrakeys.h"
12+
13+
#endif

src/modules/extrakeys/tests_impl.h

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**********************************************************************
2+
* Copyright (c) 2020 Jonas Nick *
3+
* Distributed under the MIT software license, see the accompanying *
4+
* file COPYING or http://www.opensource.org/licenses/mit-license.php.*
5+
**********************************************************************/
6+
7+
#ifndef _SECP256K1_MODULE_EXTRAKEYS_TESTS_
8+
#define _SECP256K1_MODULE_EXTRAKEYS_TESTS_
9+
10+
#include "secp256k1_extrakeys.h"
11+
12+
void run_extrakeys_tests(void) {
13+
/* TODO */
14+
}
15+
16+
#endif

src/secp256k1.c

+4
Original file line numberDiff line numberDiff line change
@@ -751,3 +751,7 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
751751
#ifdef ENABLE_MODULE_SCHNORR
752752
# include "modules/schnorr/main_impl.h"
753753
#endif
754+
755+
#ifdef ENABLE_MODULE_EXTRAKEYS
756+
# include "modules/extrakeys/main_impl.h"
757+
#endif

src/tests.c

+8
Original file line numberDiff line numberDiff line change
@@ -5360,6 +5360,10 @@ void run_ecdsa_openssl(void) {
53605360
# include "modules/schnorr/tests_impl.h"
53615361
#endif
53625362

5363+
#ifdef ENABLE_MODULE_EXTRAKEYS
5364+
# include "modules/extrakeys/tests_impl.h"
5365+
#endif
5366+
53635367
void run_memczero_test(void) {
53645368
unsigned char buf1[6] = {1, 2, 3, 4, 5, 6};
53655369
unsigned char buf2[sizeof(buf1)];
@@ -5675,6 +5679,10 @@ int main(int argc, char **argv) {
56755679
run_schnorr_tests();
56765680
#endif
56775681

5682+
#ifdef ENABLE_MODULE_EXTRAKEYS
5683+
run_extrakeys_tests();
5684+
#endif
5685+
56785686
/* util tests */
56795687
run_memczero_test();
56805688

0 commit comments

Comments
 (0)