Trait WeierstrassPoint

Source
pub trait WeierstrassPoint: Clone + Sized {
    type Coordinate: Field;

    const CURVE_A: Self::Coordinate;
    const CURVE_B: Self::Coordinate;
    const IDENTITY: Self;
Show 18 methods // Required methods fn as_le_bytes(&self) -> &[u8] ; unsafe fn from_xy_unchecked( x: Self::Coordinate, y: Self::Coordinate, ) -> Self; fn into_coords(self) -> (Self::Coordinate, Self::Coordinate); fn x(&self) -> &Self::Coordinate; fn y(&self) -> &Self::Coordinate; fn x_mut(&mut self) -> &mut Self::Coordinate; fn y_mut(&mut self) -> &mut Self::Coordinate; fn set_up_once(); fn add_assign_impl<const CHECK_SETUP: bool>(&mut self, p2: &Self); fn double_assign_impl<const CHECK_SETUP: bool>(&mut self); unsafe fn add_ne_nonidentity<const CHECK_SETUP: bool>( &self, p2: &Self, ) -> Self; unsafe fn add_ne_assign_nonidentity<const CHECK_SETUP: bool>( &mut self, p2: &Self, ); unsafe fn sub_ne_nonidentity<const CHECK_SETUP: bool>( &self, p2: &Self, ) -> Self; unsafe fn sub_ne_assign_nonidentity<const CHECK_SETUP: bool>( &mut self, p2: &Self, ); unsafe fn double_nonidentity<const CHECK_SETUP: bool>(&self) -> Self; unsafe fn double_assign_nonidentity<const CHECK_SETUP: bool>(&mut self); // Provided methods unsafe fn from_xy(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self> where for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate> { ... } unsafe fn from_xy_nonidentity( x: Self::Coordinate, y: Self::Coordinate, ) -> Option<Self> where for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate> { ... }
}
Expand description

Short Weierstrass curve affine point.

Required Associated Constants§

Source

const CURVE_A: Self::Coordinate

The a coefficient in the Weierstrass curve equation y^2 = x^3 + a x + b.

Source

const CURVE_B: Self::Coordinate

The b coefficient in the Weierstrass curve equation y^2 = x^3 + a x + b.

Source

const IDENTITY: Self

Required Associated Types§

Required Methods§

Source

fn as_le_bytes(&self) -> &[u8]

The concatenated x, y coordinates of the affine point, where coordinates are in little endian.

Warning: The memory layout of Self is expected to pack x and y contiguously with no unallocated space in between.

Source

unsafe fn from_xy_unchecked(x: Self::Coordinate, y: Self::Coordinate) -> Self

Raw constructor without asserting point is on the curve.

§Safety
  • Caller must guarantee (x, y) is a valid point on the curve and in any required subgroup.
  • Identity point must be represented by (0, 0).
Source

fn into_coords(self) -> (Self::Coordinate, Self::Coordinate)

Source

fn x(&self) -> &Self::Coordinate

Source

fn y(&self) -> &Self::Coordinate

Source

fn x_mut(&mut self) -> &mut Self::Coordinate

Source

fn y_mut(&mut self) -> &mut Self::Coordinate

Source

fn set_up_once()

Calls any setup required for this curve. The implementation should internally use OnceBool to ensure that setup is only called once.

Source

fn add_assign_impl<const CHECK_SETUP: bool>(&mut self, p2: &Self)

Add implementation that handles identity and whether points are equal or not.

§Safety
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

fn double_assign_impl<const CHECK_SETUP: bool>(&mut self)

Double implementation that handles identity.

§Safety
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

unsafe fn add_ne_nonidentity<const CHECK_SETUP: bool>(&self, p2: &Self) -> Self

§Safety
  • Assumes self != +- p2 and self != identity and p2 != identity.
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

unsafe fn add_ne_assign_nonidentity<const CHECK_SETUP: bool>( &mut self, p2: &Self, )

§Safety
  • Assumes self != +- p2 and self != identity and p2 != identity.
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

unsafe fn sub_ne_nonidentity<const CHECK_SETUP: bool>(&self, p2: &Self) -> Self

§Safety
  • Assumes self != +- p2 and self != identity and p2 != identity.
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

unsafe fn sub_ne_assign_nonidentity<const CHECK_SETUP: bool>( &mut self, p2: &Self, )

§Safety
  • Assumes self != +- p2 and self != identity and p2 != identity.
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

unsafe fn double_nonidentity<const CHECK_SETUP: bool>(&self) -> Self

§Safety
  • Assumes self != identity and 2 * self != identity.
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.
Source

unsafe fn double_assign_nonidentity<const CHECK_SETUP: bool>(&mut self)

§Safety
  • Assumes self != identity and 2 * self != identity.
  • If CHECK_SETUP is true, checks if setup has been called for this curve and if not, calls Self::set_up_once(). Only set CHECK_SETUP to false if you are sure that setup has been called already.

Provided Methods§

Source

unsafe fn from_xy(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self>
where for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate>,

Constructs a point on the curve, including the identity point.

§Safety
  • This constructor does not perform any subgroup checks and only guarantees that the point is on the curve.
Source

unsafe fn from_xy_nonidentity( x: Self::Coordinate, y: Self::Coordinate, ) -> Option<Self>
where for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate>,

Constructs a point on the curve, excluding the identity point.

§Safety
  • This constructor does not perform any subgroup checks and only guarantees that the point is a non-identity point on the curve.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§