Skip to content

Commit dfd9849

Browse files
committed
fixup! rename pubkey_sort -> ec_pubkey_sort
for consistency with other "ec_pubkey" functions
1 parent d3a8952 commit dfd9849

File tree

4 files changed

+17
-17
lines changed

4 files changed

+17
-17
lines changed

include/secp256k1.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_cmp(
482482
* In: pubkeys: array of pointers to pubkeys to sort
483483
* n_pubkeys: number of elements in the pubkeys array
484484
*/
485-
SECP256K1_API int secp256k1_pubkey_sort(
485+
SECP256K1_API int secp256k1_ec_pubkey_sort(
486486
const secp256k1_context *ctx,
487487
const secp256k1_pubkey **pubkeys,
488488
size_t n_pubkeys

include/secp256k1_musig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ SECP256K1_API int secp256k1_musig_partial_sig_parse(
184184
*
185185
* Different orders of `pubkeys` result in different `agg_pk`s.
186186
*
187-
* Before aggregating, the pubkeys can be sorted with `secp256k1_pubkey_sort`
187+
* Before aggregating, the pubkeys can be sorted with `secp256k1_ec_pubkey_sort`
188188
* which ensures the same `agg_pk` result for the same multiset of pubkeys.
189189
* This is useful to do before `pubkey_agg`, such that the order of pubkeys
190190
* does not affect the aggregate public key.

src/secp256k1.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,16 +318,16 @@ int secp256k1_ec_pubkey_cmp(const secp256k1_context* ctx, const secp256k1_pubkey
318318
* which expects a non-const cmp_data pointer. */
319319
typedef struct {
320320
const secp256k1_context *ctx;
321-
} secp256k1_pubkey_sort_cmp_data;
321+
} secp256k1_ec_pubkey_sort_cmp_data;
322322

323-
static int secp256k1_pubkey_sort_cmp(const void* pk1, const void* pk2, void *cmp_data) {
324-
return secp256k1_ec_pubkey_cmp(((secp256k1_pubkey_sort_cmp_data*)cmp_data)->ctx,
323+
static int secp256k1_ec_pubkey_sort_cmp(const void* pk1, const void* pk2, void *cmp_data) {
324+
return secp256k1_ec_pubkey_cmp(((secp256k1_ec_pubkey_sort_cmp_data*)cmp_data)->ctx,
325325
*(secp256k1_pubkey **)pk1,
326326
*(secp256k1_pubkey **)pk2);
327327
}
328328

329-
int secp256k1_pubkey_sort(const secp256k1_context* ctx, const secp256k1_pubkey **pubkeys, size_t n_pubkeys) {
330-
secp256k1_pubkey_sort_cmp_data cmp_data;
329+
int secp256k1_ec_pubkey_sort(const secp256k1_context* ctx, const secp256k1_pubkey **pubkeys, size_t n_pubkeys) {
330+
secp256k1_ec_pubkey_sort_cmp_data cmp_data;
331331
VERIFY_CHECK(ctx != NULL);
332332
ARG_CHECK(pubkeys != NULL);
333333

@@ -339,7 +339,7 @@ int secp256k1_pubkey_sort(const secp256k1_context* ctx, const secp256k1_pubkey *
339339
#pragma warning(disable: 4090)
340340
#endif
341341

342-
secp256k1_hsort(pubkeys, n_pubkeys, sizeof(*pubkeys), secp256k1_pubkey_sort_cmp, &cmp_data);
342+
secp256k1_hsort(pubkeys, n_pubkeys, sizeof(*pubkeys), secp256k1_ec_pubkey_sort_cmp, &cmp_data);
343343

344344
#if defined(_MSC_VER) && (_MSC_VER < 1933)
345345
#pragma warning(pop)

src/tests.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6661,7 +6661,7 @@ static void test_sort_helper(secp256k1_pubkey *pk, size_t *pk_order, size_t n_pk
66616661
for (i = 0; i < n_pk; i++) {
66626662
pk_test[i] = &pk[pk_order[i]];
66636663
}
6664-
secp256k1_pubkey_sort(CTX, pk_test, n_pk);
6664+
secp256k1_ec_pubkey_sort(CTX, pk_test, n_pk);
66656665
for (i = 0; i < n_pk; i++) {
66666666
CHECK(secp256k1_memcmp_var(pk_test[i], &pk[i], sizeof(*pk_test[i])) == 0);
66676667
}
@@ -6696,17 +6696,17 @@ static void test_sort_api(void) {
66966696
rand_pk(&pks[0]);
66976697
rand_pk(&pks[1]);
66986698

6699-
CHECK(secp256k1_pubkey_sort(CTX, pks_ptr, 2) == 1);
6700-
CHECK_ILLEGAL(CTX, secp256k1_pubkey_sort(CTX, NULL, 2));
6701-
CHECK(secp256k1_pubkey_sort(CTX, pks_ptr, 0) == 1);
6699+
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2) == 1);
6700+
CHECK_ILLEGAL(CTX, secp256k1_ec_pubkey_sort(CTX, NULL, 2));
6701+
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 0) == 1);
67026702
/* Test illegal public keys */
67036703
memset(&pks[0], 0, sizeof(pks[0]));
6704-
CHECK_ILLEGAL_VOID(CTX, CHECK(secp256k1_pubkey_sort(CTX, pks_ptr, 2) == 1));
6704+
CHECK_ILLEGAL_VOID(CTX, CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2) == 1));
67056705
memset(&pks[1], 0, sizeof(pks[1]));
67066706
{
67076707
int32_t ecount = 0;
67086708
secp256k1_context_set_illegal_callback(CTX, counting_callback_fn, &ecount);
6709-
CHECK(secp256k1_pubkey_sort(CTX, pks_ptr, 2) == 1);
6709+
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, 2) == 1);
67106710
CHECK(ecount == 2);
67116711
secp256k1_context_set_illegal_callback(CTX, NULL, NULL);
67126712
}
@@ -6750,9 +6750,9 @@ static void test_sort(void) {
67506750
rand_pk(&pk[j]);
67516751
pk_ptr[j] = &pk[j];
67526752
}
6753-
secp256k1_pubkey_sort(CTX, pk_ptr, 5);
6753+
secp256k1_ec_pubkey_sort(CTX, pk_ptr, 5);
67546754
for (j = 1; j < 5; j++) {
6755-
CHECK(secp256k1_pubkey_sort_cmp(&pk_ptr[j - 1], &pk_ptr[j], CTX) <= 0);
6755+
CHECK(secp256k1_ec_pubkey_sort_cmp(&pk_ptr[j - 1], &pk_ptr[j], CTX) <= 0);
67566756
}
67576757
}
67586758
}
@@ -6796,7 +6796,7 @@ static void test_sort_vectors(void) {
67966796
CHECK(secp256k1_ec_pubkey_parse(CTX, &pubkeys[i], pk_ser[i], sizeof(pk_ser[i])));
67976797
pks_ptr[i] = &pubkeys[i];
67986798
}
6799-
CHECK(secp256k1_pubkey_sort(CTX, pks_ptr, N_PUBKEYS) == 1);
6799+
CHECK(secp256k1_ec_pubkey_sort(CTX, pks_ptr, N_PUBKEYS) == 1);
68006800
for (i = 0; i < N_PUBKEYS; i++) {
68016801
CHECK(secp256k1_memcmp_var(pks_ptr[i], sorted[i], sizeof(secp256k1_pubkey)) == 0);
68026802
}

0 commit comments

Comments
 (0)