Skip to content

Commit f4db5d1

Browse files
committed
examples: add batch_example
added initial example where the batch context is created and destroyed.
1 parent 485e2dd commit f4db5d1

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ valgrind_ctime_test
99
ecdh_example
1010
ecdsa_example
1111
schnorr_example
12+
batch_example
1213
*.exe
1314
*.so
1415
*.a

Makefile.am

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ noinst_HEADERS += src/assumptions.h
5050
noinst_HEADERS += src/util.h
5151
noinst_HEADERS += src/scratch.h
5252
noinst_HEADERS += src/scratch_impl.h
53+
noinst_HEADERS += src/batch_impl.h
5354
noinst_HEADERS += src/selftest.h
5455
noinst_HEADERS += src/testrand.h
5556
noinst_HEADERS += src/testrand_impl.h
@@ -150,6 +151,15 @@ if BUILD_WINDOWS
150151
ecdsa_example_LDFLAGS += -lbcrypt
151152
endif
152153
TESTS += ecdsa_example
154+
noinst_PROGRAMS += batch_example
155+
batch_example_SOURCES = examples/batch.c
156+
batch_example_CPPFLAGS = -I$(top_srcdir)/include
157+
batch_example_LDADD = libsecp256k1.la
158+
batch_example_LDFLAGS = -static
159+
if BUILD_WINDOWS
160+
ecdsa_example_LDFLAGS += -lbcrypt
161+
endif
162+
TESTS += batch_example
153163
if ENABLE_MODULE_ECDH
154164
noinst_PROGRAMS += ecdh_example
155165
ecdh_example_SOURCES = examples/ecdh.c

examples/batch.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#include <stdio.h>
2+
#include <assert.h>
3+
#include <string.h>
4+
5+
#include <secp256k1.h>
6+
7+
int main(void) {
8+
/* batch_context uses secp256k1_context only for the error callback function*/
9+
secp256k1_context *ctx = secp256k1_context_create(SECP256K1_CONTEXT_NONE);
10+
11+
secp256k1_batch_context *batch_ctx = secp256k1_batch_context_create(ctx, 3);
12+
assert(batch_ctx != NULL);
13+
secp256k1_batch_context_destroy(ctx, batch_ctx);
14+
15+
secp256k1_context_destroy(ctx);
16+
17+
printf("Batch example completed...\n");
18+
return 0;
19+
}

0 commit comments

Comments
 (0)