elastic_elgamal::group

Trait ElementOps

Source
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 Constants§

Source

const ELEMENT_SIZE: usize

Byte size of a serialized Self::Element.

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 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.

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§

Source§

impl ElementOps for Curve25519Subgroup

Source§

const ELEMENT_SIZE: usize = 32usize

Source§

type Element = EdwardsPoint

Source§

impl ElementOps for Ristretto

Source§

const ELEMENT_SIZE: usize = 32usize

Source§

type Element = RistrettoPoint

Source§

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

Source§

const ELEMENT_SIZE: usize = _

Source§

type Element = <C as CurveArithmetic>::ProjectivePoint