Skip to content

Commit af551ab

Browse files
committed
tests: do not use functions from extrakeys module
This fixes a bug introduced in 7d2591c that prevented compiling the library without enabling the extrakeys module.
1 parent 0055b86 commit af551ab

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

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

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)