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] ⓘ;
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
fn from_xy(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self>
where for<'a> &'a Self::Coordinate: Mul<&'a Self::Coordinate, Output = Self::Coordinate> { ... }
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§
Sourceconst CURVE_A: Self::Coordinate
const CURVE_A: Self::Coordinate
The a
coefficient in the Weierstrass curve equation y^2 = x^3 + a x + b
.
Sourceconst CURVE_B: Self::Coordinate
const CURVE_B: Self::Coordinate
The b
coefficient in the Weierstrass curve equation y^2 = x^3 + a x + b
.
const IDENTITY: Self
Required Associated Types§
type Coordinate: Field
Required Methods§
Sourcefn as_le_bytes(&self) -> &[u8] ⓘ
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.
Sourcefn from_xy_unchecked(x: Self::Coordinate, y: Self::Coordinate) -> Self
fn from_xy_unchecked(x: Self::Coordinate, y: Self::Coordinate) -> Self
Raw constructor without asserting point is on the curve.
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
Sourcefn set_up_once()
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.
Sourcefn add_assign_impl<const CHECK_SETUP: bool>(&mut self, p2: &Self)
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourcefn double_assign_impl<const CHECK_SETUP: bool>(&mut self)
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourceunsafe fn add_ne_nonidentity<const CHECK_SETUP: bool>(&self, p2: &Self) -> Self
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourceunsafe fn add_ne_assign_nonidentity<const CHECK_SETUP: bool>(
&mut self,
p2: &Self,
)
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourceunsafe fn sub_ne_nonidentity<const CHECK_SETUP: bool>(&self, p2: &Self) -> Self
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourceunsafe fn sub_ne_assign_nonidentity<const CHECK_SETUP: bool>(
&mut self,
p2: &Self,
)
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourceunsafe fn double_nonidentity<const CHECK_SETUP: bool>(&self) -> Self
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Sourceunsafe fn double_assign_nonidentity<const CHECK_SETUP: bool>(&mut self)
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, callsSelf::set_up_once()
. Only setCHECK_SETUP
tofalse
if you are sure that setup has been called already.
Provided Methods§
fn from_xy(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self>
fn from_xy_nonidentity(x: Self::Coordinate, y: Self::Coordinate) -> Option<Self>
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.