Trait guff::GaloisField[][src]

pub trait GaloisField where
    Self::EE: From<Self::E>, 
{ type E: ElementStore; type EE: ElementStore; type SEE: ElementStore; const ORDER: u16; const HIGH_BIT: Self::E; const POLY_BIT: Self::EE; const FIELD_MASK: Self::E;
Show methods 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
    where
        Self::E: Into<Self::EE>
, { ... }
fn vec_sum_elements(&self, v: &[Self::E]) -> Self::E { ... }
fn vec_add_vec_in_place(&self, dest: &mut [Self::E], other: &[Self::E]) { ... }
fn vec_add_vecs_giving_other(
        &self,
        dest: &mut [Self::E],
        a: &[Self::E],
        b: &[Self::E]
    ) { ... }
fn vec_cross_product(
        &self,
        dest: &mut [Self::E],
        a: &[Self::E],
        b: &[Self::E]
    ) { ... }
fn vec_dot_product(&self, a: &[Self::E], b: &[Self::E]) -> Self::E { ... }
fn vec_constant_scale_in_place(&self, dest: &mut [Self::E], a: Self::E) { ... }
fn vec_fma_in_place(&self, dest: &mut [Self::E], a: Self::E, b: 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

Natural storage class (u8, u16, u32, etc.) for storing elements of the field.

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

As EE, but signed. Used internally to implement some lookup tables.

Associated Constants

Size of the field in bits, eg GF(28) → 8

High bit of field values, eg GF(28) → 0x80

High bit of field polynomial, eg GF(28) → 0x100

Mask for selecting all bits of field value, eg GF(28) → 0xff

Required methods

The field polynomial with (implicit) high bit stripped off.

Field polynomial in full, with high poly bit set

Provided methods

Addition in Galois Fields GF(2x) is simply XOR

Subtraction is the same as addition in GF(2x)

Polynomial multiplication modulo the field polynomial

Division modulo to the field polynomial (default implementation calculated as a・b-1)

Calculate polynomial a-1 modulo the field polynomial (using Extended Euclidean method)

Calculate polynomial ab modulo the field polynomial

Access Self::HIGH_BIT as a method

Access Self::ORDER as a method

Access Self::FIELD_MASK as a method

Implementors