Struct Point

Source
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>

Source

pub fn new(x: Num, y: Num) -> Result<Self, InvalidPoint>

Source

pub fn infinity() -> Self

Source

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.

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§

type Output = Point<C>

The resulting type after applying the + operator.
Source§

fn add(self, rhs: Self) -> Self::Output

Performs the + operation. Read more
Source§

impl<C: Curve> AddAssign for Point<C>

Source§

fn add_assign(&mut self, rhs: Self)

Performs the += operation. Read more
Source§

impl<C> Clone for Point<C>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<C: Debug> Debug for Point<C>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

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.

Source§

type Output = Point<C>

The resulting type after applying the * operator.
Source§

fn mul(self, rhs: Point<C>) -> Self::Output

Performs the * operation. Read more
Source§

impl<C> PartialEq for Point<C>

Source§

fn eq(&self, other: &Self) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<C> Copy for Point<C>

Source§

impl<C> Eq for Point<C>

Auto Trait Implementations§

§

impl<C> Freeze for Point<C>

§

impl<C> RefUnwindSafe for Point<C>
where C: RefUnwindSafe,

§

impl<C> Send for Point<C>
where C: Send,

§

impl<C> Sync for Point<C>
where C: Sync,

§

impl<C> Unpin for Point<C>
where C: Unpin,

§

impl<C> UnwindSafe for Point<C>
where C: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.