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: Fx coordinate
y: Fy coordinate
infinity: booltrue if and only if the ponit at infinity
Implementations§
Source§impl<F: FieldOps> AffinePoint<F>
impl<F: FieldOps> AffinePoint<F>
Sourcepub fn new(x: F, y: F) -> Self
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.
Sourcepub fn is_identity(&self) -> bool
pub fn is_identity(&self) -> bool
Returns true if this is the point at infinity.
Source§impl<F: FieldOps> AffinePoint<F>
impl<F: FieldOps> AffinePoint<F>
Sourcepub fn negate(&self, curve: &WeierstrassCurve<F>) -> Self
pub fn negate(&self, curve: &WeierstrassCurve<F>) -> Self
Negate a point: -(x, y) = (x, −y − a₁x − a₃).
Sourcepub fn double(&self, curve: &WeierstrassCurve<F>) -> Self
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).
Sourcepub fn add(&self, other: &Self, curve: &WeierstrassCurve<F>) -> Self
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 todouble.P = −Q(same x, opposite y) → returnO.- General chord:
λ = (y₂ − y₁) / (x₂ − x₁)
x₃ = λ² + a₁λ − a₂ − x₁ − x₂
y₃ = λ(x₁ − x₃) − y₁ − a₁x₃ − a₃Sourcepub fn scalar_mul(
&self,
k: &[u64],
curve: &<AffinePoint<F> as PointOps>::Curve,
) -> Self
pub fn scalar_mul( &self, k: &[u64], curve: &<AffinePoint<F> as PointOps>::Curve, ) -> Self
Trait Implementations§
Source§impl<F: Clone + FieldOps> Clone for AffinePoint<F>
impl<F: Clone + FieldOps> Clone for AffinePoint<F>
Source§fn clone(&self) -> AffinePoint<F>
fn clone(&self) -> AffinePoint<F>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<F> ConditionallySelectable for AffinePoint<F>
impl<F> ConditionallySelectable for AffinePoint<F>
Source§fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
fn conditional_select(a: &Self, b: &Self, choice: Choice) -> Self
Source§fn conditional_assign(&mut self, other: &Self, choice: Choice)
fn conditional_assign(&mut self, other: &Self, choice: Choice)
Source§fn conditional_swap(a: &mut Self, b: &mut Self, choice: Choice)
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 moreSource§impl<F> ConstantTimeEq for AffinePoint<F>
impl<F> ConstantTimeEq for AffinePoint<F>
Source§impl<F> Display for AffinePoint<F>
impl<F> Display for AffinePoint<F>
Source§impl<F> PartialEq for AffinePoint<F>where
F: FieldOps + ConstantTimeEq,
impl<F> PartialEq for AffinePoint<F>where
F: FieldOps + ConstantTimeEq,
Source§impl<F> PointAdd for AffinePoint<F>where
F: FieldOps,
impl<F> PointAdd for AffinePoint<F>where
F: FieldOps,
Source§impl<F> PointOps for AffinePoint<F>where
F: FieldOps,
impl<F> PointOps for AffinePoint<F>where
F: FieldOps,
Source§type Curve = WeierstrassCurve<F>
type Curve = WeierstrassCurve<F>
The elliptic curve we’re working on
Source§fn is_identity(&self) -> bool
fn is_identity(&self) -> bool
Returns true if and only if
self is the identityimpl<F: Copy + FieldOps> Copy for AffinePoint<F>
impl<F> Eq for AffinePoint<F>where
F: FieldOps + ConstantTimeEq,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more