@@ -14,7 +14,7 @@ extern "C" {
1414 * 2. Array lengths always immediately the follow the argument whose length 
1515 *    they describe, even if this violates rule 1. 
1616 * 3. Within the OUT/OUTIN/IN groups, pointers to data that is typically generated 
17-  *    later go first. This means: signatures, public nonces, private  nonces, 
17+  *    later go first. This means: signatures, public nonces, secret  nonces, 
1818 *    messages, public keys, secret keys, tweaks. 
1919 * 4. Arguments that are not data pointers go last, from more complex to less 
2020 *    complex: function pointers, algorithm names, messages, void pointers, 
@@ -531,7 +531,7 @@ SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_def
531531/** Create an ECDSA signature. 
532532 * 
533533 *  Returns: 1: signature created 
534-  *           0: the nonce generation function failed, or the private  key was invalid. 
534+  *           0: the nonce generation function failed, or the secret  key was invalid. 
535535 *  Args:    ctx:    pointer to a context object, initialized for signing (cannot be NULL) 
536536 *  Out:     sig:    pointer to an array where the signature will be placed (cannot be NULL) 
537537 *  In:      msg32:  the 32-byte message hash being signed (cannot be NULL) 
@@ -552,6 +552,11 @@ SECP256K1_API int secp256k1_ecdsa_sign(
552552) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 );
553553
554554/** Verify an ECDSA secret key. 
555+  * 
556+  *  A secret key is valid if it is not 0 and less than the secp256k1 curve order 
557+  *  when interpreted as an integer (most significant byte first). The 
558+  *  probability of choosing a 32-byte string uniformly at random which is an 
559+  *  invalid secret key is negligible. 
555560 * 
556561 *  Returns: 1: secret key is valid 
557562 *           0: secret key is invalid 
@@ -569,20 +574,32 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(
569574 *           0: secret was invalid, try again 
570575 *  Args:   ctx:        pointer to a context object, initialized for signing (cannot be NULL) 
571576 *  Out:    pubkey:     pointer to the created public key (cannot be NULL) 
572-  *  In:     seckey:     pointer to a 32-byte private  key (cannot be NULL) 
577+  *  In:     seckey:     pointer to a 32-byte secret  key (cannot be NULL) 
573578 */ 
574579SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_pubkey_create (
575580    const  secp256k1_context *  ctx ,
576581    secp256k1_pubkey  * pubkey ,
577582    const  unsigned char   * seckey 
578583) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
579584
580- /** Negates a private  key in place. 
585+ /** Negates a secret  key in place. 
581586 * 
582-  *  Returns: 1 always 
583-  *  Args:   ctx:        pointer to a context object 
584-  *  In/Out: seckey:     pointer to the 32-byte private key to be negated (cannot be NULL) 
587+  *  Returns: 0 if the given secret key is invalid according to 
588+  *           secp256k1_ec_seckey_verify. 1 otherwise 
589+  *  Args:   ctx:    pointer to a context object 
590+  *  In/Out: seckey: pointer to the 32-byte secret key to be negated. If the 
591+  *                  secret key is invalid according to 
592+  *                  secp256k1_ec_seckey_verify, this function returns 0 and 
593+  *                  seckey will be set to some unspecified value. (cannot be 
594+  *                  NULL) 
585595 */ 
596+ SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_seckey_negate (
597+     const  secp256k1_context *  ctx ,
598+     unsigned char   * seckey 
599+ ) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 );
600+ 
601+ /** Same as secp256k1_ec_seckey_negate, but DEPRECATED. Will be removed in 
602+  *  future versions. */ 
586603SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_privkey_negate (
587604    const  secp256k1_context *  ctx ,
588605    unsigned char   * seckey 
@@ -599,57 +616,93 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(
599616    secp256k1_pubkey  * pubkey 
600617) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 );
601618
602- /** Tweak a private key by adding tweak to it. 
603-  * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for 
604-  *          uniformly random 32-byte arrays, or if the resulting private key 
605-  *          would be invalid (only when the tweak is the complement of the 
606-  *          private key). 1 otherwise. 
607-  * Args:    ctx:    pointer to a context object (cannot be NULL). 
608-  * In/Out:  seckey: pointer to a 32-byte private key. 
609-  * In:      tweak:  pointer to a 32-byte tweak. 
610-  */ 
619+ /** Tweak a secret key by adding tweak to it. 
620+  * 
621+  *  Returns: 0 if the arguments are invalid or the resulting secret key would be 
622+  *           invalid (only when the tweak is the negation of the secret key). 1 
623+  *           otherwise. 
624+  *  Args:    ctx:   pointer to a context object (cannot be NULL). 
625+  *  In/Out: seckey: pointer to a 32-byte secret key. If the secret key is 
626+  *                  invalid according to secp256k1_ec_seckey_verify, this 
627+  *                  function returns 0. seckey will be set to some unspecified 
628+  *                  value if this function returns 0. (cannot be NULL) 
629+  *  In:      tweak: pointer to a 32-byte tweak. If the tweak is invalid according to 
630+  *                  secp256k1_ec_seckey_verify, this function returns 0. For 
631+  *                  uniformly random 32-byte arrays the chance of being invalid 
632+  *                  is negligible (around 1 in 2^128) (cannot be NULL). 
633+  */ 
634+ SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_seckey_tweak_add (
635+     const  secp256k1_context *  ctx ,
636+     unsigned char   * seckey ,
637+     const  unsigned char   * tweak 
638+ ) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
639+ 
640+ /** Same as secp256k1_ec_seckey_tweak_add, but DEPRECATED. Will be removed in 
641+  *  future versions. */ 
611642SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_privkey_tweak_add (
612643    const  secp256k1_context *  ctx ,
613644    unsigned char   * seckey ,
614645    const  unsigned char   * tweak 
615646) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
616647
617648/** Tweak a public key by adding tweak times the generator to it. 
618-  * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for  
619-  *          uniformly random 32-byte arrays,  or if  the resulting public key 
620-  *          would be  invalid (only when the tweak is the complement  of the 
621-  *          corresponding private  key). 1 otherwise. 
622-  * Args:    ctx:     pointer to a context object initialized for validation 
649+  * 
650+  *  Returns: 0 if the arguments are invalid  or the resulting public key would be  
651+  *            invalid (only when the tweak is the negation  of the corresponding  
652+  *           secret  key). 1 otherwise. 
653+  *   Args:    ctx:   pointer to a context object initialized for validation 
623654 *                  (cannot be NULL). 
624-  * In/Out:  pubkey: pointer to a public key object. 
625-  * In:      tweak:  pointer to a 32-byte tweak. 
655+  *  In/Out: pubkey: pointer to a public key object. pubkey will be set to an 
656+  *                  invalid value if this function returns 0 (cannot be NULL). 
657+  *  In:      tweak: pointer to a 32-byte tweak. If the tweak is invalid according to 
658+  *                  secp256k1_ec_seckey_verify, this function returns 0. For 
659+  *                  uniformly random 32-byte arrays the chance of being invalid 
660+  *                  is negligible (around 1 in 2^128) (cannot be NULL). 
626661 */ 
627662SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_pubkey_tweak_add (
628663    const  secp256k1_context *  ctx ,
629664    secp256k1_pubkey  * pubkey ,
630665    const  unsigned char   * tweak 
631666) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
632667
633- /** Tweak a private key by multiplying it by a tweak. 
634-  * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for 
635-  *          uniformly random 32-byte arrays, or equal to zero. 1 otherwise. 
636-  * Args:   ctx:    pointer to a context object (cannot be NULL). 
637-  * In/Out: seckey: pointer to a 32-byte private key. 
638-  * In:     tweak:  pointer to a 32-byte tweak. 
668+ /** Tweak a secret key by multiplying it by a tweak. 
669+  * 
670+  *  Returns: 0 if the arguments are invalid. 1 otherwise. 
671+  *  Args:   ctx:    pointer to a context object (cannot be NULL). 
672+  *  In/Out: seckey: pointer to a 32-byte secret key. If the secret key is 
673+  *                  invalid according to secp256k1_ec_seckey_verify, this 
674+  *                  function returns 0. seckey will be set to some unspecified 
675+  *                  value if this function returns 0. (cannot be NULL) 
676+  *  In:      tweak: pointer to a 32-byte tweak. If the tweak is invalid according to 
677+  *                  secp256k1_ec_seckey_verify, this function returns 0. For 
678+  *                  uniformly random 32-byte arrays the chance of being invalid 
679+  *                  is negligible (around 1 in 2^128) (cannot be NULL). 
639680 */ 
681+ SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_seckey_tweak_mul (
682+     const  secp256k1_context *  ctx ,
683+     unsigned char   * seckey ,
684+     const  unsigned char   * tweak 
685+ ) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
686+ 
687+ /** Same as secp256k1_ec_seckey_tweak_mul, but DEPRECATED. Will be removed in 
688+  *  future versions. */ 
640689SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_privkey_tweak_mul (
641690    const  secp256k1_context *  ctx ,
642691    unsigned char   * seckey ,
643692    const  unsigned char   * tweak 
644693) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
645694
646695/** Tweak a public key by multiplying it by a tweak value. 
647-  * Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for 
648-  *          uniformly random 32-byte arrays, or equal to zero. 1 otherwise. 
649-  * Args:    ctx:    pointer to a context object initialized for validation 
650-  *                 (cannot be NULL). 
651-  * In/Out:  pubkey: pointer to a public key object. 
652-  * In:      tweak:  pointer to a 32-byte tweak. 
696+  * 
697+  *  Returns: 0 if the arguments are invalid. 1 otherwise. 
698+  *  Args:    ctx:   pointer to a context object initialized for validation 
699+  *                  (cannot be NULL). 
700+  *  In/Out: pubkey: pointer to a public key object. pubkey will be set to an 
701+  *                  invalid value if this function returns 0 (cannot be NULL). 
702+  *  In:      tweak: pointer to a 32-byte tweak. If the tweak is invalid according to 
703+  *                  secp256k1_ec_seckey_verify, this function returns 0. For 
704+  *                  uniformly random 32-byte arrays the chance of being invalid 
705+  *                  is negligible (around 1 in 2^128) (cannot be NULL). 
653706 */ 
654707SECP256K1_API  SECP256K1_WARN_UNUSED_RESULT  int  secp256k1_ec_pubkey_tweak_mul (
655708    const  secp256k1_context *  ctx ,
@@ -688,6 +741,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(
688741) SECP256K1_ARG_NONNULL (1 );
689742
690743/** Add a number of public keys together. 
744+  * 
691745 *  Returns: 1: the sum of the public keys is valid. 
692746 *           0: the sum of the public keys is not valid. 
693747 *  Args:   ctx:        pointer to a context object 
0 commit comments