Skip to content

Commit 22911ee

Browse files
committed
Rename private key to secret key in public API (with the exception of function names)
1 parent 5a73f14 commit 22911ee

File tree

3 files changed

+46
-40
lines changed

3 files changed

+46
-40
lines changed

include/secp256k1.h

+43-37
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -574,23 +574,23 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_seckey_verify(
574574
* 0: secret was invalid, try again
575575
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL)
576576
* Out: pubkey: pointer to the created public key (cannot be NULL)
577-
* 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)
578578
*/
579579
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(
580580
const secp256k1_context* ctx,
581581
secp256k1_pubkey *pubkey,
582582
const unsigned char *seckey
583583
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
584584

585-
/** Negates a private key in place.
585+
/** Negates a secret key in place.
586586
*
587-
* Returns: 0 if the given private key is invalid according to
587+
* Returns: 0 if the given secret key is invalid according to
588588
* secp256k1_ec_seckey_verify. 1 otherwise
589589
* Args: ctx: pointer to a context object
590-
* In/Out: seckey: pointer to the 32-byte private key to be negated. The private
590+
* In/Out: seckey: pointer to the 32-byte secret key to be negated. The secret
591591
* key should be valid according to secp256k1_ec_seckey_verify.
592-
* Value becomes unspecified if this function returns 0.
593-
* (cannot be NULL)
592+
* If this function returns 0, seckey will be some
593+
* unspecified value. (cannot be NULL)
594594
*/
595595
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_negate(
596596
const secp256k1_context* ctx,
@@ -608,16 +608,18 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(
608608
secp256k1_pubkey *pubkey
609609
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2);
610610

611-
/** Tweak a private key by adding tweak to it.
612-
* Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for
613-
* uniformly random 32-byte arrays, or if the given private key is
614-
* invalid according to secp256k1_ec_seckey_verify, or if the resulting
615-
* private key would be invalid (only when the tweak is the complement
616-
* of the private key). 1 otherwise.
611+
/** Tweak a secret key by adding tweak to it.
612+
* Returns: 0 if the resulting secret key would be invalid (only when the tweak
613+
* is the negation of the secret key). 1 otherwise.
617614
* Args: ctx: pointer to a context object (cannot be NULL).
618-
* In/Out: seckey: pointer to a 32-byte private key. Value becomes unspecified if this
619-
* function returns 0. (cannot be NULL)
620-
* In: tweak: pointer to a 32-byte tweak.
615+
* In/Out: seckey: pointer to a 32-byte secret key. The secret key should be
616+
* valid according to secp256k1_ec_seckey_verify. If this
617+
* function returns 0, seckey will be some unspecified
618+
* value. (cannot be NULL)
619+
* In: tweak: pointer to a 32-byte tweak. Must be in the same range as secret
620+
* keys (see secp256k1_ec_seckey_verify). For uniformly random
621+
* 32-byte arrays the chance of being out of range is
622+
* negligible (around 1 in 2^128). (cannot be NULL)
621623
*/
622624
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(
623625
const secp256k1_context* ctx,
@@ -626,30 +628,32 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_add(
626628
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
627629

628630
/** Tweak a public key by adding tweak times the generator to it.
629-
* Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for
630-
* uniformly random 32-byte arrays, or if the given private key is
631-
* invalid according to secp256k1_ec_seckey_verify, or if the resulting
632-
* public key would be invalid (only when the tweak is the complement
633-
* of the corresponding private key). 1 otherwise.
631+
* Returns: 0 if the resulting public key would be invalid (only when the tweak
632+
* is the negation of the corresponding secret key). 1 otherwise.
634633
* Args: ctx: pointer to a context object initialized for validation
635634
* (cannot be NULL).
636-
* In/Out: pubkey: pointer to a public key object. Value becomes unspecified if this
637-
* function returns 0. (cannot be NULL).
638-
* In: tweak: pointer to a 32-byte tweak.
635+
* In/Out: pubkey: pointer to a public key object. If this function returns 0,
636+
* pubkey will be invalid. (cannot be NULL).
637+
* In: tweak: pointer to a 32-byte tweak. Must be in the same range as secret
638+
* keys (see secp256k1_ec_seckey_verify). For uniformly random
639+
* 32-byte arrays the chance of being out of range is
640+
* negligible (around 1 in 2^128). (cannot be NULL)
639641
*/
640642
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
641643
const secp256k1_context* ctx,
642644
secp256k1_pubkey *pubkey,
643645
const unsigned char *tweak
644646
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
645647

646-
/** Tweak a private key by multiplying it by a tweak.
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.
648+
/** Tweak a secret key by multiplying it by a tweak.
649+
* Returns: 0 if the arguments are invalid.. 1 otherwise.
649650
* Args: ctx: pointer to a context object (cannot be NULL).
650-
* In/Out: seckey: pointer to a 32-byte private key. Value becomes unspecified if this
651-
* function returns 0. (cannot be NULL).
652-
* In: tweak: pointer to a 32-byte tweak.
651+
* In/Out: seckey: pointer to a 32-byte secret key. If this function returns 0,
652+
* seckey will be some unspecified value. (cannot be NULL).
653+
* In: tweak: pointer to a 32-byte tweak. Must be in the same range as secret
654+
* keys (see secp256k1_ec_seckey_verify). For uniformly random
655+
* 32-byte arrays the chance of being out of range is
656+
* negligible (around 1 in 2^128). (cannot be NULL)
653657
*/
654658
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
655659
const secp256k1_context* ctx,
@@ -658,13 +662,15 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
658662
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
659663

660664
/** Tweak a public key by multiplying it by a tweak value.
661-
* Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for
662-
* uniformly random 32-byte arrays, or equal to zero. 1 otherwise.
665+
* Returns: 0 if the arguments are invalid. 1 otherwise.
663666
* Args: ctx: pointer to a context object initialized for validation
664-
* (cannot be NULL).
665-
* In/Out: pubkey: pointer to a public key object. Value becomes unspecified if this
666-
* function returns 0. (cannot be NULL).
667-
* In: tweak: pointer to a 32-byte tweak.
667+
* (cannot be NULL).
668+
* In/Out: pubkey: pointer to a public key object. If this function returns 0,
669+
* pubkey will be invalid. (cannot be NULL).
670+
* In: tweak: pointer to a 32-byte tweak. Must be in the same range as secret
671+
* keys (see secp256k1_ec_seckey_verify). For uniformly random
672+
* 32-byte arrays the chance of being out of range is
673+
* negligible (around 1 in 2^128). (cannot be NULL)
668674
*/
669675
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_mul(
670676
const secp256k1_context* ctx,

include/secp256k1_ecdh.h

+2-2
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ SECP256K1_API extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_func
4141
* Out: output: pointer to an array to be filled by hashfp
4242
* In: pubkey: a pointer to a secp256k1_pubkey containing an
4343
* initialized public key
44-
* privkey: a 32-byte scalar with which to multiply the point
44+
* seckey: a 32-byte scalar with which to multiply the point
4545
* hashfp: pointer to a hash function. If NULL, secp256k1_ecdh_hash_function_sha256 is used
4646
* (in which case, 32 bytes will be written to output)
4747
* data: arbitrary data pointer that is passed through to hashfp
@@ -50,7 +50,7 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(
5050
const secp256k1_context* ctx,
5151
unsigned char *output,
5252
const secp256k1_pubkey *pubkey,
53-
const unsigned char *privkey,
53+
const unsigned char *seckey,
5454
secp256k1_ecdh_hash_function hashfp,
5555
void *data
5656
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4);

include/secp256k1_recovery.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ SECP256K1_API int secp256k1_ecdsa_recoverable_signature_serialize_compact(
7070
/** Create a recoverable ECDSA signature.
7171
*
7272
* Returns: 1: signature created
73-
* 0: the nonce generation function failed, or the private key was invalid.
73+
* 0: the nonce generation function failed, or the secret key was invalid.
7474
* Args: ctx: pointer to a context object, initialized for signing (cannot be NULL)
7575
* Out: sig: pointer to an array where the signature will be placed (cannot be NULL)
7676
* In: msg32: the 32-byte message hash being signed (cannot be NULL)

0 commit comments

Comments
 (0)