pub trait ElementOps: ScalarOps {
    type Element: Copy + Add<Output = Self::Element> + Sub<Output = Self::Element> + Neg<Output = Self::Element> + for<'a> Mul<&'a Self::Scalar, Output = Self::Element> + PartialEq + Debug;

    const ELEMENT_SIZE: usize;

    // Required methods
    fn identity() -> Self::Element;
    fn is_identity(element: &Self::Element) -> bool;
    fn generator() -> Self::Element;
    fn serialize_element(element: &Self::Element, output: &mut [u8]);
    fn deserialize_element(buffer: &[u8]) -> Option<Self::Element>;
}
Expand description

Helper trait for Group that describes operations on group elements (i.e., EC points for elliptic curve groups).

Required Associated Types§

source

type Element: Copy + Add<Output = Self::Element> + Sub<Output = Self::Element> + Neg<Output = Self::Element> + for<'a> Mul<&'a Self::Scalar, Output = Self::Element> + PartialEq + Debug

Element of the group. Arithmetic operations requested here (addition among elements and multiplication by a Scalar) must be constant-time.

Required Associated Constants§

source

const ELEMENT_SIZE: usize

Byte size of a serialized Self::Element.

Required Methods§

source

fn identity() -> Self::Element

Returns the identity of the group (aka point at infinity for EC groups).

source

fn is_identity(element: &Self::Element) -> bool

Checks if the specified element is the identity.

source

fn generator() -> Self::Element

Returns the agreed-upon generator of the group.

source

fn serialize_element(element: &Self::Element, output: &mut [u8])

Serializes element into the provided buffer, which is guaranteed to have length Self::ELEMENT_SIZE.

source

fn deserialize_element(buffer: &[u8]) -> Option<Self::Element>

Deserializes an element from buffer, which is guaranteed to have length Self::ELEMENT_SIZE. This method returns None if the buffer does not correspond to a representation of a valid scalar.

Object Safety§

This trait is not object safe.

Implementors§

source§

impl ElementOps for Curve25519Subgroup

§

type Element = EdwardsPoint

source§

const ELEMENT_SIZE: usize = 32usize

source§

impl ElementOps for Ristretto

§

type Element = RistrettoPoint

source§

const ELEMENT_SIZE: usize = 32usize

source§

impl<C> ElementOps for Generic<C>
where C: CurveArithmetic, Scalar<C>: Zeroize, FieldBytesSize<C>: ModulusSize, ProjectivePoint<C>: ToEncodedPoint<C> + FromEncodedPoint<C>,

§

type Element = <C as CurveArithmetic>::ProjectivePoint

source§

const ELEMENT_SIZE: usize = _