elastic_elgamal::group

Trait Group

Source
pub trait Group:
    Copy
    + ScalarOps
    + ElementOps
    + 'static {
    // Provided methods
    fn mul_generator(k: &Self::Scalar) -> Self::Element { ... }
    fn vartime_mul_generator(k: &Self::Scalar) -> Self::Element { ... }
    fn multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element
       where I: IntoIterator<Item = &'a Self::Scalar>,
             J: IntoIterator<Item = Self::Element> { ... }
    fn vartime_double_mul_generator(
        k: &Self::Scalar,
        k_element: Self::Element,
        r: &Self::Scalar,
    ) -> Self::Element { ... }
    fn vartime_multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element
       where I: IntoIterator<Item = &'a Self::Scalar>,
             J: IntoIterator<Item = Self::Element> { ... }
}
Expand description

Prime-order group in which the discrete log problem and decisional / computational Diffie–Hellman problems are believed to be hard.

Groups conforming to this trait can be used for ElGamal encryption and other cryptographic protocols defined in this crate.

This crate provides the following implementations of this trait:

  • Curve25519Subgroup, representation of a prime-order subgroup of Curve25519 with the conventionally chosen generator.
  • Ristretto, a transform of Curve25519 which eliminates its co-factor 8 with the help of the eponymous technique.
  • Generic implementation defined in terms of traits from the elliptic-curve crate. (For example, this means secp256k1 support via the k256 crate.)

Provided Methods§

Source

fn mul_generator(k: &Self::Scalar) -> Self::Element

Multiplies the provided scalar by ElementOps::generator(). This operation must be constant-time.

§Default implementation

Implemented using Mul (which is constant-time as per the ElementOps contract).

Source

fn vartime_mul_generator(k: &Self::Scalar) -> Self::Element

Multiplies the provided scalar by ElementOps::generator(). Unlike Self::mul_generator(), this operation does not need to be constant-time; thus, it may employ additional optimizations.

§Default implementation

Implemented by calling Self::mul_generator().

Source

fn multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element
where I: IntoIterator<Item = &'a Self::Scalar>, J: IntoIterator<Item = Self::Element>,

Multiplies provided scalars by elements. This operation must be constant-time w.r.t. the given length of elements.

§Default implementation

Implemented by straightforward computations, which are constant-time as per the ElementOps contract.

Source

fn vartime_double_mul_generator( k: &Self::Scalar, k_element: Self::Element, r: &Self::Scalar, ) -> Self::Element

Calculates k * k_element + r * G, where G is the group generator. This operation does not need to be constant-time.

§Default implementation

Implemented by straightforward arithmetic.

Source

fn vartime_multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element
where I: IntoIterator<Item = &'a Self::Scalar>, J: IntoIterator<Item = Self::Element>,

Multiplies provided scalars by elements. Unlike Self::multi_mul(), this operation does not need to be constant-time; thus, it may employ additional optimizations.

§Default implementation

Implemented by calling Self::multi_mul().

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 Curve25519Subgroup

Source§

impl Group for Ristretto

Source§

impl<C> Group for Generic<C>
where C: CurveArithmetic + 'static, Scalar<C>: Zeroize, FieldBytesSize<C>: ModulusSize, ProjectivePoint<C>: ToEncodedPoint<C> + FromEncodedPoint<C>,