@@ -174,8 +174,12 @@ int secp256k1_musig_pubnonce_serialize(const secp256k1_context* ctx, unsigned ch
174
174
int ret ;
175
175
size_t size = 33 ;
176
176
ret = secp256k1_eckey_pubkey_serialize (& ge [i ], & out66 [33 * i ], & size , 1 );
177
+ #ifdef VERIFY
177
178
/* serialize must succeed because the point was just loaded */
178
179
VERIFY_CHECK (ret && size == 33 );
180
+ #else
181
+ (void ) ret ;
182
+ #endif
179
183
}
180
184
return 1 ;
181
185
}
@@ -258,16 +262,6 @@ int secp256k1_musig_partial_sig_parse(const secp256k1_context* ctx, secp256k1_mu
258
262
return 1 ;
259
263
}
260
264
261
- /* Normalizes the x-coordinate of the given group element. */
262
- static int secp256k1_xonly_ge_serialize (unsigned char * output32 , secp256k1_ge * ge ) {
263
- if (secp256k1_ge_is_infinity (ge )) {
264
- return 0 ;
265
- }
266
- secp256k1_fe_normalize_var (& ge -> x );
267
- secp256k1_fe_get_b32 (output32 , & ge -> x );
268
- return 1 ;
269
- }
270
-
271
265
/* Write optional inputs into the hash */
272
266
static void secp256k1_nonce_function_musig_helper (secp256k1_sha256 * sha , unsigned int prefix_size , const unsigned char * data , unsigned char len ) {
273
267
unsigned char zero [7 ] = { 0 };
@@ -364,22 +358,25 @@ int secp256k1_musig_nonce_gen(const secp256k1_context* ctx, secp256k1_musig_secn
364
358
}
365
359
366
360
if (keyagg_cache != NULL ) {
367
- int ret_tmp ;
368
361
if (!secp256k1_keyagg_cache_load (ctx , & cache_i , keyagg_cache )) {
369
362
return 0 ;
370
363
}
371
- ret_tmp = secp256k1_xonly_ge_serialize (aggpk_ser , & cache_i .pk );
372
- /* Serialization can not fail because the loaded point can not be infinity. */
373
- VERIFY_CHECK (ret_tmp );
364
+ /* The loaded point cache_i.pk can not be the point at infinity. */
365
+ secp256k1_fe_get_b32 (aggpk_ser , & cache_i .pk .x );
374
366
aggpk_ser_ptr = aggpk_ser ;
375
367
}
376
368
if (!secp256k1_pubkey_load (ctx , & pk , pubkey )) {
377
369
return 0 ;
378
370
}
379
371
pk_serialize_success = secp256k1_eckey_pubkey_serialize (& pk , pk_ser , & pk_ser_len , SECP256K1_EC_COMPRESSED );
372
+
373
+ #ifdef VERIFY
380
374
/* A pubkey cannot be the point at infinity */
381
375
VERIFY_CHECK (pk_serialize_success );
382
376
VERIFY_CHECK (pk_ser_len == sizeof (pk_ser ));
377
+ #else
378
+ (void ) pk_serialize_success ;
379
+ #endif
383
380
384
381
secp256k1_nonce_function_musig (k , session_id32 , msg32 , seckey , pk_ser , aggpk_ser_ptr , extra_input32 );
385
382
VERIFY_CHECK (!secp256k1_scalar_is_zero (& k [0 ]));
@@ -460,7 +457,6 @@ static int secp256k1_musig_nonce_process_internal(int *fin_nonce_parity, unsigne
460
457
secp256k1_ge fin_nonce_pt ;
461
458
secp256k1_gej fin_nonce_ptj ;
462
459
secp256k1_ge aggnonce [2 ];
463
- int ret ;
464
460
465
461
secp256k1_ge_set_gej (& aggnonce [0 ], & aggnoncej [0 ]);
466
462
secp256k1_ge_set_gej (& aggnonce [1 ], & aggnoncej [1 ]);
@@ -476,9 +472,9 @@ static int secp256k1_musig_nonce_process_internal(int *fin_nonce_parity, unsigne
476
472
if (secp256k1_ge_is_infinity (& fin_nonce_pt )) {
477
473
fin_nonce_pt = secp256k1_ge_const_g ;
478
474
}
479
- ret = secp256k1_xonly_ge_serialize ( fin_nonce , & fin_nonce_pt );
480
- /* Can't fail since fin_nonce_pt is not infinity */
481
- VERIFY_CHECK ( ret );
475
+ /* fin_nonce_pt is not the point at infinity */
476
+ secp256k1_fe_normalize_var ( & fin_nonce_pt . x );
477
+ secp256k1_fe_get_b32 ( fin_nonce , & fin_nonce_pt . x );
482
478
secp256k1_fe_normalize_var (& fin_nonce_pt .y );
483
479
* fin_nonce_parity = secp256k1_fe_is_odd (& fin_nonce_pt .y );
484
480
return 1 ;
0 commit comments