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 theelliptic-curve
crate. (For example, this means secp256k1 support via thek256
crate.)
Provided Methods§
Sourcefn mul_generator(k: &Self::Scalar) -> Self::Element
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).
Sourcefn vartime_mul_generator(k: &Self::Scalar) -> Self::Element
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()
.
Sourcefn multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element
fn multi_mul<'a, I, J>(scalars: I, elements: J) -> 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.
Sourcefn vartime_double_mul_generator(
k: &Self::Scalar,
k_element: Self::Element,
r: &Self::Scalar,
) -> Self::Element
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.
Sourcefn vartime_multi_mul<'a, I, J>(scalars: I, elements: J) -> Self::Element
fn vartime_multi_mul<'a, I, J>(scalars: I, elements: J) -> 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.