Skip to main content

Group

Trait Group 

Source
pub trait Group:
    Sized
    + Clone
    + Copy
    + Debug
    + Eq
    + Send
    + Sync
    + 'static
    + Sum
    + for<'a> Sum<&'a Self>
    + Neg<Output = Self>
    + GroupOps
    + GroupOpsOwned
    + ScalarMul<Self::Scalar>
    + ScalarMulOwned<Self::Scalar> {
    type Scalar: PrimeField;

    // Required methods
    fn try_random<R>(rng: &mut R) -> Result<Self, <R as TryRng>::Error>
       where R: TryRng + ?Sized;
    fn identity() -> Self;
    fn generator() -> Self;
    fn is_identity(&self) -> Choice;
    fn double(&self) -> Self;

    // Provided methods
    fn random<R>(rng: &mut R) -> Self
       where R: Rng + ?Sized { ... }
    fn mul_by_generator(scalar: &Self::Scalar) -> Self { ... }
}
Expand description

This trait represents an element of a cryptographic group.

Required Associated Types§

Source

type Scalar: PrimeField

Scalars modulo the order of this group’s scalar field.

Required Methods§

Source

fn try_random<R>(rng: &mut R) -> Result<Self, <R as TryRng>::Error>
where R: TryRng + ?Sized,

Returns an element chosen uniformly at random from the non-identity elements of this group using a user-provided fallible RNG.

Returns Err propagating the RNG’s error if the underlying RNG fails to produce the randomness required to sample an element. Implementors of Group must provide this method; Group::random is derived from it for infallible RNGs.

Source

fn identity() -> Self

Returns the additive identity, also known as the “neutral element”.

Source

fn generator() -> Self

Returns a fixed generator of the prime-order subgroup.

Source

fn is_identity(&self) -> Choice

Determines if this point is the identity.

Source

fn double(&self) -> Self

Doubles this element.

Provided Methods§

Source

fn random<R>(rng: &mut R) -> Self
where R: Rng + ?Sized,

Returns an element chosen uniformly at random from the non-identity elements of this group using a user-provided infallible RNG.

This is a convenience wrapper around Group::try_random for RNGs that cannot fail. Use Group::try_random if your RNG may fail (for example, an OS-backed entropy source).

Source

fn mul_by_generator(scalar: &Self::Scalar) -> Self

Multiply by the generator of the prime-order subgroup.

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§