Crate guff[][src]

Expand description

Grand Unified Finite Field library*

Implements GF(2x) for various “natural” sizes such as 28, 216 and 232.

Basic Use: doing maths in a particular field

As a user, the steps to take to use this library are:

  • decide what “class” of field you want to use (GF(28), GF(216), etc.);

  • decide if you want to use one of the optimised adaptations or are happy with the default, generic code;

  • create a new field object (we can call f) of that class with your chosen field polynomial (aka “irreducible polynomial”) by calling the appropriate constructor;

  • use that object to do maths in that field: eg, result = f.mul(a,b)

use guff::{GaloisField, F4};
 
fn main() {
    // create a GF(2<sup>4</sup>) field from a struct
    // * `19` is the field's irreducible polynomial
    // * `3` is the same value with bit 0x10 removed
    let f = guff::F4 { full : 19, compact : 3 };
     
    assert_eq!(f.pow(5,3), f.mul(5,f.mul(5,5)) );
}
 

Crate Name

* The crate name is deliberately hyperbolic:

Noun guff - unacceptable behavior (especially ludicrously false statements)

Structs

A type implementing maths in GF(24)

A type implementing maths in GF(28)

A type implementing maths in GF(216)

A type implementing maths in GF(232)

Traits

A typing trait meant to map to a primitive unsigned integer type such as u8, u16 or u32.

Collection of methods needed to implement maths in GF(2x). Provides (slow) default implementations that can be overriden by optimised versions.

Functions

Create a new GF(24) field from a given field polynomial

Create a new GF(28) field from a given field polynomial

Create a new GF(216) field from a given field polynomial

Create a new GF(232) field from a given field polynomial