Skip to content

Commit 9c30a48

Browse files
committed
f rephrase ec arithmetic doc
1 parent 4a179b0 commit 9c30a48

File tree

1 file changed

+35
-29
lines changed

1 file changed

+35
-29
lines changed

include/secp256k1.h

+35-29
Original file line numberDiff line numberDiff line change
@@ -585,8 +585,8 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_create(
585585
* Args: ctx: pointer to a context object
586586
* In/Out: seckey: pointer to the 32-byte secret key to be negated. The secret
587587
* key should be valid according to secp256k1_ec_seckey_verify.
588-
* Value becomes undefined if this function returns 0.
589-
* (cannot be NULL)
588+
* If this function returns 0, seckey will be some
589+
* unspecified value. (cannot be NULL)
590590
*/
591591
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_negate(
592592
const secp256k1_context* ctx,
@@ -605,15 +605,17 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_negate(
605605
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2);
606606

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

624626
/** Tweak a public key by adding tweak times the generator to it.
625-
* Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for
626-
* uniformly random 32-byte arrays, or if the given secret key is
627-
* invalid according to secp256k1_ec_seckey_verify, or if the resulting
628-
* public key would be invalid (only when the tweak is the complement
629-
* of the corresponding secret key). 1 otherwise.
627+
* Returns: 0 if the resulting public key would be invalid (only when the tweak
628+
* is the negation of the corresponding secret key). 1 otherwise.
630629
* Args: ctx: pointer to a context object initialized for validation
631630
* (cannot be NULL).
632-
* In/Out: pubkey: pointer to a public key object. Value becomes undefined if this
633-
* function returns 0. (cannot be NULL).
634-
* In: tweak: pointer to a 32-byte tweak.
631+
* In/Out: pubkey: pointer to a public key object. If this function returns 0,
632+
* pubkey will be invalid. (cannot be NULL).
633+
* In: tweak: pointer to a 32-byte tweak. Must be in the same range as secret
634+
* keys (see secp256k1_ec_seckey_verify). For uniformly random
635+
* 32-byte arrays the chance of being out of range is
636+
* negligible (around 1 in 2^128). (cannot be NULL)
635637
*/
636638
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
637639
const secp256k1_context* ctx,
@@ -640,12 +642,14 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_pubkey_tweak_add(
640642
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
641643

642644
/** Tweak a secret key by multiplying it by a tweak.
643-
* Returns: 0 if the tweak was out of range (chance of around 1 in 2^128 for
644-
* uniformly random 32-byte arrays, or equal to zero. 1 otherwise.
645+
* Returns: 0 if the arguments are invalid.. 1 otherwise.
645646
* Args: ctx: pointer to a context object (cannot be NULL).
646-
* In/Out: seckey: pointer to a 32-byte secret key. Value becomes undefined if this
647-
* function returns 0. (cannot be NULL).
648-
* In: tweak: pointer to a 32-byte tweak.
647+
* In/Out: seckey: pointer to a 32-byte secret key. If this function returns 0,
648+
* seckey will be some unspecified value. (cannot be NULL).
649+
* In: tweak: pointer to a 32-byte tweak. Must be in the same range as secret
650+
* keys (see secp256k1_ec_seckey_verify). For uniformly random
651+
* 32-byte arrays the chance of being out of range is
652+
* negligible (around 1 in 2^128). (cannot be NULL)
649653
*/
650654
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
651655
const secp256k1_context* ctx,
@@ -654,13 +658,15 @@ SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ec_privkey_tweak_mul(
654658
) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3);
655659

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

0 commit comments

Comments
 (0)