Skip to main content

GroupElement

Trait GroupElement 

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

Source

type AlphaLen: ArraySize

Length of the Alpha value - a binary representation of the group element.

Required Methods§

Source

fn to_alpha(&self) -> Array<u8, Self::AlphaLen>

Converts the group element to a binary format suitable for representing the Alpha value.

Source

fn from_alpha(alpha: Array<u8, Self::AlphaLen>) -> Result<Self>

Converts the group element from the binary format representing an Alpha value.

Source

fn generate(scalar: &E) -> Self

Create a group element using the group generator and the given scalar

Source

fn is_valid(&self) -> bool

Group element is considered valid if it is not a neutral element and also not a torsion element of small order.

Provided Methods§

Source

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.

Source

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

type AlphaLen = UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>

Source§

fn to_alpha(&self) -> Array<u8, U32>

Source§

fn from_alpha(alpha: Array<u8, U32>) -> Result<Self>

Source§

fn generate(scalar: &Curve25519Scalar) -> Self

Source§

fn is_valid(&self) -> bool

Implementors§