Skip to content

Commit 5a0b27c

Browse files
committed
Squashed 'src/secp256k1/' changes from 4af241b320..00b0cb19a9
00b0cb19a9 docs: update README 54b8bc8ec6 ci: enable silentpayments module 96bd71fb8a tests: add BIP-352 test vectors c30bc013fe silentpayments: add benchmark for `scan_outputs` 91b1b3365b silentpayments: add examples/silentpayments.c b4475ea80c silentpayments: receiving 23c7aead63 silentpayments: recipient label support 79562d0cd1 silentpayments: sending 35f91359b8 build: add skeleton for new silentpayments (BIP352) module 0055b86780 Merge bitcoin-core/secp256k1#1551: Add ellswift usage example ea2d5f0f17 Merge bitcoin-core/secp256k1#1563: doc: Add convention for defaults ca06e58b2c Merge bitcoin-core/secp256k1#1564: build, ci: Adjust the default size of the precomputed table for signing e2af491263 ci: Switch to the new default value of the precomputed table for signing d94a9273f8 build: Adjust the default size of the precomputed table for signing fcc5d7381b Merge bitcoin-core/secp256k1#1565: cmake: Bump CMake minimum required version up to 3.16 9420eece24 cmake: Bump CMake minimum required version up to 3.16 16685649d2 doc: Add convention for defaults a5269373fa Merge bitcoin-core/secp256k1#1555: Fixed O3 replacement b8fe33332b cmake: Fixed O3 replacement 31f84595c4 Add ellswift usage example fe4fbaa7f3 examples: fix case typos in secret clearing paragraphs (s/, Or/, or/) git-subtree-dir: src/secp256k1 git-subtree-split: 00b0cb19a97718dfaab70aa7505ff157f22a31bd
1 parent 1408944 commit 5a0b27c

30 files changed

+9697
-31
lines changed

.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ env:
2222
RECOVERY: no
2323
SCHNORRSIG: no
2424
ELLSWIFT: no
25+
SILENTPAYMENTS: no
2526
### test options
2627
SECP256K1_TEST_ITERS:
2728
BENCH: yes
@@ -68,6 +69,7 @@ task:
6869
RECOVERY: yes
6970
SCHNORRSIG: yes
7071
ELLSWIFT: yes
72+
SILENTPAYMENTS: yes
7173
matrix:
7274
# Currently only gcc-snapshot, the other compilers are tested on GHA with QEMU
7375
- env: { CC: 'gcc-snapshot' }
@@ -84,6 +86,7 @@ task:
8486
RECOVERY: yes
8587
SCHNORRSIG: yes
8688
ELLSWIFT: yes
89+
SILENTPAYMENTS: yes
8790
WRAPPER_CMD: 'valgrind --error-exitcode=42'
8891
SECP256K1_TEST_ITERS: 2
8992
matrix:

.github/workflows/ci.yml

+23-12
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ env:
2222
BUILD: 'check'
2323
### secp256k1 config
2424
ECMULTWINDOW: 15
25-
ECMULTGENKB: 22
25+
ECMULTGENKB: 86
2626
ASM: 'no'
2727
WIDEMUL: 'auto'
2828
WITH_VALGRIND: 'yes'
@@ -33,6 +33,7 @@ env:
3333
RECOVERY: 'no'
3434
SCHNORRSIG: 'no'
3535
ELLSWIFT: 'no'
36+
SILENTPAYMENTS: 'no'
3637
### test options
3738
SECP256K1_TEST_ITERS:
3839
BENCH: 'yes'
@@ -71,18 +72,18 @@ jobs:
7172
matrix:
7273
configuration:
7374
- env_vars: { WIDEMUL: 'int64', RECOVERY: 'yes' }
74-
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
75+
- env_vars: { WIDEMUL: 'int64', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
7576
- env_vars: { WIDEMUL: 'int128' }
7677
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
7778
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
78-
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes' }
79+
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', SILENTPAYMENTS: 'yes' }
7980
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
8081
- env_vars: { RECOVERY: 'yes', SCHNORRSIG: 'yes' }
81-
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', CPPFLAGS: '-DVERIFY' }
82+
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', SILENTPAYMENTS: 'yes', CPPFLAGS: '-DVERIFY' }
8283
- env_vars: { BUILD: 'distcheck', WITH_VALGRIND: 'no', CTIMETESTS: 'no', BENCH: 'no' }
8384
- env_vars: { CPPFLAGS: '-DDETERMINISTIC' }
8485
- env_vars: { CFLAGS: '-O0', CTIMETESTS: 'no' }
85-
- env_vars: { CFLAGS: '-O1', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
86+
- env_vars: { CFLAGS: '-O1', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
8687
- env_vars: { ECMULTGENKB: 2, ECMULTWINDOW: 2 }
8788
- env_vars: { ECMULTGENKB: 86, ECMULTWINDOW: 4 }
8889
cc:
@@ -141,6 +142,7 @@ jobs:
141142
RECOVERY: 'yes'
142143
SCHNORRSIG: 'yes'
143144
ELLSWIFT: 'yes'
145+
SILENTPAYMENTS: 'yes'
144146
CC: ${{ matrix.cc }}
145147

146148
steps:
@@ -185,6 +187,7 @@ jobs:
185187
RECOVERY: 'yes'
186188
SCHNORRSIG: 'yes'
187189
ELLSWIFT: 'yes'
190+
SILENTPAYMENTS: 'yes'
188191
CTIMETESTS: 'no'
189192

190193
steps:
@@ -236,6 +239,7 @@ jobs:
236239
RECOVERY: 'yes'
237240
SCHNORRSIG: 'yes'
238241
ELLSWIFT: 'yes'
242+
SILENTPAYMENTS: 'yes'
239243
CTIMETESTS: 'no'
240244

241245
steps:
@@ -281,6 +285,7 @@ jobs:
281285
RECOVERY: 'yes'
282286
SCHNORRSIG: 'yes'
283287
ELLSWIFT: 'yes'
288+
SILENTPAYMENTS: 'yes'
284289
CTIMETESTS: 'no'
285290

286291
strategy:
@@ -336,6 +341,7 @@ jobs:
336341
RECOVERY: 'yes'
337342
SCHNORRSIG: 'yes'
338343
ELLSWIFT: 'yes'
344+
SILENTPAYMENTS: 'yes'
339345
CTIMETESTS: 'no'
340346

341347
steps:
@@ -388,6 +394,7 @@ jobs:
388394
RECOVERY: 'yes'
389395
SCHNORRSIG: 'yes'
390396
ELLSWIFT: 'yes'
397+
SILENTPAYMENTS: 'yes'
391398
CTIMETESTS: 'no'
392399
SECP256K1_TEST_ITERS: 2
393400

@@ -439,6 +446,7 @@ jobs:
439446
RECOVERY: 'yes'
440447
SCHNORRSIG: 'yes'
441448
ELLSWIFT: 'yes'
449+
SILENTPAYMENTS: 'yes'
442450
CTIMETESTS: 'no'
443451
CFLAGS: '-fsanitize=undefined,address -g'
444452
UBSAN_OPTIONS: 'print_stacktrace=1:halt_on_error=1'
@@ -503,6 +511,7 @@ jobs:
503511
RECOVERY: 'yes'
504512
SCHNORRSIG: 'yes'
505513
ELLSWIFT: 'yes'
514+
SILENTPAYMENTS: 'yes'
506515
CC: 'clang'
507516
SECP256K1_TEST_ITERS: 32
508517
ASM: 'no'
@@ -549,6 +558,7 @@ jobs:
549558
RECOVERY: 'yes'
550559
SCHNORRSIG: 'yes'
551560
ELLSWIFT: 'yes'
561+
SILENTPAYMENTS: 'yes'
552562
CTIMETESTS: 'no'
553563

554564
strategy:
@@ -605,14 +615,14 @@ jobs:
605615
fail-fast: false
606616
matrix:
607617
env_vars:
608-
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
618+
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
609619
- { WIDEMUL: 'int128_struct', ECMULTGENKB: 2, ECMULTWINDOW: 4 }
610-
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
620+
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
611621
- { WIDEMUL: 'int128', RECOVERY: 'yes' }
612-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
613-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
614-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
615-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
622+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes' }
623+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes', CC: 'gcc' }
624+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
625+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', SILENTPAYMENTS: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
616626
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
617627
- BUILD: 'distcheck'
618628

@@ -780,6 +790,7 @@ jobs:
780790
RECOVERY: 'yes'
781791
SCHNORRSIG: 'yes'
782792
ELLSWIFT: 'yes'
793+
SILENTPAYMENTS: 'yes'
783794

784795
steps:
785796
- name: Checkout
@@ -864,5 +875,5 @@ jobs:
864875
CI_BUILD: ${{ runner.temp }}/${{ github.run_id }}${{ github.action }}/build
865876
CI_INSTALL: ${{ runner.temp }}/${{ github.run_id }}${{ github.action }}/install
866877
run: |
867-
cmake -B ${{ env.CI_BUILD }} -DCMAKE_INSTALL_PREFIX=${{ env.CI_INSTALL }} && cmake --build ${{ env.CI_BUILD }} --target install && ls -RlAh ${{ env.CI_INSTALL }}
878+
cmake -B ${{ env.CI_BUILD }} -DCMAKE_INSTALL_PREFIX=${{ env.CI_INSTALL }} && cmake --build ${{ env.CI_BUILD }} && cmake --install ${{ env.CI_BUILD }} && ls -RlAh ${{ env.CI_INSTALL }}
868879
gcc -o ecdsa examples/ecdsa.c -I ${{ env.CI_INSTALL }}/include -L ${{ env.CI_INSTALL }}/lib*/ -l secp256k1 -Wl,-rpath,"${{ env.CI_INSTALL }}/lib",-rpath,"${{ env.CI_INSTALL }}/lib64" && ./ecdsa

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ ctime_tests
1010
ecdh_example
1111
ecdsa_example
1212
schnorr_example
13+
ellswift_example
14+
silentpayments_example
1315
*.exe
1416
*.so
1517
*.a

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
#### Added
11+
- Added usage example for an ElligatorSwift key exchange.
12+
1013
## [0.5.0] - 2024-05-06
1114

1215
#### Added

CMakeLists.txt

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
1-
cmake_minimum_required(VERSION 3.13)
2-
3-
if(CMAKE_VERSION VERSION_GREATER_EQUAL 3.15)
4-
# MSVC runtime library flags are selected by the CMAKE_MSVC_RUNTIME_LIBRARY abstraction.
5-
cmake_policy(SET CMP0091 NEW)
6-
# MSVC warning flags are not in CMAKE_<LANG>_FLAGS by default.
7-
cmake_policy(SET CMP0092 NEW)
8-
endif()
1+
cmake_minimum_required(VERSION 3.16)
92

103
project(libsecp256k1
114
# The package (a.k.a. release) version is based on semantic versioning 2.0.0 of
@@ -59,9 +52,14 @@ option(SECP256K1_ENABLE_MODULE_RECOVERY "Enable ECDSA pubkey recovery module." O
5952
option(SECP256K1_ENABLE_MODULE_EXTRAKEYS "Enable extrakeys module." ON)
6053
option(SECP256K1_ENABLE_MODULE_SCHNORRSIG "Enable schnorrsig module." ON)
6154
option(SECP256K1_ENABLE_MODULE_ELLSWIFT "Enable ElligatorSwift module." ON)
55+
option(SECP256K1_ENABLE_MODULE_SILENTPAYMENTS "Enable Silent Payments module." OFF)
6256

6357
# Processing must be done in a topological sorting of the dependency graph
6458
# (dependent module first).
59+
if(SECP256K1_ENABLE_MODULE_SILENTPAYMENTS)
60+
add_compile_definitions(ENABLE_MODULE_SILENTPAYMENTS=1)
61+
endif()
62+
6563
if(SECP256K1_ENABLE_MODULE_ELLSWIFT)
6664
add_compile_definitions(ENABLE_MODULE_ELLSWIFT=1)
6765
endif()
@@ -97,7 +95,7 @@ include(CheckStringOptionValue)
9795
check_string_option_value(SECP256K1_ECMULT_WINDOW_SIZE)
9896
add_compile_definitions(ECMULT_WINDOW_SIZE=${SECP256K1_ECMULT_WINDOW_SIZE})
9997

100-
set(SECP256K1_ECMULT_GEN_KB 22 CACHE STRING "The size of the precomputed table for signing in multiples of 1024 bytes (on typical platforms). Larger values result in possibly better signing or key generation performance at the cost of a larger table. Valid choices are 2, 22, 86. The default value is a reasonable setting for desktop machines (currently 22). [default=22]")
98+
set(SECP256K1_ECMULT_GEN_KB 86 CACHE STRING "The size of the precomputed table for signing in multiples of 1024 bytes (on typical platforms). Larger values result in possibly better signing or key generation performance at the cost of a larger table. Valid choices are 2, 22, 86. The default value is a reasonable setting for desktop machines (currently 86). [default=86]")
10199
set_property(CACHE SECP256K1_ECMULT_GEN_KB PROPERTY STRINGS 2 22 86)
102100
check_string_option_value(SECP256K1_ECMULT_GEN_KB)
103101
if(SECP256K1_ECMULT_GEN_KB EQUAL 2)
@@ -185,7 +183,7 @@ else()
185183
string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
186184
string(REGEX REPLACE "-DNDEBUG[ \t\r\n]*" "" CMAKE_C_FLAGS_MINSIZEREL "${CMAKE_C_FLAGS_MINSIZEREL}")
187185
# Prefer -O2 optimization level. (-O3 is CMake's default for Release for many compilers.)
188-
string(REGEX REPLACE "-O3[ \t\r\n]*" "-O2" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
186+
string(REGEX REPLACE "-O3( |$)" "-O2\\1" CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
189187
endif()
190188

191189
# Define custom "Coverage" build type.
@@ -305,6 +303,7 @@ message(" ECDSA pubkey recovery ............... ${SECP256K1_ENABLE_MODULE_RECOV
305303
message(" extrakeys ........................... ${SECP256K1_ENABLE_MODULE_EXTRAKEYS}")
306304
message(" schnorrsig .......................... ${SECP256K1_ENABLE_MODULE_SCHNORRSIG}")
307305
message(" ElligatorSwift ...................... ${SECP256K1_ENABLE_MODULE_ELLSWIFT}")
306+
message(" Silent Payments ..................... ${SECP256K1_ENABLE_MODULE_SILENTPAYMENTS}")
308307
message("Parameters:")
309308
message(" ecmult window size .................. ${SECP256K1_ECMULT_WINDOW_SIZE}")
310309
message(" ecmult gen table size ............... ${SECP256K1_ECMULT_GEN_KB} KiB")

CONTRIBUTING.md

+1
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ In addition, libsecp256k1 tries to maintain the following coding conventions:
4949
* Operations involving secret data should be tested for being constant time with respect to the secrets (see [src/ctime_tests.c](src/ctime_tests.c)).
5050
* Local variables containing secret data should be cleared explicitly to try to delete secrets from memory.
5151
* Use `secp256k1_memcmp_var` instead of `memcmp` (see [#823](https://github.com/bitcoin-core/secp256k1/issues/823)).
52+
* As a rule of thumb, the default values for configuration options should target standard desktop machines and align with Bitcoin Core's defaults, and the tests should mostly exercise the default configuration (see [#1549](https://github.com/bitcoin-core/secp256k1/issues/1549#issuecomment-2200559257)).
5253

5354
#### Style conventions
5455

Makefile.am

+31
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,28 @@ schnorr_example_LDFLAGS += -lbcrypt
184184
endif
185185
TESTS += schnorr_example
186186
endif
187+
if ENABLE_MODULE_ELLSWIFT
188+
noinst_PROGRAMS += ellswift_example
189+
ellswift_example_SOURCES = examples/ellswift.c
190+
ellswift_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
191+
ellswift_example_LDADD = libsecp256k1.la
192+
ellswift_example_LDFLAGS = -static
193+
if BUILD_WINDOWS
194+
ellswift_example_LDFLAGS += -lbcrypt
195+
endif
196+
TESTS += ellswift_example
197+
endif
198+
if ENABLE_MODULE_SILENTPAYMENTS
199+
noinst_PROGRAMS += silentpayments_example
200+
silentpayments_example_SOURCES = examples/silentpayments.c
201+
silentpayments_example_CPPFLAGS = -I$(top_srcdir)/include -DSECP256K1_STATIC
202+
silentpayments_example_LDADD = libsecp256k1.la
203+
silentpayments_example_LDFLAGS = -static
204+
if BUILD_WINDOWS
205+
silentpayments_example_LDFLAGS += -lbcrypt
206+
endif
207+
TESTS += silentpayments_example
208+
endif
187209
endif
188210

189211
### Precomputed tables
@@ -226,11 +248,16 @@ maintainer-clean-local: clean-precomp
226248
### Pregenerated test vectors
227249
### (see the comments in the previous section for detailed rationale)
228250
TESTVECTORS = src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h
251+
TESTVECTORS += src/modules/silentpayments/vectors.h
229252

230253
src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.h:
231254
mkdir -p $(@D)
232255
python3 $(top_srcdir)/tools/tests_wycheproof_generate.py $(top_srcdir)/src/wycheproof/ecdsa_secp256k1_sha256_bitcoin_test.json > $@
233256

257+
src/modules/silentpayments/vectors.h:
258+
mkdir -p $(@D)
259+
python3 $(top_srcdir)/tools/tests_silentpayments_generate.py $(top_srcdir)/src/modules/silentpayments/bip352_send_and_receive_test_vectors.json > $@
260+
234261
testvectors: $(TESTVECTORS)
235262

236263
BUILT_SOURCES += $(TESTVECTORS)
@@ -273,3 +300,7 @@ endif
273300
if ENABLE_MODULE_ELLSWIFT
274301
include src/modules/ellswift/Makefile.am.include
275302
endif
303+
304+
if ENABLE_MODULE_SILENTPAYMENTS
305+
include src/modules/silentpayments/Makefile.am.include
306+
endif

README.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Features:
2121
* Optional module for ECDH key exchange.
2222
* Optional module for Schnorr signatures according to [BIP-340](https://github.com/bitcoin/bips/blob/master/bip-0340.mediawiki).
2323
* Optional module for ElligatorSwift key exchange according to [BIP-324](https://github.com/bitcoin/bips/blob/master/bip-0324.mediawiki).
24+
* Optional module for Silent Payments send and receive according to [BIP-352](https://github.com/bitcoin/bips/blob/master/bip-0352.mediawiki).
2425

2526
Implementation details
2627
----------------------
@@ -82,7 +83,7 @@ To maintain a pristine source tree, CMake encourages to perform an out-of-source
8283
$ cmake ..
8384
$ cmake --build .
8485
$ ctest # run the test suite
85-
$ sudo cmake --build . --target install # optional
86+
$ sudo cmake --install . # optional
8687

8788
To compile optional modules (such as Schnorr signatures), you need to run `cmake` with additional flags (such as `-DSECP256K1_ENABLE_MODULE_SCHNORRSIG=ON`). Run `cmake .. -LH` to see the full list of available flags.
8889

@@ -114,6 +115,8 @@ Usage examples can be found in the [examples](examples) directory. To compile th
114115
* [ECDSA example](examples/ecdsa.c)
115116
* [Schnorr signatures example](examples/schnorr.c)
116117
* [Deriving a shared secret (ECDH) example](examples/ecdh.c)
118+
* [ElligatorSwift key exchange example](examples/ellswift.c)
119+
* [Silent Payments send and receive example](examples/silentpayments.c)
117120

118121
To compile the Schnorr signature and ECDH examples, you also need to configure with `--enable-module-schnorrsig` and `--enable-module-ecdh`.
119122

ci/ci.sh

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ print_environment() {
1313
# does not rely on bash.
1414
for var in WERROR_CFLAGS MAKEFLAGS BUILD \
1515
ECMULTWINDOW ECMULTGENKB ASM WIDEMUL WITH_VALGRIND EXTRAFLAGS \
16-
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG ELLSWIFT \
16+
EXPERIMENTAL ECDH RECOVERY SCHNORRSIG ELLSWIFT SILENTPAYMENTS \
1717
SECP256K1_TEST_ITERS BENCH SECP256K1_BENCH_ITERS CTIMETESTS\
1818
EXAMPLES \
1919
HOST WRAPPER_CMD \
@@ -77,6 +77,7 @@ esac
7777
--with-ecmult-gen-kb="$ECMULTGENKB" \
7878
--enable-module-ecdh="$ECDH" --enable-module-recovery="$RECOVERY" \
7979
--enable-module-ellswift="$ELLSWIFT" \
80+
--enable-module-silentpayments="$SILENTPAYMENTS" \
8081
--enable-module-schnorrsig="$SCHNORRSIG" \
8182
--enable-examples="$EXAMPLES" \
8283
--enable-ctime-tests="$CTIMETESTS" \

configure.ac

+12-2
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,10 @@ AC_ARG_ENABLE(module_ellswift,
188188
AS_HELP_STRING([--enable-module-ellswift],[enable ElligatorSwift module [default=yes]]), [],
189189
[SECP_SET_DEFAULT([enable_module_ellswift], [yes], [yes])])
190190

191+
AC_ARG_ENABLE(module_silentpayments,
192+
AS_HELP_STRING([--enable-module-silentpayments],[enable Silent Payments module [default=no]]), [],
193+
[SECP_SET_DEFAULT([enable_module_silentpayments], [no], [yes])])
194+
191195
AC_ARG_ENABLE(external_default_callbacks,
192196
AS_HELP_STRING([--enable-external-default-callbacks],[enable external default callback functions [default=no]]), [],
193197
[SECP_SET_DEFAULT([enable_external_default_callbacks], [no], [no])])
@@ -216,9 +220,9 @@ AC_ARG_WITH([ecmult-window], [AS_HELP_STRING([--with-ecmult-window=SIZE],
216220
AC_ARG_WITH([ecmult-gen-kb], [AS_HELP_STRING([--with-ecmult-gen-kb=2|22|86],
217221
[The size of the precomputed table for signing in multiples of 1024 bytes (on typical platforms).]
218222
[Larger values result in possibly better signing/keygeneration performance at the cost of a larger table.]
219-
[The default value is a reasonable setting for desktop machines (currently 22). [default=22]]
223+
[The default value is a reasonable setting for desktop machines (currently 86). [default=86]]
220224
)],
221-
[set_ecmult_gen_kb=$withval], [set_ecmult_gen_kb=22])
225+
[set_ecmult_gen_kb=$withval], [set_ecmult_gen_kb=86])
222226

223227
AC_ARG_WITH([valgrind], [AS_HELP_STRING([--with-valgrind=yes|no|auto],
224228
[Build with extra checks for running inside Valgrind [default=auto]]
@@ -394,6 +398,10 @@ SECP_CFLAGS="$SECP_CFLAGS $WERROR_CFLAGS"
394398

395399
# Processing must be done in a reverse topological sorting of the dependency graph
396400
# (dependent module first).
401+
if test x"$enable_module_silentpayments" = x"yes"; then
402+
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_SILENTPAYMENTS=1"
403+
fi
404+
397405
if test x"$enable_module_ellswift" = x"yes"; then
398406
SECP_CONFIG_DEFINES="$SECP_CONFIG_DEFINES -DENABLE_MODULE_ELLSWIFT=1"
399407
fi
@@ -450,6 +458,7 @@ AM_CONDITIONAL([ENABLE_MODULE_RECOVERY], [test x"$enable_module_recovery" = x"ye
450458
AM_CONDITIONAL([ENABLE_MODULE_EXTRAKEYS], [test x"$enable_module_extrakeys" = x"yes"])
451459
AM_CONDITIONAL([ENABLE_MODULE_SCHNORRSIG], [test x"$enable_module_schnorrsig" = x"yes"])
452460
AM_CONDITIONAL([ENABLE_MODULE_ELLSWIFT], [test x"$enable_module_ellswift" = x"yes"])
461+
AM_CONDITIONAL([ENABLE_MODULE_SILENTPAYMENTS], [test x"$enable_module_silentpayments" = x"yes"])
453462
AM_CONDITIONAL([USE_EXTERNAL_ASM], [test x"$enable_external_asm" = x"yes"])
454463
AM_CONDITIONAL([USE_ASM_ARM], [test x"$set_asm" = x"arm32"])
455464
AM_CONDITIONAL([BUILD_WINDOWS], [test "$build_windows" = "yes"])
@@ -472,6 +481,7 @@ echo " module recovery = $enable_module_recovery"
472481
echo " module extrakeys = $enable_module_extrakeys"
473482
echo " module schnorrsig = $enable_module_schnorrsig"
474483
echo " module ellswift = $enable_module_ellswift"
484+
echo " module silentpayments = $enable_module_silentpayments"
475485
echo
476486
echo " asm = $set_asm"
477487
echo " ecmult window size = $set_ecmult_window"

0 commit comments

Comments
 (0)