Skip to content

Commit b7697cd

Browse files
jonasnickdeadalnix
authored andcommitted
schnorrsig: Init empty experimental module
Summary: This is a partial backport of secp256k1 [[bitcoin-core/secp256k1#558 | PR558]] : bitcoin-core/secp256k1@7a703fd Test Plan: ninja check-secp256k1 With missing extrakeys: cmake -GNinja .. -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=On Check that we get an error. And with the module: cmake -GNinja .. -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=On -DSECP256K1_ENABLE_MODULE_SCHNORRSIG=On ninja check-secp256k1 Reviewers: #bitcoin_abc, Fabien Reviewed By: #bitcoin_abc, Fabien Differential Revision: https://reviews.bitcoinabc.org/D7646
1 parent f995ae3 commit b7697cd

File tree

9 files changed

+99
-2
lines changed

9 files changed

+99
-2
lines changed

CMakeLists.txt

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ if(SECP256K1_ENABLE_MODULE_EXTRAKEYS)
233233
list(APPEND SECP256K1_PUBLIC_HEADERS include/secp256k1_extrakeys.h)
234234
endif()
235235

236+
# Schnorrsig module
237+
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Build libsecp256k1's Schnorrsig module" OFF)
238+
if(SECP256K1_ENABLE_MODULE_SCHNORRSIG)
239+
if(NOT SECP256K1_ENABLE_MODULE_EXTRAKEYS)
240+
message(FATAL_ERROR "The module Schnorrsig require Extrakeys. Try running cmake using -DSECP256K1_ENABLE_MODULE_EXTRAKEYS=On")
241+
endif()
242+
set(ENABLE_MODULE_SCHNORRSIG 1)
243+
list(APPEND SECP256K1_PUBLIC_HEADERS include/secp256k1_schnorrsig.h)
244+
endif()
245+
236246
# External default callbacks
237247
option(SECP256K1_ENABLE_EXTERNAL_DEFAULT_CALLBACKS "Enable external default callbacks" OFF)
238248
if(SECP256K1_ENABLE_EXTERNAL_DEFAULT_CALLBACKS)

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,3 +201,7 @@ endif
201201
if ENABLE_MODULE_EXTRAKEYS
202202
include src/modules/extrakeys/Makefile.am.include
203203
endif
204+
205+
if ENABLE_MODULE_SCHNORRSIG
206+
include src/modules/schnorrsig/Makefile.am.include
207+
endif

configure.ac

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,11 @@ AC_ARG_ENABLE(module_extrakeys,
151151
[enable_module_extrakeys=$enableval],
152152
[enable_module_extrakeys=no])
153153

154+
AC_ARG_ENABLE(module_schnorrsig,
155+
AS_HELP_STRING([--enable-module-schnorrsig],[enable schnorrsig module (experimental)]),
156+
[enable_module_schnorrsig=$enableval],
157+
[enable_module_schnorrsig=no])
158+
154159
AC_ARG_ENABLE(external_default_callbacks,
155160
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]),
156161
[use_external_default_callbacks=$enableval],
@@ -486,6 +491,13 @@ if test x"$enable_module_schnorr" = x"yes"; then
486491
AC_DEFINE(ENABLE_MODULE_SCHNORR, 1, [Define this symbol to enable the Schnorr signature module])
487492
fi
488493

494+
if test x"$enable_module_schnorrsig" = x"yes"; then
495+
AC_DEFINE(ENABLE_MODULE_SCHNORRSIG, 1, [Define this symbol to enable the schnorrsig module])
496+
enable_module_extrakeys=yes
497+
fi
498+
499+
# Test if extrakeys is set after the schnorrsig module to allow the schnorrsig
500+
# module to set enable_module_extrakeys=yes
489501
if test x"$enable_module_extrakeys" = x"yes"; then
490502
AC_DEFINE(ENABLE_MODULE_EXTRAKEYS, 1, [Define this symbol to enable the extrakeys module])
491503
fi
@@ -504,6 +516,7 @@ if test x"$enable_experimental" = x"yes"; then
504516
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
505517
AC_MSG_NOTICE([Building ECDH module: $enable_module_ecdh])
506518
AC_MSG_NOTICE([Building extrakeys module: $enable_module_extrakeys])
519+
AC_MSG_NOTICE([Building schnorrsig module: $enable_module_schnorrsig])
507520
AC_MSG_NOTICE([******])
508521
else
509522
if test x"$enable_module_ecdh" = x"yes"; then
@@ -515,6 +528,9 @@ else
515528
if test x"$enable_module_extrakeys" = x"yes"; then
516529
AC_MSG_ERROR([extrakeys module is experimental. Use --enable-experimental to allow.])
517530
fi
531+
if test x"$enable_module_schnorrsig" = x"yes"; then
532+
AC_MSG_ERROR([schnorrsig module is experimental. Use --enable-experimental to allow.])
533+
fi
518534
if test x"$set_asm" = x"arm"; then
519535
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
520536
fi
@@ -533,10 +549,11 @@ AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$use_exhaustive_tests" != x"no"])
533549
AM_CONDITIONAL([USE_BENCHMARK], [test x"$use_benchmark" = x"yes"])
534550
AM_CONDITIONAL([USE_ECMULT_STATIC_PRECOMPUTATION], [test x"$set_precomp" = x"yes"])
535551
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
536-
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"])
538552
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
553+
AM_CONDITIONAL([ENABLE_MODULE_MULTISET], [test x"$enable_module_multiset" = x"yes"])
539554
AM_CONDITIONAL([ENABLE_MODULE_SCHNORR], [test x"$enable_module_schnorr" = x"yes"])
555+
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
556+
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
540557
AM_CONDITIONAL([USE_JNI], [test x"$use_jni" = x"yes"])
541558
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$use_external_asm" = x"yes"])
542559
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
@@ -561,6 +578,7 @@ echo " module recovery = $enable_module_recovery"
561578
echo " module multiset = $enable_module_multiset"
562579
echo " module schnorr = $enable_module_schnorr"
563580
echo " module extrakeys = $enable_module_extrakeys"
581+
echo " module schnorrsig = $enable_module_schnorrsig"
564582
echo
565583
echo " asm = $set_asm"
566584
echo " bignum = $set_bignum"

include/secp256k1_schnorrsig.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef SECP256K1_SCHNORRSIG_H
2+
#define SECP256K1_SCHNORRSIG_H
3+
4+
#include "secp256k1.h"
5+
#include "secp256k1_extrakeys.h"
6+
7+
#ifdef __cplusplus
8+
extern "C" {
9+
#endif
10+
11+
/* TODO */
12+
13+
#ifdef __cplusplus
14+
}
15+
#endif
16+
17+
#endif /* SECP256K1_SCHNORRSIG_H */
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
include_HEADERS += include/secp256k1_schnorrsig.h
2+
noinst_HEADERS += src/modules/schnorrsig/main_impl.h
3+
noinst_HEADERS += src/modules/schnorrsig/tests_impl.h

src/modules/schnorrsig/main_impl.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**********************************************************************
2+
* Copyright (c) 2018-2020 Andrew Poelstra, 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_SCHNORRSIG_MAIN_
8+
#define _SECP256K1_MODULE_SCHNORRSIG_MAIN_
9+
10+
#include "include/secp256k1.h"
11+
#include "include/secp256k1_schnorrsig.h"
12+
#include "hash.h"
13+
14+
/* TODO */
15+
16+
#endif

src/modules/schnorrsig/tests_impl.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/**********************************************************************
2+
* Copyright (c) 2018-2020 Andrew Poelstra, 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_SCHNORRSIG_TESTS_
8+
9+
#define _SECP256K1_MODULE_SCHNORRSIG_TESTS_
10+
11+
#include "secp256k1_schnorrsig.h"
12+
13+
void run_schnorrsig_tests(void) {
14+
/* TODO */
15+
}
16+
17+
#endif

src/secp256k1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -770,3 +770,7 @@ int secp256k1_ec_pubkey_combine(const secp256k1_context* ctx, secp256k1_pubkey *
770770
#ifdef ENABLE_MODULE_EXTRAKEYS
771771
# include "modules/extrakeys/main_impl.h"
772772
#endif
773+
774+
#ifdef ENABLE_MODULE_SCHNORRSIG
775+
# include "modules/schnorrsig/main_impl.h"
776+
#endif

src/tests.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5364,6 +5364,10 @@ void run_ecdsa_openssl(void) {
53645364
# include "modules/extrakeys/tests_impl.h"
53655365
#endif
53665366

5367+
#ifdef ENABLE_MODULE_SCHNORRSIG
5368+
# include "modules/schnorrsig/tests_impl.h"
5369+
#endif
5370+
53675371
void run_memczero_test(void) {
53685372
unsigned char buf1[6] = {1, 2, 3, 4, 5, 6};
53695373
unsigned char buf2[sizeof(buf1)];
@@ -5683,6 +5687,10 @@ int main(int argc, char **argv) {
56835687
run_extrakeys_tests();
56845688
#endif
56855689

5690+
#ifdef ENABLE_MODULE_SCHNORRSIG
5691+
run_schnorrsig_tests();
5692+
#endif
5693+
56865694
/* util tests */
56875695
run_memczero_test();
56885696

0 commit comments

Comments
 (0)