7#ifndef SECP256K1_MODULE_ECDH_MAIN_H
8#define SECP256K1_MODULE_ECDH_MAIN_H
14 unsigned char version = (y32[31] & 0x01) | 0x02;
48 secp256k1_pubkey_load(ctx, &pt, point);
49 secp256k1_scalar_set_b32(&s, scalar, &overflow);
51 overflow |= secp256k1_scalar_is_zero(&s);
52 secp256k1_scalar_cmov(&s, &secp256k1_scalar_one, overflow);
54 secp256k1_ecmult_const(&res, &pt, &s);
55 secp256k1_ge_set_gej(&pt, &res);
63 ret = hashfp(output, x, y, data);
67 secp256k1_scalar_clear(&s);
68 secp256k1_ge_clear(&pt);
69 secp256k1_gej_clear(&res);
71 return !!
ret & !overflow;
static int ecdh_hash_function_sha256(unsigned char *output, const unsigned char *x32, const unsigned char *y32, void *data)
#define secp256k1_fe_get_b32
#define secp256k1_fe_normalize
static void secp256k1_sha256_initialize(secp256k1_sha256 *hash)
static void secp256k1_sha256_finalize(secp256k1_sha256 *hash, unsigned char *out32)
static void secp256k1_sha256_write(secp256k1_sha256 *hash, const unsigned char *data, size_t size)
static void secp256k1_sha256_clear(secp256k1_sha256 *hash)
static SECP256K1_INLINE void secp256k1_memclear_explicit(void *ptr, size_t len)
#define VERIFY_CHECK(cond)
struct secp256k1_context_struct secp256k1_context
Unless explicitly stated all pointer arguments must not be NULL.
SECP256K1_API SECP256K1_WARN_UNUSED_RESULT int secp256k1_ecdh(const secp256k1_context *ctx, unsigned char *output, const secp256k1_pubkey *pubkey, const unsigned char *seckey, secp256k1_ecdh_hash_function hashfp, void *data) SECP256K1_ARG_NONNULL(1) SECP256K1_ARG_NONNULL(2) SECP256K1_ARG_NONNULL(3) SECP256K1_ARG_NONNULL(4)
Compute an EC Diffie-Hellman secret in constant time.
int(*) secp256k1_ecdh_hash_function(unsigned char *output, const unsigned char *x32, const unsigned char *y32, void *data)
A pointer to a function that hashes an EC point to obtain an ECDH secret.
SECP256K1_API const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_sha256
An implementation of SHA256 hash function that applies to compressed public key.
SECP256K1_API const secp256k1_ecdh_hash_function secp256k1_ecdh_hash_function_default
A default ECDH hash function (currently equal to secp256k1_ecdh_hash_function_sha256).
A group element in affine coordinates on the secp256k1 curve, or occasionally on an isomorphic curve ...
A group element of the secp256k1 curve, in jacobian coordinates.
Opaque data structure that holds a parsed and valid public key.
A scalar modulo the group order of the secp256k1 curve.