### 2 stable releases

1.0.1 | Aug 26, 2022 |
---|---|

1.0.0 | Feb 9, 2020 |

#**908** in Algorithms

**MIT**license

13KB

151 lines

# Isochronous finite fields

This crate implements
finite field arithmetic
on finite fields with 2^{8} elements, often denoted as GF(2^{8}),
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
*x*^{8} + *x*^{4} + *x*^{3} + *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``)``)``;`

# License

This project is licensed under the MIT License - see the LICENSE file for details.