Trait CofactorGroup
pub trait CofactorGroup:
Group
+ GroupEncoding
+ GroupOps<Self::Subgroup>
+ GroupOpsOwned<Self::Subgroup> {
type Subgroup: PrimeGroup<Scalar = Self::Scalar> + Into<Self>;
// Required methods
fn clear_cofactor(&self) -> Self::Subgroup;
fn into_subgroup(self) -> CtOption<Self::Subgroup>;
fn is_torsion_free(&self) -> Choice;
// Provided method
fn is_small_order(&self) -> Choice { ... }
}Expand description
This trait represents an element of a cryptographic group with a large prime-order subgroup and a comparatively-small cofactor.
Required Associated Types§
Required Methods§
fn clear_cofactor(&self) -> Self::Subgroup
fn clear_cofactor(&self) -> Self::Subgroup
Maps self to the prime-order subgroup by multiplying this element by some
k-multiple of the cofactor.
The value k does not vary between inputs for a given implementation, but may
vary between different implementations of CofactorGroup because some groups have
more efficient methods of clearing the cofactor when k is allowed to be
different than 1.
If Self implements [PrimeGroup], this returns self.
fn into_subgroup(self) -> CtOption<Self::Subgroup>
fn into_subgroup(self) -> CtOption<Self::Subgroup>
Returns self if it is contained in the prime-order subgroup.
If Self implements [PrimeGroup], this returns Some(self).
fn is_torsion_free(&self) -> Choice
fn is_torsion_free(&self) -> Choice
Determines if this element is “torsion free”, i.e., is contained in the prime-order subgroup.
Returns:
trueifselfhas trivial torsion and is in the prime-order subgroup.falseifselfhas non-zero torsion component and is not in the prime-order subgroup.
Provided Methods§
fn is_small_order(&self) -> Choice
fn is_small_order(&self) -> Choice
Determines if this element is of small order.
Returns:
trueifselfis in the torsion subgroup.falseifselfis not in the torsion subgroup.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
§impl CofactorGroup for ProjectivePoint
secp256k1 has a cofactor of 1.
impl CofactorGroup for ProjectivePoint
secp256k1 has a cofactor of 1.
type Subgroup = ProjectivePoint
fn clear_cofactor(&self) -> <ProjectivePoint as CofactorGroup>::Subgroup
fn into_subgroup(self) -> CtOption<<ProjectivePoint as CofactorGroup>::Subgroup>
fn is_torsion_free(&self) -> Choice
§impl CofactorGroup for ProjectivePoint
impl CofactorGroup for ProjectivePoint
§fn clear_cofactor(&self) -> <ProjectivePoint as CofactorGroup>::Subgroup
fn clear_cofactor(&self) -> <ProjectivePoint as CofactorGroup>::Subgroup
Maps any curve point onto the prime-order subgroup by multiplying it by
the cofactor 8 (i.e. k = 1 times the cofactor).
BabyJubJub has cofactor 8, so every point splits uniquely as P = Q + T
with Q in the prime-order subgroup and T a torsion point of order
dividing 8. Because [8]T = O, the result [8]P = [8]Q always lies in
the prime-order subgroup; it is the identity exactly when Q = O (i.e.
when P is pure torsion).
Implemented as three doublings ([8]P = [2][2][2]P) on the backend’s
complete (exception-free) doubling formula, which accepts torsion inputs
(as do Group::double and the + operator). Like the rest of the
crate this is almost — but not end-to-end — constant-time (see the
crate-level Security notes). To clear the cofactor and multiply by a
scalar in a single operation, use [ProjectivePoint::mul_with_cofactor_clear].
§fn into_subgroup(self) -> CtOption<<ProjectivePoint as CofactorGroup>::Subgroup>
fn into_subgroup(self) -> CtOption<<ProjectivePoint as CofactorGroup>::Subgroup>
Returns self if it lies in the prime-order subgroup, otherwise
CtOption::none().
Membership is decided by [ProjectivePoint::is_in_prime_order_subgroup],
which normalizes to affine via a field inversion and is therefore not
constant-time with respect to self.
§fn is_torsion_free(&self) -> Choice
fn is_torsion_free(&self) -> Choice
Returns true iff this element is torsion free, i.e. lies in the
prime-order subgroup.
Delegates to [ProjectivePoint::is_in_prime_order_subgroup]. As noted
there, this normalizes to affine coordinates and is not constant-time
with respect to self.
type Subgroup = ProjectivePoint
§impl<C> CofactorGroup for ProjectivePoint<C>where
C: PrimeCurveParams,
Prime order elliptic curves have a cofactor of 1.
impl<C> CofactorGroup for ProjectivePoint<C>where
C: PrimeCurveParams,
Prime order elliptic curves have a cofactor of 1.