[][src]Crate isochronous_finite_fields

This crate implements finite field arithmetic on finite fields with 28 elements, often denoted as GF(28), in an isochronous manner. This means that it will always run in the same amount of time, no matter the input.

The implementation isochronous, because it:

  • is branch free
  • runs in constant time
  • doesn't do table lookups

This crate uses the irreducible polynomial x8 + x4 + x3 + x + 1 for multiplication, as standardized for the AES algorithm in FIPS 197.

Example

// Add two elements of the Galois field GF(2^8) together.
assert_eq!(GF(5) + GF(12), GF(9));

// Subtract two elements of the Galois field GF(2^8).
assert_eq!(GF(32) - GF(219), GF(251));

// Multiply two elements of the Galois field GF(2^8) together.
assert_eq!(GF(175) * GF(47),  GF(83));

// Calculate the multiplicative inverse of GF(110) in the Galois field GF(2^8).
assert_eq!(GF(110).multiplicative_inverse(), GF(33));
assert_eq!(GF(110) * GF(33), GF(1));

Structs

GF

Galois field wrapper struct.