TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
Implementation of Elliptic Curve Diffie Hellman Key Exchange. More...
Go to the source code of this file.
Classes | |
struct | ciphers::elliptic_curve_key_exchange::Point |
Definition of struct Point. More... | |
Namespaces | |
namespace | ciphers |
Algorithms for encryption and decryption. | |
namespace | ciphers::elliptic_curve_key_exchange |
namespace elliptic_curve_key_exchange | |
Typedefs | |
typedef struct ciphers::elliptic_curve_key_exchange::Point | ciphers::elliptic_curve_key_exchange::Point |
Definition of struct Point. | |
Functions | |
uint256_t | ciphers::elliptic_curve_key_exchange::exp (uint256_t number, uint256_t power, const uint256_t &mod) |
This function calculates number raised to exponent power under modulo mod using Modular Exponentiation. | |
Point | ciphers::elliptic_curve_key_exchange::addition (Point a, Point b, const uint256_t &curve_a_coeff, uint256_t mod) |
Addition of points. | |
Point | ciphers::elliptic_curve_key_exchange::multiply (const Point &a, const uint256_t &curve_a_coeff, uint256_t p, const uint256_t &mod) |
multiply Point and integer | |
static void | uint128_t_tests () |
Function to test the uint128_t header. | |
static void | uint256_t_tests () |
Function to test the uint256_t header. | |
static void | test () |
Function to test the provided algorithm above. | |
int | main () |
Main function. | |
Implementation of Elliptic Curve Diffie Hellman Key Exchange.
The ECDH (Elliptic Curve Diffie–Hellman Key Exchange) is anonymous key agreement scheme, which allows two parties, each having an elliptic-curve public–private key pair, to establish a shared secret over an insecure channel. ECDH is very similar to the classical DHKE (Diffie–Hellman Key Exchange) algorithm, but it uses ECC point multiplication instead of modular exponentiations. ECDH is based on the following property of EC points: (a * G) * b = (b * G) * a If we have two secret numbers a and b (two private keys, belonging to Alice and Bob) and an ECC elliptic curve with generator point G, we can exchange over an insecure channel the values (a * G) and (b * G) (the public keys of Alice and Bob) and then we can derive a shared secret: secret = (a * G) * b = (b * G) * a. Pretty simple. The above equation takes the following form: alicePubKey * bobPrivKey = bobPubKey * alicePrivKey = secret
Definition in file elliptic_curve_key_exchange.cpp.
int main | ( | void | ) |
Main function.
Definition at line 320 of file elliptic_curve_key_exchange.cpp.
|
static |
Function to test the provided algorithm above.
Definition at line 267 of file elliptic_curve_key_exchange.cpp.
|
static |
Function to test the uint128_t header.
Definition at line 197 of file elliptic_curve_key_exchange.cpp.
|
static |
Function to test the uint256_t header.
Definition at line 230 of file elliptic_curve_key_exchange.cpp.