Trait elastic_elgamal::group::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 Types§
sourcetype 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
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§
sourceconst ELEMENT_SIZE: usize
const ELEMENT_SIZE: usize
Byte size of a serialized Self::Element
.
Required Methods§
sourcefn identity() -> Self::Element
fn identity() -> Self::Element
Returns the identity of the group (aka point at infinity for EC groups).
sourcefn is_identity(element: &Self::Element) -> bool
fn is_identity(element: &Self::Element) -> bool
Checks if the specified element is the identity.
sourcefn serialize_element(element: &Self::Element, output: &mut [u8])
fn serialize_element(element: &Self::Element, output: &mut [u8])
Serializes element
into the provided buffer
, which is guaranteed to have length
Self::ELEMENT_SIZE
.
sourcefn deserialize_element(buffer: &[u8]) -> Option<Self::Element>
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.