Skip to content

Commit fded437

Browse files
committed
Merge #1574: Fix compilation when extrakeys module isn't enabled
763d938 ci: only enable extrakeys module when schnorrsig is enabled (Jonas Nick) af551ab tests: do not use functions from extrakeys module (Jonas Nick) Pull request description: ACKs for top commit: sipa: ACK 763d938 hebasto: ACK 763d938. Tree-SHA512: a5d52e69af896e7bb43c6826f269b5f26e8d1b8c0d040d71a369fdaebf894e47dcf9ff1bbe1b62864adb85437d2c93eabd655c4d690d5d894b712145c2bd252f
2 parents 0055b86 + 763d938 commit fded437

File tree

6 files changed

+48
-32
lines changed

6 files changed

+48
-32
lines changed

.cirrus.yml

+3
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ env:
2020
EXPERIMENTAL: no
2121
ECDH: no
2222
RECOVERY: no
23+
EXTRAKEYS: no
2324
SCHNORRSIG: no
2425
ELLSWIFT: no
2526
### test options
@@ -66,6 +67,7 @@ task:
6667
env:
6768
ECDH: yes
6869
RECOVERY: yes
70+
EXTRAKEYS: yes
6971
SCHNORRSIG: yes
7072
ELLSWIFT: yes
7173
matrix:
@@ -82,6 +84,7 @@ task:
8284
env:
8385
ECDH: yes
8486
RECOVERY: yes
87+
EXTRAKEYS: yes
8588
SCHNORRSIG: yes
8689
ELLSWIFT: yes
8790
WRAPPER_CMD: 'valgrind --error-exitcode=42'

.github/workflows/ci.yml

+31-20
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ env:
3131
EXPERIMENTAL: 'no'
3232
ECDH: 'no'
3333
RECOVERY: 'no'
34+
EXTRAKEYS: 'no'
3435
SCHNORRSIG: 'no'
3536
ELLSWIFT: 'no'
3637
### test options
@@ -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', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
7576
- env_vars: { WIDEMUL: 'int128' }
76-
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
77-
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
78-
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes' }
79-
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
80-
- env_vars: { RECOVERY: 'yes', SCHNORRSIG: 'yes' }
81-
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', CPPFLAGS: '-DVERIFY' }
77+
- env_vars: { WIDEMUL: 'int128_struct', ELLSWIFT: 'yes' }
78+
- env_vars: { WIDEMUL: 'int128', RECOVERY: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
79+
- env_vars: { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes' }
80+
- env_vars: { WIDEMUL: 'int128', ASM: 'x86_64', ELLSWIFT: 'yes' }
81+
- env_vars: { RECOVERY: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes' }
82+
- env_vars: { CTIMETESTS: 'no', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: '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', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
8687
- env_vars: { ECMULTGENKB: 2, ECMULTWINDOW: 2 }
8788
- env_vars: { ECMULTGENKB: 86, ECMULTWINDOW: 4 }
8889
cc:
@@ -139,6 +140,7 @@ jobs:
139140
HOST: 'i686-linux-gnu'
140141
ECDH: 'yes'
141142
RECOVERY: 'yes'
143+
EXTRAKEYS: 'yes'
142144
SCHNORRSIG: 'yes'
143145
ELLSWIFT: 'yes'
144146
CC: ${{ matrix.cc }}
@@ -183,6 +185,7 @@ jobs:
183185
WITH_VALGRIND: 'no'
184186
ECDH: 'yes'
185187
RECOVERY: 'yes'
188+
EXTRAKEYS: 'yes'
186189
SCHNORRSIG: 'yes'
187190
ELLSWIFT: 'yes'
188191
CTIMETESTS: 'no'
@@ -234,6 +237,7 @@ jobs:
234237
WITH_VALGRIND: 'no'
235238
ECDH: 'yes'
236239
RECOVERY: 'yes'
240+
EXTRAKEYS: 'yes'
237241
SCHNORRSIG: 'yes'
238242
ELLSWIFT: 'yes'
239243
CTIMETESTS: 'no'
@@ -279,6 +283,7 @@ jobs:
279283
WITH_VALGRIND: 'no'
280284
ECDH: 'yes'
281285
RECOVERY: 'yes'
286+
EXTRAKEYS: 'yes'
282287
SCHNORRSIG: 'yes'
283288
ELLSWIFT: 'yes'
284289
CTIMETESTS: 'no'
@@ -334,6 +339,7 @@ jobs:
334339
WITH_VALGRIND: 'no'
335340
ECDH: 'yes'
336341
RECOVERY: 'yes'
342+
EXTRAKEYS: 'yes'
337343
SCHNORRSIG: 'yes'
338344
ELLSWIFT: 'yes'
339345
CTIMETESTS: 'no'
@@ -386,6 +392,7 @@ jobs:
386392
WRAPPER_CMD: 'valgrind --error-exitcode=42'
387393
ECDH: 'yes'
388394
RECOVERY: 'yes'
395+
EXTRAKEYS: 'yes'
389396
SCHNORRSIG: 'yes'
390397
ELLSWIFT: 'yes'
391398
CTIMETESTS: 'no'
@@ -437,6 +444,7 @@ jobs:
437444
env:
438445
ECDH: 'yes'
439446
RECOVERY: 'yes'
447+
EXTRAKEYS: 'yes'
440448
SCHNORRSIG: 'yes'
441449
ELLSWIFT: 'yes'
442450
CTIMETESTS: 'no'
@@ -501,6 +509,7 @@ jobs:
501509
env:
502510
ECDH: 'yes'
503511
RECOVERY: 'yes'
512+
EXTRAKEYS: 'yes'
504513
SCHNORRSIG: 'yes'
505514
ELLSWIFT: 'yes'
506515
CC: 'clang'
@@ -547,6 +556,7 @@ jobs:
547556
WITH_VALGRIND: 'no'
548557
ECDH: 'yes'
549558
RECOVERY: 'yes'
559+
EXTRAKEYS: 'yes'
550560
SCHNORRSIG: 'yes'
551561
ELLSWIFT: 'yes'
552562
CTIMETESTS: 'no'
@@ -605,15 +615,15 @@ 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', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
609619
- { WIDEMUL: 'int128_struct', ECMULTGENKB: 2, ECMULTWINDOW: 4 }
610-
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
620+
- { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: '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 }
616-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
622+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
623+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
624+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
625+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc', WRAPPER_CMD: 'valgrind --error-exitcode=42', SECP256K1_TEST_ITERS: 2 }
626+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY', CTIMETESTS: 'no' }
617627
- BUILD: 'distcheck'
618628

619629
steps:
@@ -666,13 +676,13 @@ jobs:
666676
fail-fast: false
667677
matrix:
668678
env_vars:
669-
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
679+
- { WIDEMUL: 'int64', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
670680
- { WIDEMUL: 'int128_struct', ECMULTGENPRECISION: 2, ECMULTWINDOW: 4 }
671-
- { WIDEMUL: 'int128', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
681+
- { WIDEMUL: 'int128', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
672682
- { WIDEMUL: 'int128', RECOVERY: 'yes' }
673-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
674-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
675-
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY' }
683+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes' }
684+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CC: 'gcc' }
685+
- { WIDEMUL: 'int128', RECOVERY: 'yes', ECDH: 'yes', EXTRAKEYS: 'yes', SCHNORRSIG: 'yes', ELLSWIFT: 'yes', CPPFLAGS: '-DVERIFY' }
676686
- BUILD: 'distcheck'
677687

678688
steps:
@@ -778,6 +788,7 @@ jobs:
778788
WERROR_CFLAGS:
779789
ECDH: 'yes'
780790
RECOVERY: 'yes'
791+
EXTRAKEYS: 'yes'
781792
SCHNORRSIG: 'yes'
782793
ELLSWIFT: 'yes'
783794

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1010
#### Added
1111
- Added usage example for an ElligatorSwift key exchange.
1212

13+
#### Fixed
14+
- Fixed compilation when the extrakeys module is disabled.
15+
1316
## [0.5.0] - 2024-05-06
1417

1518
#### Added

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 EXTRAKEYS SCHNORRSIG ELLSWIFT \
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-extrakeys="$EXTRAKEYS" \
8081
--enable-module-schnorrsig="$SCHNORRSIG" \
8182
--enable-examples="$EXAMPLES" \
8283
--enable-ctime-tests="$CTIMETESTS" \

src/tests.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -6609,23 +6609,15 @@ static void permute(size_t *arr, size_t n) {
66096609
}
66106610
}
66116611

6612-
static void rand_pk(secp256k1_pubkey *pk) {
6613-
unsigned char seckey[32];
6614-
secp256k1_keypair keypair;
6615-
testrand256(seckey);
6616-
CHECK(secp256k1_keypair_create(CTX, &keypair, seckey) == 1);
6617-
CHECK(secp256k1_keypair_pub(CTX, pk, &keypair) == 1);
6618-
}
6619-
66206612
static void test_sort_api(void) {
66216613
secp256k1_pubkey pks[2];
66226614
const secp256k1_pubkey *pks_ptr[2];
66236615

66246616
pks_ptr[0] = &pks[0];
66256617
pks_ptr[1] = &pks[1];
66266618

6627-
rand_pk(&pks[0]);
6628-
rand_pk(&pks[1]);
6619+
testutil_random_pubkey_test(&pks[0]);
6620+
testutil_random_pubkey_test(&pks[1]);
66296621

66306622
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2) == 1);
66316623
CHECK_ILLEGAL(CTX, secp256k1_ec_pubkey_sort(CTX, NULL, 2));
@@ -6678,7 +6670,7 @@ static void test_sort(void) {
66786670
int j;
66796671
const secp256k1_pubkey *pk_ptr[5];
66806672
for (j = 0; j < 5; j++) {
6681-
rand_pk(&pk[j]);
6673+
testutil_random_pubkey_test(&pk[j]);
66826674
pk_ptr[j] = &pk[j];
66836675
}
66846676
secp256k1_ec_pubkey_sort(CTX, pk_ptr, 5);

src/testutil.h

+6
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@ static void testutil_random_gej_test(secp256k1_gej *gej) {
107107
testutil_random_ge_jacobian_test(gej, &ge);
108108
}
109109

110+
static void testutil_random_pubkey_test(secp256k1_pubkey *pk) {
111+
secp256k1_ge ge;
112+
testutil_random_ge_test(&ge);
113+
secp256k1_pubkey_save(pk, &ge);
114+
}
115+
110116
static void testutil_random_scalar_order_test(secp256k1_scalar *num) {
111117
do {
112118
unsigned char b32[32];

0 commit comments

Comments
 (0)