Group

Trait Group 

Source
pub trait Group:
    Copy
    + Clone
    + PartialEq {
    type Field: Field;
    type Element: Add<Output = Self::Element> + Copy + Clone + Eq + Mul<<Self::Field as Field>::Scalar, Output = Self::Element> + PartialEq + Sub<Output = Self::Element>;
    type Serialization: AsRef<[u8]> + Debug + TryFrom<Vec<u8>>;

    // Required methods
    fn cofactor() -> <Self::Field as Field>::Scalar;
    fn identity() -> Self::Element;
    fn generator() -> Self::Element;
    fn serialize(
        element: &Self::Element,
    ) -> Result<Self::Serialization, GroupError>;
    fn deserialize(
        buf: &Self::Serialization,
    ) -> Result<Self::Element, GroupError>;
}
Expand description

A prime-order group (or subgroup) that provides everything we need to create and verify Schnorr signatures.

This trait does not have to be implemented for the curve/element/point itself, it can be a pass-through, implemented for a type just for the ciphersuite, and calls through to another implementation underneath, so that this trait does not have to be implemented for types you don’t own.

Required Associated Types§

Source

type Field: Field

A prime order finite field GF(q) over which all scalar values for our prime order group can be multiplied are defined.

Source

type Element: Add<Output = Self::Element> + Copy + Clone + Eq + Mul<<Self::Field as Field>::Scalar, Output = Self::Element> + PartialEq + Sub<Output = Self::Element>

An element of our group that we will be computing over.

Source

type Serialization: AsRef<[u8]> + Debug + TryFrom<Vec<u8>>

A unique byte array buf of fixed length N.

Little-endian!

Required Methods§

Source

fn cofactor() -> <Self::Field as Field>::Scalar

The order of the the quotient group when the prime order subgroup divides the order of the full curve group.

If using a prime order elliptic curve, the cofactor should be 1 in the scalar field.

Source

fn identity() -> Self::Element

Additive identity of the prime order group.

Source

fn generator() -> Self::Element

The fixed generator element of the prime order group.

The ‘base’ of [‘ScalarBaseMult()’] from the spec.

Source

fn serialize(element: &Self::Element) -> Result<Self::Serialization, GroupError>

A member function of a group G that maps an Element to a unique byte array buf of fixed length Ne. This function raises an error if the element is the identity element of the group.

https://datatracker.ietf.org/doc/html/rfc9591#section-3.1-4.12

Source

fn deserialize(buf: &Self::Serialization) -> Result<Self::Element, GroupError>

A member function of a Group that attempts to map a byte array buf to an Element.

Fails if the input is not a valid byte representation of an Element of the Group. This function can raise an Error if deserialization fails or if the resulting Element is the identity element of the group

https://datatracker.ietf.org/doc/html/rfc9591#section-3.1-4.14

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.

Implementors§