Skip to main content

Group

Trait Group 

pub trait Group: Copy + 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> + Send + Sync;
    type Serialization: Clone + AsRef<[u8]> + AsMut<[u8]> + for<'a> TryFrom<&'a [u8]> + Debug;

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

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.

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

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

type Serialization: Clone + AsRef<[u8]> + AsMut<[u8]> + for<'a> TryFrom<&'a [u8]> + Debug

A unique byte array buf of fixed length N.

Little-endian!

Required Methods§

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.

fn identity() -> Self::Element

Additive identity of the prime order group.

fn generator() -> Self::Element

The fixed generator element of the prime order group.

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

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

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§

Source§

impl Group for PallasGroup

Source§

type Element = Projective<PallasParameters>

Source§

type Field = PallasScalarField

Source§

type Serialization = [u8; 96]