|
7 | 7 | extern "C" {
|
8 | 8 | #endif
|
9 | 9 |
|
10 |
| -/** A pointer to a function that applies hash function to a point |
| 10 | +/** A pointer to a function that hashes an EC point to obtain an ECDH secret |
11 | 11 | *
|
12 |
| - * Returns: 1 if a point was successfully hashed. 0 will cause ecdh to fail |
13 |
| - * Out: output: pointer to an array to be filled by the function |
14 |
| - * In: x: pointer to a 32-byte x coordinate |
15 |
| - * y: pointer to a 32-byte y coordinate |
16 |
| - * data: Arbitrary data pointer that is passed through |
| 12 | + * Returns: 1 if the point was successfully hashed. |
| 13 | + * 0 will cause secp256k1_ecdh to fail and return 0. |
| 14 | + * Other return values are not allowed, and the behaviour of |
| 15 | + * secp256k1_ecdh is undefined for other return values. |
| 16 | + * Out: output: pointer to an array to be filled by the function |
| 17 | + * In: x32: pointer to a 32-byte x coordinate |
| 18 | + * y32: pointer to a 32-byte y coordinate |
| 19 | + * data: arbitrary data pointer that is passed through |
17 | 20 | */
|
18 | 21 | typedef int (*secp256k1_ecdh_hash_function)(
|
19 | 22 | unsigned char *output,
|
20 |
| - const unsigned char *x, |
21 |
| - const unsigned char *y, |
| 23 | + const unsigned char *x32, |
| 24 | + const unsigned char *y32, |
22 | 25 | void *data
|
23 | 26 | );
|
24 | 27 |
|
25 | 28 | /** An implementation of SHA256 hash function that applies to compressed public key.
|
26 | 29 | * Populates the output parameter with 32 bytes. */
|
27 | 30 | SECP256K1_API extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_sha256;
|
28 | 31 |
|
29 |
| -/** A default ecdh hash function (currently equal to secp256k1_ecdh_hash_function_sha256). |
| 32 | +/** A default ECDH hash function (currently equal to secp256k1_ecdh_hash_function_sha256). |
30 | 33 | * Populates the output parameter with 32 bytes. */
|
31 | 34 | SECP256K1_API extern const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_default;
|
32 | 35 |
|
33 | 36 | /** Compute an EC Diffie-Hellman secret in constant time
|
| 37 | + * |
34 | 38 | * Returns: 1: exponentiation was successful
|
35 |
| - * 0: scalar was invalid (zero or overflow) |
| 39 | + * 0: scalar was invalid (zero or overflow) or hashfp returned 0 |
36 | 40 | * Args: ctx: pointer to a context object (cannot be NULL)
|
37 | 41 | * Out: output: pointer to an array to be filled by hashfp
|
38 | 42 | * In: pubkey: a pointer to a secp256k1_pubkey containing an
|
39 | 43 | * initialized public key
|
40 | 44 | * privkey: a 32-byte scalar with which to multiply the point
|
41 | 45 | * hashfp: pointer to a hash function. If NULL, secp256k1_ecdh_hash_function_sha256 is used
|
42 | 46 | * (in which case, 32 bytes will be written to output)
|
43 |
| - * data: Arbitrary data pointer that is passed through to hashfp |
| 47 | + * data: arbitrary data pointer that is passed through to hashfp |
44 | 48 | */
|
45 | 49 | SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(
|
46 | 50 | const secp256k1_context* ctx,
|
|
0 commit comments