PrimeOrderCurve

Trait PrimeOrderCurve 

Source
pub trait PrimeOrderCurve:
    Copy
    + Clone
    + Sized
    + Send
    + Sync
    + Debug
    + Eq
    + 'static
    + Neg<Output = Self>
    + Mul<Self::Scalar, Output = Self>
    + Add<Self, Output = Self>
    + Sub<Self, Output = Self>
    + AddAssign<Self>
    + SubAssign<Self>
    + MulAssign<Self::Scalar>
    + Serialize
    + for<'de> Deserialize<'de>
    + Zeroizable {
    type Scalar: Field;
    type Base: Field;

    const UNCOMPRESSED_CURVE_POINT_BYTEWIDTH: usize;
    const COMPRESSED_CURVE_POINT_BYTEWIDTH: usize;
    const SCALAR_ELEM_BYTEWIDTH: usize;
Show 13 methods // Required methods fn zero() -> Self; fn generator() -> Self; fn random(rng: impl RngCore) -> Self; fn double(&self) -> Self; fn projective_coordinates(&self) -> (Self::Base, Self::Base, Self::Base); fn affine_coordinates(&self) -> Option<(Self::Base, Self::Base)>; fn to_bytes_uncompressed(&self) -> Vec<u8> ; fn to_bytes_compressed(&self) -> Vec<u8> ; fn from_bytes_uncompressed(bytes: &[u8]) -> Self; fn from_bytes_compressed(bytes: &[u8]) -> Self; fn from_xy(x: Self::Base, y: Self::Base) -> Self; fn from_x_and_sign_y(x: Self::Base, y_sign: u8) -> Self; fn scalar_mult_unsigned_integer<T: Unsigned + Zero + ToBytes>( &self, scalar: &T, ) -> Self;
}
Expand description

Minimal interface for an elliptic curve of prime order.

Required Associated Constants§

Required Associated Types§

Source

type Scalar: Field

The scalar field of the curve.

Source

type Base: Field

The base field of the curve.

Required Methods§

Source

fn zero() -> Self

Return the additive identity of the curve.

Source

fn generator() -> Self

Return the chosen generator of the curve.

Source

fn random(rng: impl RngCore) -> Self

Returns an element chosen uniformly at random.

Source

fn double(&self) -> Self

Return the point doubled.

Source

fn projective_coordinates(&self) -> (Self::Base, Self::Base, Self::Base)

Return the projective coordinates of the point.

Source

fn affine_coordinates(&self) -> Option<(Self::Base, Self::Base)>

Return the affine coordinates of the point, if it is not at the identity (in which case, return None).

Source

fn to_bytes_uncompressed(&self) -> Vec<u8>

Returns an uncompressed byte representation of a curve element.

Source

fn to_bytes_compressed(&self) -> Vec<u8>

Returns a compressed byte representation of a curve element. TODO!(ryancao): Should we also have a self type representing the bitwidth?

Source

fn from_bytes_uncompressed(bytes: &[u8]) -> Self

Returns the unique curve element represented by the uncompressed bytestring.

Source

fn from_bytes_compressed(bytes: &[u8]) -> Self

Returns the unique curve element represented by the compressed bytestring.

Source

fn from_xy(x: Self::Base, y: Self::Base) -> Self

Returns the group element from x and y coordinates.

Source

fn from_x_and_sign_y(x: Self::Base, y_sign: u8) -> Self

Returns the group element from x coordinate + parity of y.

Source

fn scalar_mult_unsigned_integer<T: Unsigned + Zero + ToBytes>( &self, scalar: &T, ) -> Self

An optimized version of scalar multiplication when the scalar element fits within 128 bits.

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§