Skip to main content

AffinePoint

Struct AffinePoint 

Source
pub struct AffinePoint<F: FieldOps> {
    pub x: F,
    pub y: F,
    pub infinity: bool,
}
Expand description

An affine point on a Weierstrass elliptic curve over F.

The point at infinity is represented by infinity = true; in that case the x and y fields are meaningless (set to zero by convention).

Fields§

§x: F

x coordinate

§y: F

y coordinate

§infinity: bool

true if and only if the ponit at infinity

Implementations§

Source§

impl<F: FieldOps> AffinePoint<F>

Source

pub fn new(x: F, y: F) -> Self

Construct a finite affine point (x, y).

No on-curve check is performed; use WeierstrassCurve::contains if you need validation.

Source

pub fn identity() -> Self

The point at infinity O (the group identity).

Source

pub fn is_identity(&self) -> bool

Returns true if this is the point at infinity.

Source§

impl<F: FieldOps> AffinePoint<F>

Source

pub fn negate(&self, curve: &WeierstrassCurve<F>) -> Self

Negate a point: -(x, y) = (x, −y − a₁x − a₃).

Source

pub fn double(&self, curve: &WeierstrassCurve<F>) -> Self

Double a point: [2]P.

Uses the tangent-line formula for the general Weierstrass model:

λ = (3x₁² + 2a₂x₁ + a₄ − a₁y₁) / (2y₁ + a₁x₁ + a₃)
x₃ = λ² + a₁λ − a₂ − 2x₁
y₃ = λ(x₁ − x₃) − y₁ − a₁x₃ − a₃

Returns O when the tangent is vertical (i.e. 2y + a₁x + a₃ = 0).

Source

pub fn add(&self, other: &Self, curve: &WeierstrassCurve<F>) -> Self

Add two points: P + Q.

Handles all cases:

  • Either operand is O → return the other.
  • P = Q → delegate to double.
  • P = −Q (same x, opposite y) → return O.
  • General chord:
λ  = (y₂ − y₁) / (x₂ − x₁)
x₃ = λ² + a₁λ − a₂ − x₁ − x₂
y₃ = λ(x₁ − x₃) − y₁ − a₁x₃ − a₃
Source

pub fn scalar_mul( &self, k: &[u64], curve: &<AffinePoint<F> as PointOps>::Curve, ) -> Self

Multiply self by k

§Arguments
  • &self - Point on curve (type: Self)
  • k - Integer (type: &[u64])
  • curve - The curve we’re on (type: &<AffinePoint<F> as PointOps>::Curve)
§Returns

The point k * self (type: Self)

Trait Implementations§

Source§

impl<F: Clone + FieldOps> Clone for AffinePoint<F>

Source§

fn clone(&self) -> AffinePoint<F>

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<F> ConditionallySelectable for AffinePoint<F>
where F: FieldOps + Copy,

Source§

fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self

Select a or b according to choice. Read more
Source§

fn conditional_assign(&mut self, other: &Self, choice: Choice)

Conditionally assign other to self, according to choice. Read more
Source§

fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)

Conditionally swap self and other if choice == 1; otherwise, reassign both unto themselves. Read more
Source§

impl<F> ConstantTimeEq for AffinePoint<F>

Source§

fn ct_eq(&self, other: &Self) -> Choice

Determine if two items are equal. Read more
Source§

fn ct_ne(&self, other: &Self) -> Choice

Determine if two items are NOT equal. Read more
Source§

impl<F: Debug + FieldOps> Debug for AffinePoint<F>

Source§

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

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

impl<F> Display for AffinePoint<F>
where F: FieldOps + Display,

Source§

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

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

impl<F> PartialEq for AffinePoint<F>

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<F> PointAdd for AffinePoint<F>
where F: FieldOps,

Source§

fn add(&self, other: &Self, curve: &Self::Curve) -> Self

Add a pair of points
Source§

impl<F> PointOps for AffinePoint<F>
where F: FieldOps,

Source§

type BaseField = F

The base field $\mathbb{F}_{p^M}$
Source§

type Curve = WeierstrassCurve<F>

The elliptic curve we’re working on
Source§

fn identity(_curve: &Self::Curve) -> Self

Returns the identity
Source§

fn is_identity(&self) -> bool

Returns true if and only if self is the identity
Source§

fn negate(&self, curve: &Self::Curve) -> Self

Negate a point
Source§

fn scalar_mul(&self, k: &[u64], curve: &Self::Curve) -> Self

Scalar multiplication [k]P (variable-time double-and-add). Read more
Source§

impl<F: Copy + FieldOps> Copy for AffinePoint<F>

Source§

impl<F> Eq for AffinePoint<F>

Auto Trait Implementations§

§

impl<F> Freeze for AffinePoint<F>
where F: Freeze,

§

impl<F> RefUnwindSafe for AffinePoint<F>
where F: RefUnwindSafe,

§

impl<F> Send for AffinePoint<F>
where F: Send,

§

impl<F> Sync for AffinePoint<F>
where F: Sync,

§

impl<F> Unpin for AffinePoint<F>
where F: Unpin,

§

impl<F> UnsafeUnpin for AffinePoint<F>
where F: UnsafeUnpin,

§

impl<F> UnwindSafe for AffinePoint<F>
where F: 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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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.