Skip to content

Commit ce18267

Browse files
committed
Merge #229: musig: Fix nits left open in #211
a0b51af musig: VERIFY_CHECK preconditions of _musig_keyaggcoef_internal() (Tim Ruffing) da77028 extrakeys: Clarify comparison order of compare/sort functions (Tim Ruffing) Pull request description: ACKs for top commit: jonasnick: ACK a0b51af Tree-SHA512: ad509d7a55c6f832a25b896b0fe38e259b79864b2a8d1fb337b9d9b4a5e1950a9d579040285465c89d815becc6e49af4129ab2d904d32ac98cef74357a440c89
2 parents 78ed0e0 + a0b51af commit ce18267

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

include/secp256k1_extrakeys.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,8 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_keypair_xonly_tweak_add
242242
const unsigned char *tweak32
243243
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
244244

245-
/** Compare two public keys using lexicographic order
245+
/** Compare two public keys using lexicographic order of their compressed
246+
* serialization.
246247
*
247248
* Returns: <0 if the first public key is less than the second
248249
* >0 if the first public key is greater than the second
@@ -257,7 +258,8 @@ SECP256K1_API int secp256k1_pubkey_cmp(
257258
const secp256k1_pubkey* pk2
258259
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
259260

260-
/** Sorts public keys using lexicographic order
261+
/** Sort public keys using lexicographic order of their compressed
262+
* serialization.
261263
*
262264
* Returns: 0 if the arguments are invalid. 1 otherwise.
263265
*

src/modules/musig/keyagg_impl.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,12 @@ static void secp256k1_musig_keyaggcoef_sha256(secp256k1_sha256 *sha) {
166166
static void secp256k1_musig_keyaggcoef_internal(secp256k1_scalar *r, const unsigned char *pk_hash, secp256k1_ge *pk, const secp256k1_ge *second_pk) {
167167
secp256k1_sha256 sha;
168168

169+
VERIFY_CHECK(!secp256k1_ge_is_infinity(pk));
170+
#ifdef VERIFY
171+
VERIFY_CHECK(pk->x.normalized && pk->y.normalized);
172+
VERIFY_CHECK(secp256k1_ge_is_infinity(second_pk) || (second_pk->x.normalized && second_pk->y.normalized));
173+
#endif
174+
169175
if (!secp256k1_ge_is_infinity(second_pk)
170176
&& secp256k1_fe_equal(&pk->x, &second_pk->x)
171177
&& secp256k1_fe_is_odd(&pk->y) == secp256k1_fe_is_odd(&second_pk->y)) {

0 commit comments

Comments
 (0)