Trait guff::GaloisField [−][src]
pub trait GaloisField { type E: ElementStore; type EE: ElementStore; const ORDER: u16; const HIGH_BIT: Self::E; const POLY_BIT: Self::EE; const FIELD_MASK: Self::E; fn poly(&self) -> Self::E; fn full_poly(&self) -> Self::EE; fn add(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn sub(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn mul(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn div(&self, a: Self::E, b: Self::E) -> Self::E { ... } fn inv(&self, a: Self::E) -> Self::E { ... } fn pow(&self, a: Self::E, b: Self::EE) -> Self::E { ... } fn high_bit(&self) -> Self::E { ... } fn order(&self) -> u16 { ... } fn field_mask(&self) -> Self::E { ... } }
Expand description
Collection of methods needed to implement maths in GF(2x). Provides (slow) default implementations that can be overriden by optimised versions.
Associated Types
type E: ElementStore
type E: ElementStore
Natural storage class (u8, u16, u32, etc.) for storing elements of the field.
type EE: ElementStore
type EE: ElementStore
The next largest natural storage class, eg if E is u8, then EE should be U16. Used for:
-
storing/returning field polynomial, which is always larger than the largest field element
-
storing the result of a non-modular (overflowing) multiply of two field elements
Associated Constants
const FIELD_MASK: Self::E
const FIELD_MASK: Self::E
Mask for selecting all bits of field value, eg GF(28) → 0xff
Required methods
Provided methods
Polynomial multiplication modulo the field polynomial
Division modulo to the field polynomial (default implementation calculated as a・b-1
Calculate polynomial a・b-1 modulo the field polynomial (using Extended Euclidean method)
fn field_mask(&self) -> Self::E
fn field_mask(&self) -> Self::E
Access Self::FIELD_MASK as a method