Algebra
Groups are algebraic structures which are set and has a binary operation that combines two elements of the set to produce a third element in the set. The operation is said to have following properties:
- Closure:
- Associative:
- Existence of Identity element:
- Existence of inverse element for every element of the set:
- Commutativity: Groups which satisfy an additional property: commutativity on the set of elements are known as Abelian groups, .
Examples:
- is a group under addition defined as
- is a finite group under multiplication
- Equilateral triangles for a non-abelian group of order 6 under symmetry.
- Invertible form a non-abelian group under multiplication.
Rings are algebraic structures with two binary operations satisfying the following properties:
- Abelian group under +
- Monoid under
- Distributive with respect to
Examples:
- form a ring
- a polynomial with integer coefficients: satisfy ring axioms
Fields are algebraic structures with two binary operations such that:
- Abelian group under
- Non-zero numbers form abelian group under
- Multiplicative distribution over
Fields can also be defined as commutative ring with existence of inverse under . Thus, every Field can be classified as Ring.
Examples:
- , i.e. set of rational, real and complex numbers are all Fields.
- is not a field.
- form a finite field under modulo addition and multiplication.
Finite fields are field with a finite order and are instrumental in cryptographic systems. They are used in elliptic curve cryptography, RSA, and many other cryptographic systems. This module provides a generic implementation of finite fields via two traits and two structs. It is designed to be easy to use and understand, and to be flexible enough to extend yourself.
Constant (Compile Time) Implementations
Note that traits defined in this module are tagged with #[const_trait]
which implies that each method and associated constant is implemented at compile time.
This is done purposefully as it allows for generic implementations of these fields to be constructed when you compile ronkathon
rather than computed at runtime.
In principle, this means the code runs faster, but will compile slower, but the tradeoff is that the cryptographic system is faster and extensible.