|
Algorithms_in_C++ 1.0.0
Set of 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. More... | |
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. More... | |
| Point | addition (Point a, Point b, const uint256_t &curve_a_coeff, uint256_t mod) |
| Addition of points. More... | |
| Point | multiply (const Point &a, const uint256_t &curve_a_coeff, uint256_t p, const uint256_t &mod) |
| multiply Point and integer More... | |
namespace elliptic_curve_key_exchange
Demonstration of Elliptic Curve Diffie-Hellman key exchange.
| 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)
| 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 |
| 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 |