Skip to content

Commit 4b48a43

Browse files
committed
doc: document the length requirements of output parameter.
It's subtle, since it is actually only touched by hashfp (though we assert it's non-NULL), but give explicit advice in the default case. Signed-off-by: Rusty Russell <[email protected]>
1 parent 1b4d256 commit 4b48a43

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

include/secp256k1_ecdh.h

+7-4
Original file line numberDiff line numberDiff line change
@@ -22,22 +22,25 @@ typedef int (*secp256k1_ecdh_hash_function)(
2222
void *data
2323
);
2424

25-
/** An implementation of SHA256 hash function that applies to compressed public key. */
25+
/** An implementation of SHA256 hash function that applies to compressed public key.
26+
* Populates the output parameter with 32 bytes. */
2627
SECP256K1_API extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_sha256;
2728

28-
/** A default ecdh hash function (currently equal to secp256k1_ecdh_hash_function_sha256). */
29+
/** A default ecdh hash function (currently equal to secp256k1_ecdh_hash_function_sha256).
30+
* Populates the output parameter with 32 bytes. */
2931
SECP256K1_API extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_default;
3032

3133
/** Compute an EC Diffie-Hellman secret in constant time
3234
* Returns: 1: exponentiation was successful
3335
* 0: scalar was invalid (zero or overflow)
3436
* Args: ctx: pointer to a context object (cannot be NULL)
35-
* Out: output: pointer to an array to be filled by the function
37+
* Out: output: pointer to an array to be filled by hashfp
3638
* In: pubkey: a pointer to a secp256k1_pubkey containing an
3739
* initialized public key
3840
* privkey: a 32-byte scalar with which to multiply the point
3941
* hashfp: pointer to a hash function. If NULL, secp256k1_ecdh_hash_function_sha256 is used
40-
* data: Arbitrary data pointer that is passed through
42+
* (in which case, 32 bytes will be written to output)
43+
* data: Arbitrary data pointer that is passed through to hashfp
4144
*/
4245
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(
4346
const secp256k1_context* ctx,

0 commit comments

Comments
 (0)