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§
Sourceconst ELEMENT_SIZE: usize
const ELEMENT_SIZE: usize
Byte size of a serialized Self::Element
.
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 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.
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.