Skip to content

Commit 2cb2e31

Browse files
committed
extrakeys: Migrate to bitcoin-core/secp256k1#1518 secp256k1_ec_pubkey_sort
1 parent 3291b02 commit 2cb2e31

File tree

7 files changed

+2
-387
lines changed

7 files changed

+2
-387
lines changed

include/secp256k1_extrakeys.h

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -240,21 +240,6 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_xonly_tweak_add
240240
const unsigned char *tweak32
241241
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
242242

243-
/** Sort public keys using lexicographic order of their compressed
244-
* serialization.
245-
*
246-
* Returns: 0 if the arguments are invalid. 1 otherwise.
247-
*
248-
* Args: ctx: pointer to a context object
249-
* In: pubkeys: array of pointers to pubkeys to sort
250-
* n_pubkeys: number of elements in the pubkeys array
251-
*/
252-
SECP256K1_API int secp256k1_pubkey_sort(
253-
const secp256k1_context *ctx,
254-
const secp256k1_pubkey **pubkeys,
255-
size_t n_pubkeys
256-
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2);
257-
258243
#ifdef __cplusplus
259244
}
260245
#endif

include/secp256k1_musig.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ SECP256K1_API int secp256k1_musig_partial_sig_parse(
186186
*
187187
* Different orders of `pubkeys` result in different `agg_pk`s.
188188
*
189-
* Before aggregating, the pubkeys can be sorted with `secp256k1_pubkey_sort`
189+
* Before aggregating, the pubkeys can be sorted with `secp256k1_ec_pubkey_sort`
190190
* which ensures the same `agg_pk` result for the same multiset of pubkeys.
191191
* This is useful to do before `pubkey_agg`, such that the order of pubkeys
192192
* does not affect the aggregate public key.
Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
include_HEADERS += include/secp256k1_extrakeys.h
22
noinst_HEADERS += src/modules/extrakeys/tests_impl.h
33
noinst_HEADERS += src/modules/extrakeys/tests_exhaustive_impl.h
4-
noinst_HEADERS += src/modules/extrakeys/main_impl.h
5-
noinst_HEADERS += src/modules/extrakeys/hsort.h
6-
noinst_HEADERS += src/modules/extrakeys/hsort_impl.h
4+
noinst_HEADERS += src/modules/extrakeys/main_impl.h

src/modules/extrakeys/hsort.h

Lines changed: 0 additions & 22 deletions
This file was deleted.

src/modules/extrakeys/hsort_impl.h

Lines changed: 0 additions & 116 deletions
This file was deleted.

src/modules/extrakeys/main_impl.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99

1010
#include "../../../include/secp256k1.h"
1111
#include "../../../include/secp256k1_extrakeys.h"
12-
#include "hsort_impl.h"
1312
#include "../../util.h"
1413

1514
static SECP256K1_INLINE int secp256k1_xonly_pubkey_load(const secp256k1_context* ctx, secp256k1_ge *ge, const secp256k1_xonly_pubkey *pubkey) {
@@ -283,38 +282,4 @@ int secp256k1_keypair_xonly_tweak_add(const secp256k1_context* ctx, secp256k1_ke
283282
return ret;
284283
}
285284

286-
/* This struct wraps a const context pointer to satisfy the secp256k1_hsort api
287-
* which expects a non-const cmp_data pointer. */
288-
typedef struct {
289-
const secp256k1_context *ctx;
290-
} secp256k1_pubkey_sort_cmp_data;
291-
292-
static int secp256k1_pubkey_sort_cmp(const void* pk1, const void* pk2, void *cmp_data) {
293-
return secp256k1_ec_pubkey_cmp(((secp256k1_pubkey_sort_cmp_data*)cmp_data)->ctx,
294-
*(secp256k1_pubkey **)pk1,
295-
*(secp256k1_pubkey **)pk2);
296-
}
297-
298-
int secp256k1_pubkey_sort(const secp256k1_context* ctx, const secp256k1_pubkey **pubkeys, size_t n_pubkeys) {
299-
secp256k1_pubkey_sort_cmp_data cmp_data;
300-
VERIFY_CHECK(ctx != NULL);
301-
ARG_CHECK(pubkeys != NULL);
302-
303-
cmp_data.ctx = ctx;
304-
305-
/* Suppress wrong warning (fixed in MSVC 19.33) */
306-
#if defined(_MSC_VER) && (_MSC_VER < 1933)
307-
#pragma warning(push)
308-
#pragma warning(disable: 4090)
309-
#endif
310-
311-
secp256k1_hsort(pubkeys, n_pubkeys, sizeof(*pubkeys), secp256k1_pubkey_sort_cmp, &cmp_data);
312-
313-
#if defined(_MSC_VER) && (_MSC_VER < 1933)
314-
#pragma warning(pop)
315-
#endif
316-
317-
return 1;
318-
}
319-
320285
#endif

0 commit comments

Comments
 (0)