@@ -423,16 +423,20 @@ static int nonce_function_rfc6979(unsigned char *nonce32, const unsigned char *m
423
423
unsigned int offset = 0 ;
424
424
secp256k1_rfc6979_hmac_sha256 rng ;
425
425
unsigned int i ;
426
+ secp256k1_scalar msg ;
427
+ unsigned char msgmod32 [32 ];
428
+ secp256k1_scalar_set_b32 (& msg , msg32 , NULL );
429
+ secp256k1_scalar_get_b32 (msgmod32 , & msg );
426
430
/* We feed a byte array to the PRNG as input, consisting of:
427
- * - the private key (32 bytes) and message (32 bytes), see RFC 6979 3.2d.
431
+ * - the private key (32 bytes) and reduced message (32 bytes), see RFC 6979 3.2d.
428
432
* - optionally 32 extra bytes of data, see RFC 6979 3.6 Additional Data.
429
433
* - optionally 16 extra bytes with the algorithm name.
430
434
* Because the arguments have distinct fixed lengths it is not possible for
431
435
* different argument mixtures to emulate each other and result in the same
432
436
* nonces.
433
437
*/
434
438
buffer_append (keydata , & offset , key32 , 32 );
435
- buffer_append (keydata , & offset , msg32 , 32 );
439
+ buffer_append (keydata , & offset , msgmod32 , 32 );
436
440
if (data != NULL ) {
437
441
buffer_append (keydata , & offset , data , 32 );
438
442
}
0 commit comments