Skip to content

Commit b83c814

Browse files
committed
bulletproofs: add new empty module
1 parent 194f486 commit b83c814

File tree

11 files changed

+131
-1
lines changed

11 files changed

+131
-1
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,12 @@
11
bench
2+
bench_bulletproofs
23
bench_ecmult
34
bench_generator
45
bench_rangeproof
56
bench_internal
7+
bench_whitelist
68
tests
9+
example_musig
710
exhaustive_tests
811
precompute_ecmult_gen
912
precompute_ecmult
@@ -66,4 +69,4 @@ src/stamp-h1
6669
libsecp256k1.pc
6770
contrib/gh-pr-create.sh
6871

69-
musig_example
72+
musig_example

Makefile.am

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,10 @@ clean-precomp:
226226

227227
EXTRA_DIST = autogen.sh SECURITY.md
228228

229+
if ENABLE_MODULE_BULLETPROOFS
230+
include src/modules/bulletproofs/Makefile.am.include
231+
endif
232+
229233
if ENABLE_MODULE_ECDH
230234
include src/modules/ecdh/Makefile.am.include
231235
endif

ci/cirrus.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ valgrind --version || true
1919
--with-ecmult-gen-precision="$ECMULTGENPRECISION" \
2020
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
2121
--enable-module-ecdsa-s2c="$ECDSA_S2C" \
22+
--enable-module-bulletproofs="$BULLETPROOFS" \
2223
--enable-module-rangeproof="$RANGEPROOF" --enable-module-whitelist="$WHITELIST" --enable-module-generator="$GENERATOR" \
2324
--enable-module-schnorrsig="$SCHNORRSIG" --enable-module-musig="$MUSIG" --enable-module-ecdsa-adaptor="$ECDSAADAPTOR" \
2425
--enable-module-schnorrsig="$SCHNORRSIG" \

configure.ac

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ AC_ARG_ENABLE(examples,
140140
AS_HELP_STRING([--enable-examples],[compile the examples [default=no]]), [],
141141
[SECP_SET_DEFAULT([enable_examples], [no], [yes])])
142142

143+
AC_ARG_ENABLE(module_bulletproofs,
144+
AS_HELP_STRING([--enable-module-bulletproofs],[enable Bulletproofs module (experimental)]),
145+
[],
146+
[SECP_SET_DEFAULT([enable_module_bulletproofs], [no], [yes])])
147+
143148
AC_ARG_ENABLE(module_ecdh,
144149
AS_HELP_STRING([--enable-module-ecdh],[enable ECDH module [default=no]]), [],
145150
[SECP_SET_DEFAULT([enable_module_ecdh], [no], [yes])])
@@ -385,6 +390,10 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
385390
### Handle module options
386391
###
387392

393+
if test x"$enable_module_bulletproofs" = x"yes"; then
394+
AC_DEFINE(ENABLE_MODULE_BULLETPROOFS, 1, [Define this symbol to enable the Bulletproofs module])
395+
fi
396+
388397
if test x"$enable_module_ecdh" = x"yes"; then
389398
AC_DEFINE(ENABLE_MODULE_ECDH, 1, [Define this symbol to enable the ECDH module])
390399
fi
@@ -450,6 +459,7 @@ if test x"$enable_experimental" = x"yes"; then
450459
AC_MSG_NOTICE([******])
451460
AC_MSG_NOTICE([WARNING: experimental build])
452461
AC_MSG_NOTICE([Experimental features do not have stable APIs or properties, and may not be safe for production use.])
462+
AC_MSG_NOTICE([Building Bulletproofs module: $enable_module_bulletproofs])
453463
AC_MSG_NOTICE([Building NUMS generator module: $enable_module_generator])
454464
AC_MSG_NOTICE([Building range proof module: $enable_module_rangeproof])
455465
AC_MSG_NOTICE([Building key whitelisting module: $enable_module_whitelist])
@@ -467,6 +477,9 @@ if test x"$enable_experimental" = x"yes"; then
467477
fi
468478

469479
if test x"$enable_module_generator" != x"yes"; then
480+
if test x"$enable_module_bulletproofs" = x"yes"; then
481+
AC_MSG_ERROR([Bulletproofs module requires the generator module. Use --enable-module-generator to allow.])
482+
fi
470483
if test x"$enable_module_rangeproof" = x"yes"; then
471484
AC_MSG_ERROR([Rangeproof module requires the generator module. Use --enable-module-generator to allow.])
472485
fi
@@ -481,6 +494,9 @@ if test x"$enable_experimental" = x"yes"; then
481494
fi
482495
fi
483496
else
497+
if test x"$enable_module_bulletproofs" = x"yes"; then
498+
AC_MSG_ERROR([Bulletproofs module is experimental. Use --enable-experimental to allow.])
499+
fi
484500
if test x"$enable_module_musig" = x"yes"; then
485501
AC_MSG_ERROR([MuSig module is experimental. Use --enable-experimental to allow.])
486502
fi
@@ -523,6 +539,7 @@ AM_CONDITIONAL([USE_TESTS], [test x"$enable_tests" != x"no"])
523539
AM_CONDITIONAL([USE_EXHAUSTIVE_TESTS], [test x"$enable_exhaustive_tests" != x"no"])
524540
AM_CONDITIONAL([USE_EXAMPLES], [test x"$enable_examples" != x"no"])
525541
AM_CONDITIONAL([USE_BENCHMARK], [test x"$enable_benchmark" = x"yes"])
542+
AM_CONDITIONAL([ENABLE_MODULE_BULLETPROOFS], [test x"$enable_module_bulletproofs" = x"yes"])
526543
AM_CONDITIONAL([ENABLE_MODULE_ECDH], [test x"$enable_module_ecdh" = x"yes"])
527544
AM_CONDITIONAL([ENABLE_MODULE_MUSIG], [test x"$enable_module_musig" = x"yes"])
528545
AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"yes"])
@@ -558,6 +575,7 @@ echo " module schnorrsig = $enable_module_schnorrsig"
558575
echo " module musig = $enable_module_musig"
559576
echo " module ecdsa-s2c = $enable_module_ecdsa_s2c"
560577
echo " module ecdsa-adaptor = $enable_module_ecdsa_adaptor"
578+
echo " module bulletproofs = $enable_module_bulletproofs"
561579
echo
562580
echo " asm = $set_asm"
563581
echo " ecmult window size = $set_ecmult_window"

include/secp256k1_bulletproofs.h

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#ifndef _SECP256K1_BULLETPROOFS_
2+
# define _SECP256K1_BULLETPROOFS_
3+
4+
# include "secp256k1.h"
5+
6+
# ifdef __cplusplus
7+
extern "C" {
8+
# endif
9+
10+
#include <stdint.h>
11+
12+
/* TODO */
13+
14+
# ifdef __cplusplus
15+
}
16+
# endif
17+
18+
#endif

src/bench_bulletproofs.c

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
/**********************************************************************
2+
* Copyright (c) 2020 Andrew Poelstra *
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+
#include <stdint.h>
8+
9+
#include "include/secp256k1_bulletproofs.h"
10+
#include "util.h"
11+
#include "bench.h"
12+
13+
typedef struct {
14+
secp256k1_context* ctx;
15+
} bench_bulletproofs_data;
16+
17+
static void bench_bulletproofs_setup(void* arg) {
18+
(void) arg;
19+
}
20+
21+
static void bench_bulletproofs(void* arg, int iters) {
22+
bench_bulletproofs_data *data = (bench_bulletproofs_data*)arg;
23+
24+
(void) data;
25+
(void) iters;
26+
}
27+
28+
int main(void) {
29+
bench_bulletproofs_data data;
30+
int iters = get_iters(32);
31+
32+
data.ctx = secp256k1_context_create(SECP256K1_CONTEXT_SIGN | SECP256K1_CONTEXT_VERIFY);
33+
34+
run_benchmark("bulletproofs_verify_bit", bench_bulletproofs, bench_bulletproofs_setup, NULL, &data, 10, iters);
35+
36+
secp256k1_context_destroy(data.ctx);
37+
return 0;
38+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
include_HEADERS += include/secp256k1_bulletproofs.h
2+
noinst_HEADERS += src/modules/bulletproofs/tests_impl.h
3+
noinst_HEADERS += src/modules/bulletproofs/main_impl.h
4+
5+
if USE_BENCHMARK
6+
noinst_PROGRAMS += bench_bulletproofs
7+
bench_bulletproofs_SOURCES = src/bench_bulletproofs.c
8+
bench_bulletproofs_LDADD = libsecp256k1.la $(SECP_LIBS)
9+
bench_bulletproofs_LDFLAGS = -static
10+
endif
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**********************************************************************
2+
* Copyright (c) 2020 Andrew Poelstra *
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_BULLETPROOFS_MAIN_
8+
#define _SECP256K1_MODULE_BULLETPROOFS_MAIN_
9+
10+
/* TODO */
11+
12+
#endif
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
/**********************************************************************
2+
* Copyright (c) 2020 Andrew Poelstra *
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_BULLETPROOFS_TEST_
8+
#define _SECP256K1_MODULE_BULLETPROOFS_TEST_
9+
10+
void run_bulletproofs_tests(void) {
11+
/* TODO */
12+
}
13+
14+
#endif

src/secp256k1.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -800,6 +800,10 @@ int secp256k1_tagged_sha256(const secp256k1_context* ctx, unsigned char *hash32,
800800
return 1;
801801
}
802802

803+
#ifdef ENABLE_MODULE_BULLETPROOFS
804+
# include "modules/bulletproofs/main_impl.h"
805+
#endif
806+
803807
#ifdef ENABLE_MODULE_ECDH
804808
# include "modules/ecdh/main_impl.h"
805809
#endif

0 commit comments

Comments
 (0)