[−][src]Trait accumulator::group::Group
A mathematical group.
This trait allows the implementation of standard group routines:
- Identity
- Op (the fundamental group operation)
- Exponentiation
- Inverse (particularly where this is efficient to compute)
The TypeRep
trait lets us emulate type-level static fields, e.g. the modulus in an RSA group
or the discriminant in a class group.
Clients of this trait need to implement functions of the form *_
, which take in TypeRep
data as a parameter. Consumers use functions without the underscore: id
, op
, exp
, and
inv
.
Associated Types
type Elem: Clone + Debug + Eq + Hash + Sized + Send + Sync
The associated group element type for this group.
Required methods
fn id_(rep: &Self::Rep) -> Self::Elem
A group-specific wrapper for id
.
fn op_(rep: &Self::Rep, a: &Self::Elem, b: &Self::Elem) -> Self::Elem
A group-specific wrapper for op
.
fn inv_(rep: &Self::Rep, a: &Self::Elem) -> Self::Elem
A group-specific wrapper for inv
.
Provided methods
fn exp_(_rep: &Self::Rep, a: &Self::Elem, n: &Integer) -> Self::Elem
A group-specific wrapper for exp
, although it comes with a default implementation via
repeated squaring.
Specific implementations may provide more performant specializations as needed (e.g. Montgomery multiplication for RSA groups).
fn id() -> Self::Elem
Returns the identity element of the group.
fn op(a: &Self::Elem, b: &Self::Elem) -> Self::Elem
Applies the group operation to elements a
and b
and returns the result.
fn exp(a: &Self::Elem, n: &Integer) -> Self::Elem
Applies the group operation to a
and itself n
times and returns the result.
fn inv(a: &Self::Elem) -> Self::Elem
Returns the group inverse of a
.