Skip to content

Commit cac2701

Browse files
committed
batch_interface: initialize empty batch module (experimental)
1 parent a2ee400 commit cac2701

File tree

7 files changed

+59
-0
lines changed

7 files changed

+59
-0
lines changed

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,3 +238,7 @@ endif
238238
if ENABLE_MODULE_SCHNORRSIG
239239
include src/modules/schnorrsig/Makefile.am.include
240240
endif
241+
242+
if ENABLE_MODULE_BATCH
243+
include src/modules/batch/Makefile.am.include
244+
endif

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Features:
1818
* Optional module for public key recovery.
1919
* Optional module for ECDH key exchange.
2020
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
21+
* Optional module for Batch Verification (experimental).
2122

2223
Implementation details
2324
----------------------

configure.ac

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,10 @@ AC_ARG_ENABLE(module_schnorrsig,
156156
AS_HELP_STRING([--enable-module-schnorrsig],[enable schnorrsig module [default=no]]), [],
157157
[SECP_SET_DEFAULT([enable_module_schnorrsig], [no], [yes])])
158158

159+
AC_ARG_ENABLE(module_batch,
160+
AS_HELP_STRING([--enable-module-batch],[enable batch verification module (experimental) [default=no]]), [],
161+
[SECP_SET_DEFAULT([enable_module_batch], [no], [yes])])
162+
159163
AC_ARG_ENABLE(external_default_callbacks,
160164
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]), [],
161165
[SECP_SET_DEFAULT([enable_external_default_callbacks], [no], [no])])
@@ -352,6 +356,10 @@ if test x"$enable_module_extrakeys" = x"yes"; then
352356
AC_DEFINE(ENABLE_MODULE_EXTRAKEYS, 1, [Define this symbol to enable the extrakeys module])
353357
fi
354358

359+
if test x"$enable_module_batch" = x"yes"; then
360+
AC_DEFINE(ENABLE_MODULE_BATCH, 1, [Define this symbol to enable the batch verification module])
361+
fi
362+
355363
if test x"$enable_external_default_callbacks" = x"yes"; then
356364
AC_DEFINE(USE_EXTERNAL_DEFAULT_CALLBACKS, 1, [Define this symbol if an external implementation of the default callbacks is used])
357365
fi
@@ -364,11 +372,15 @@ if test x"$enable_experimental" = x"yes"; then
364372
AC_MSG_NOTICE([******])
365373
AC_MSG_NOTICE([WARNING: experimental build])
366374
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
375+
AC_MSG_NOTICE([Building batch verification module: $enable_module_batch])
367376
AC_MSG_NOTICE([******])
368377
else
369378
if test x"$set_asm" = x"arm"; then
370379
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
371380
fi
381+
if test x"$enable_module_batch" = x"yes"; then
382+
AC_MSG_ERROR([batch verification module is experimental. Use --enable-experimental to allow.])
383+
fi
372384
fi
373385

374386
###
@@ -391,6 +403,7 @@ AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
391403
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
392404
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
393405
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
406+
AM_CONDITIONAL([ENABLE_MODULE_BATCH], [test x"$enable_module_batch" = x"yes"])
394407
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
395408
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
396409
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
@@ -411,6 +424,7 @@ echo " module ecdh = $enable_module_ecdh"
411424
echo " module recovery = $enable_module_recovery"
412425
echo " module extrakeys = $enable_module_extrakeys"
413426
echo " module schnorrsig = $enable_module_schnorrsig"
427+
echo " module batch = $enable_module_batch"
414428
echo
415429
echo " asm = $set_asm"
416430
echo " ecmult window size = $set_ecmult_window"

include/secp256k1_batch.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#ifndef SECP256K1_BATCH_H
2+
#define SECP256K1_BATCH_H
3+
4+
#ifdef __cplusplus
5+
extern "C" {
6+
#endif
7+
8+
/** This module implements a Batch Verification context that supports:
9+
*
10+
* 1. Schnorr signatures compliant with Bitcoin Improvement Proposal 340
11+
* "Schnorr Signatures for secp256k1"
12+
* (https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
13+
*
14+
* 2. Taproot commitments compliant with Bitcoin Improvemtn Proposal 341
15+
* "Taproot: SegWit version 1 spending rules"
16+
* (https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki).
17+
*/
18+
19+
#ifdef __cplusplus
20+
}
21+
#endif
22+
23+
#endif /* SECP256K1_BATCH_H */

src/modules/batch/Makefile.am.include

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
include_HEADERS += include/secp256k1_batch.h

src/modules/batch/main_impl.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**********************************************************************
2+
* Copyright (c) 2022 Jonas Nick, Sivaram Dhakshinamoorthy *
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_BATCH_MAIN_H
8+
#define SECP256K1_MODULE_BATCH_MAIN_H
9+
10+
#include "include/secp256k1_batch.h"
11+
12+
#endif /* SECP256K1_MODULE_BATCH_MAIN_H */

src/secp256k1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -784,3 +784,7 @@ int secp256k1_tagged_sha256(const secp256k1_context* ctx, unsigned char *hash32,
784784
# include "modules/schnorrsig/main_impl.h"
785785
# include "modules/schnorrsig/batch_add_impl.h"
786786
#endif
787+
788+
#ifdef ENABLE_MODULE_BATCH
789+
# include "modules/batch/main_impl.h"
790+
#endif

0 commit comments

Comments
 (0)