TheAlgorithms/C++ 1.0.0
All the algorithms implemented in C++
|
namespace elliptic_curve_key_exchange More...
Classes | |
struct | Point |
Definition of struct Point. More... | |
Typedefs | |
typedef struct ciphers::elliptic_curve_key_exchange::Point | Point |
Definition of struct Point. | |
Functions | |
uint256_t | 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 | addition (Point a, Point b, const uint256_t &curve_a_coeff, uint256_t mod) |
Addition of points. | |
Point | multiply (const Point &a, const uint256_t &curve_a_coeff, uint256_t p, const uint256_t &mod) |
multiply Point and integer | |
namespace elliptic_curve_key_exchange
Demonstration of Elliptic Curve Diffie-Hellman key exchange.
typedef struct ciphers::elliptic_curve_key_exchange::Point ciphers::elliptic_curve_key_exchange::Point |
Point ciphers::elliptic_curve_key_exchange::addition | ( | Point | a, |
Point | b, | ||
const uint256_t & | curve_a_coeff, | ||
uint256_t | mod ) |
Addition of points.
Add given point to generate third point. More description can be found here, and here
a | First point |
b | Second point |
curve_a_coeff | Coefficient a of the given curve (y^2 = x^3 + ax + b) % mod |
mod | Given field |
Slope
value zero
slope when the line is tangent to curve. This operation is performed while doubling. Taking derivative of y^2 = x^3 + ax + b
=> 2y dy = (3 * x^2 + a)dx
=> (dy/dx) = (3x^2 + a)/(2y)
if y co-ordinate is zero, the slope is infinite, return inf. else calculate the slope (here % mod and store in lambda)
Definition at line 110 of file elliptic_curve_key_exchange.cpp.
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.
number | integer base |
power | unsigned integer exponent |
mod | integer modulo |
Definition at line 78 of file elliptic_curve_key_exchange.cpp.
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
Multiply Point by a scalar factor (here it is a private key p). The multiplication is called as double and add method
a | Point to multiply |
curve_a_coeff | Coefficient of given curve (y^2 = x^3 + ax + b) % mod |
p | The scalar value |
mod | Given field |
Definition at line 165 of file elliptic_curve_key_exchange.cpp.