@@ -14,7 +14,7 @@ extern "C" {
14
14
* 2. Array lengths always immediately the follow the argument whose length
15
15
* they describe, even if this violates rule 1.
16
16
* 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,
18
18
* messages, public keys, secret keys, tweaks.
19
19
* 4. Arguments that are not data pointers go last, from more complex to less
20
20
* complex: function pointers, algorithm names, messages, void pointers,
@@ -531,7 +531,7 @@ SECP256K1_API extern const secp256k1_nonce_function secp256k1_nonce_function_def
531
531
/** Create an ECDSA signature.
532
532
*
533
533
* 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.
535
535
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL)
536
536
* Out: sig: pointer to an array where the signature will be placed (cannot be NULL)
537
537
* In: msg32: the 32-byte message hash being signed (cannot be NULL)
@@ -552,6 +552,11 @@ SECP256K1_API int secp256k1_ecdsa_sign(
552
552
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 ) SECP256K1_ARG_NONNULL (4 );
553
553
554
554
/** 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.
555
560
*
556
561
* Returns: 1: secret key is valid
557
562
* 0: secret key is invalid
@@ -569,20 +574,32 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(
569
574
* 0: secret was invalid, try again
570
575
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL)
571
576
* 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)
573
578
*/
574
579
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create (
575
580
const secp256k1_context * ctx ,
576
581
secp256k1_pubkey * pubkey ,
577
582
const unsigned char * seckey
578
583
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
579
584
580
- /** Negates a private key in place.
585
+ /** Negates a secret key in place.
581
586
*
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)
585
595
*/
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. */
586
603
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_negate (
587
604
const secp256k1_context * ctx ,
588
605
unsigned char * seckey
@@ -599,57 +616,93 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(
599
616
secp256k1_pubkey * pubkey
600
617
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 );
601
618
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. */
611
642
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add (
612
643
const secp256k1_context * ctx ,
613
644
unsigned char * seckey ,
614
645
const unsigned char * tweak
615
646
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
616
647
617
648
/** 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
623
654
* (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).
626
661
*/
627
662
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add (
628
663
const secp256k1_context * ctx ,
629
664
secp256k1_pubkey * pubkey ,
630
665
const unsigned char * tweak
631
666
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
632
667
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).
639
680
*/
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. */
640
689
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul (
641
690
const secp256k1_context * ctx ,
642
691
unsigned char * seckey ,
643
692
const unsigned char * tweak
644
693
) SECP256K1_ARG_NONNULL (1 ) SECP256K1_ARG_NONNULL (2 ) SECP256K1_ARG_NONNULL (3 );
645
694
646
695
/** 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).
653
706
*/
654
707
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul (
655
708
const secp256k1_context * ctx ,
@@ -688,6 +741,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_context_randomize(
688
741
) SECP256K1_ARG_NONNULL (1 );
689
742
690
743
/** Add a number of public keys together.
744
+ *
691
745
* Returns: 1: the sum of the public keys is valid.
692
746
* 0: the sum of the public keys is not valid.
693
747
* Args: ctx: pointer to a context object
0 commit comments