pub struct Point<C>(/* private fields */);Expand description
A point on an elliptic curve curve, possibly at infinity.
Implementations§
Source§impl<C: Curve> Point<C>
impl<C: Curve> Point<C>
pub fn new(x: Num, y: Num) -> Result<Self, InvalidPoint>
pub fn infinity() -> Self
pub fn coordinates(&self) -> Coordinates
Trait Implementations§
Source§impl<C: Curve> Add for Point<C>
Elliptic curve points are added together by first constructing a
line through the two points, then finding the intersection of that line with
the curve. The intersection is the result. If the two points are equal, a
tangent should be constructed instead of a line.
impl<C: Curve> Add for Point<C>
Elliptic curve points are added together by first constructing a line through the two points, then finding the intersection of that line with the curve. The intersection is the result. If the two points are equal, a tangent should be constructed instead of a line.
If the points are not equal: $$ (x_1, y_1) + (x_2, y_2) = (x_3, y_3) \\ H = \frac{y_2 - y_1}{x_2 - x_1} \\ x_3 = H^2 - x_1 - x_2 \\ y_3 = H(x_1 - x_3) - y_1 \\ $$
If the points are equal: $$ 2 \cdot (x_1, y_1) = (x_3, y_3) \\ H = \frac{3x_1^2 + a}{2y_1} \\ x_3 = H^2 - 2x_1 \\ y_3 = H(x_1 - x_3) - y_1 \\ $$
Source§impl<C: Curve> AddAssign for Point<C>
impl<C: Curve> AddAssign for Point<C>
Source§fn add_assign(&mut self, rhs: Self)
fn add_assign(&mut self, rhs: Self)
+= operation. Read moreSource§impl<C: Curve> Mul<Point<C>> for Num
Multiply the point by a scalar.
impl<C: Curve> Mul<Point<C>> for Num
Multiply the point by a scalar.
This uses the square-and-multiply method. For example, to calculate $x^{19}$, start with $y = x$ and multiply $y$ with itself, resulting in $y = y \cdot y = x^2$. Then, multiply $y$ with itself again, resulting in $y = y \cdot y = x^4$. Repeat this until it can no longer be done, at which point $y = x^{16}$ and there have been four multiplications thus far. Finally, multiply $y$ with $x$ three more times to get the desired result.
With this method, $x^{19}$ was calculated in only seven multiplications, compared to the naive algorithm which would execute 19 multiplications.
In the case of elliptic curve points, the “square” is equivalent to doubling, and “multiply” is equivalent to addition.