Changeset View
Changeset View
Standalone View
Standalone View
src/secp256k1/src/modules/ecdh/main_impl.h
/********************************************************************** | /********************************************************************** | ||||
* Copyright (c) 2015 Andrew Poelstra * | * Copyright (c) 2015 Andrew Poelstra * | ||||
* Distributed under the MIT software license, see the accompanying * | * Distributed under the MIT software license, see the accompanying * | ||||
* file COPYING or http://www.opensource.org/licenses/mit-license.php.* | * file COPYING or http://www.opensource.org/licenses/mit-license.php.* | ||||
**********************************************************************/ | **********************************************************************/ | ||||
#ifndef _SECP256K1_MODULE_ECDH_MAIN_ | #ifndef SECP256K1_MODULE_ECDH_MAIN_H | ||||
#define _SECP256K1_MODULE_ECDH_MAIN_ | #define SECP256K1_MODULE_ECDH_MAIN_H | ||||
#include "include/secp256k1_ecdh.h" | #include "include/secp256k1_ecdh.h" | ||||
#include "ecmult_const_impl.h" | #include "ecmult_const_impl.h" | ||||
int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const secp256k1_pubkey *point, const unsigned char *scalar) { | int secp256k1_ecdh(const secp256k1_context* ctx, unsigned char *result, const secp256k1_pubkey *point, const unsigned char *scalar) { | ||||
int ret = 0; | int ret = 0; | ||||
int overflow = 0; | int overflow = 0; | ||||
secp256k1_gej res; | secp256k1_gej res; | ||||
Show All 29 Lines | if (overflow || secp256k1_scalar_is_zero(&s)) { | ||||
secp256k1_sha256_finalize(&sha, result); | secp256k1_sha256_finalize(&sha, result); | ||||
ret = 1; | ret = 1; | ||||
} | } | ||||
secp256k1_scalar_clear(&s); | secp256k1_scalar_clear(&s); | ||||
return ret; | return ret; | ||||
} | } | ||||
#endif | #endif /* SECP256K1_MODULE_ECDH_MAIN_H */ |