Skip to content

Commit db210f4

Browse files
committed
batch: Initialize an experimental batch module
This commit adds the foundational configuration, build scripts, and an initial structure for experimental batch module.
1 parent 694ce8f commit db210f4

File tree

7 files changed

+56
-0
lines changed

7 files changed

+56
-0
lines changed

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,3 +227,7 @@ endif
227227
if ENABLE_MODULE_SCHNORRSIG
228228
include src/modules/schnorrsig/Makefile.am.include
229229
endif
230+
231+
if ENABLE_MODULE_BATCH
232+
include src/modules/batch/Makefile.am.include
233+
endif

README.md

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

2526
Implementation details
2627
----------------------

configure.ac

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

173+
AC_ARG_ENABLE(module_batch,
174+
AS_HELP_STRING([--enable-module-batch],[enable batch verification module (experimental) [default=no]]), [],
175+
[SECP_SET_DEFAULT([enable_module_batch], [no], [yes])])
176+
173177
AC_ARG_ENABLE(external_default_callbacks,
174178
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]), [],
175179
[SECP_SET_DEFAULT([enable_external_default_callbacks], [no], [no])])
@@ -368,6 +372,10 @@ if test x"$enable_module_extrakeys" = x"yes"; then
368372
AC_DEFINE(ENABLE_MODULE_EXTRAKEYS, 1, [Define this symbol to enable the extrakeys module])
369373
fi
370374

375+
if test x"$enable_module_batch" = x"yes"; then
376+
AC_DEFINE(ENABLE_MODULE_BATCH, 1, [Define this symbol to enable the batch verification module])
377+
fi
378+
371379
if test x"$enable_external_default_callbacks" = x"yes"; then
372380
AC_DEFINE(USE_EXTERNAL_DEFAULT_CALLBACKS, 1, [Define this symbol if an external implementation of the default callbacks is used])
373381
fi
@@ -380,11 +388,15 @@ if test x"$enable_experimental" = x"yes"; then
380388
AC_MSG_NOTICE([******])
381389
AC_MSG_NOTICE([WARNING: experimental build])
382390
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
391+
AC_MSG_NOTICE([Building batch verification module: $enable_module_batch])
383392
AC_MSG_NOTICE([******])
384393
else
385394
if test x"$set_asm" = x"arm"; then
386395
AC_MSG_ERROR([ARM assembly optimization is experimental. Use --enable-experimental to allow.])
387396
fi
397+
if test x"$enable_module_batch" = x"yes"; then
398+
AC_MSG_ERROR([batch verification module is experimental. Use --enable-experimental to allow.])
399+
fi
388400
fi
389401

390402
###
@@ -407,6 +419,7 @@ AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
407419
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
408420
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
409421
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
422+
AM_CONDITIONAL([ENABLE_MODULE_BATCH], [test x"$enable_module_batch" = x"yes"])
410423
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
411424
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm"])
412425
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
@@ -427,6 +440,7 @@ echo " module ecdh = $enable_module_ecdh"
427440
echo " module recovery = $enable_module_recovery"
428441
echo " module extrakeys = $enable_module_extrakeys"
429442
echo " module schnorrsig = $enable_module_schnorrsig"
443+
echo " module batch = $enable_module_batch"
430444
echo
431445
echo " asm = $set_asm"
432446
echo " ecmult window size = $set_ecmult_window"

include/secp256k1_batch.h

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

src/modules/batch/Makefile.am.include

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
include_HEADERS += include/secp256k1_batch.h
2+
noinst_HEADERS += src/modules/batch/main_impl.h

src/modules/batch/main_impl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#ifndef SECP256K1_MODULE_BATCH_MAIN_H
2+
#define SECP256K1_MODULE_BATCH_MAIN_H
3+
4+
#include "include/secp256k1_batch.h"
5+
6+
#endif /* SECP256K1_MODULE_BATCH_MAIN_H */

src/secp256k1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -776,3 +776,7 @@ int secp256k1_tagged_sha256(const secp256k1_context* ctx, unsigned char *hash32,
776776
#ifdef ENABLE_MODULE_SCHNORRSIG
777777
# include "modules/schnorrsig/main_impl.h"
778778
#endif
779+
780+
#ifdef ENABLE_MODULE_BATCH
781+
# include "modules/batch/main_impl.h"
782+
#endif

0 commit comments

Comments
 (0)