pub trait GroupElement<E: Scalar>: Clone + for<'a> Mul<&'a E, Output = Self> {
type AlphaLen: ArraySize;
// Required methods
fn to_alpha(&self) -> Array<u8, Self::AlphaLen>;
fn from_alpha(alpha: Array<u8, 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, context: &str, 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) -> Array<u8, Self::AlphaLen>
fn to_alpha(&self) -> Array<u8, Self::AlphaLen>
Converts the group element to a binary format suitable for representing the Alpha value.
Sourcefn from_alpha(alpha: Array<u8, Self::AlphaLen>) -> Result<Self>
fn from_alpha(alpha: Array<u8, 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, context: &str, salt: &[u8]) -> SharedSecret
fn extract_key(&self, context: &str, salt: &[u8]) -> SharedSecret
Extract a keying material from a group element using a KDF
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl GroupElement<Scalar> for Curve25519Point
Available on crate feature ed25519 only.
impl GroupElement<Scalar> for Curve25519Point
Available on crate feature
ed25519 only.