pub trait GroupElement<E: Scalar>: Clone + for<'a> Mul<&'a E, Output = Self> {
type AlphaLen: ArrayLength<u8>;
// Required methods
fn to_alpha(&self) -> Alpha<Self::AlphaLen>;
fn from_alpha(alpha: Alpha<Self::AlphaLen>) -> Result<Self>;
fn generate(scalar: &E) -> Self;
fn is_valid(&self) -> bool;
// Provided methods
fn random_pair() -> (Self, E) { ... }
fn extract_key(&self, salt: &[u8]) -> SharedSecret { ... }
fn expand_key(&self, salt: &[u8]) -> SharedSecret { ... }
}
Expand description
Generic additive abelian group element with an associated scalar type. It also comes with the associated Alpha value size. A group element is considered valid if it is not neutral or a torsion element of small order.
Required Associated Types§
Required Methods§
Sourcefn to_alpha(&self) -> Alpha<Self::AlphaLen>
fn to_alpha(&self) -> Alpha<Self::AlphaLen>
Converts the group element to a binary format suitable for representing the Alpha value.
Sourcefn from_alpha(alpha: Alpha<Self::AlphaLen>) -> Result<Self>
fn from_alpha(alpha: Alpha<Self::AlphaLen>) -> Result<Self>
Converts the group element from the binary format representing an Alpha value.
Provided Methods§
Sourcefn random_pair() -> (Self, E)
fn random_pair() -> (Self, E)
Generates a random pair of group element and secret scalar.
This is a convenience method that internally calls the random
method of the associated Scalar
and constructs the group element using generate
.
Sourcefn extract_key(&self, salt: &[u8]) -> SharedSecret
fn extract_key(&self, salt: &[u8]) -> SharedSecret
Extract a keying material from a group element using HKDF extract
Sourcefn expand_key(&self, salt: &[u8]) -> SharedSecret
fn expand_key(&self, salt: &[u8]) -> SharedSecret
Performs KDF expansion from the given group element using HKDF expand
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.