[−][src]Trait g2p::GaloisField
Common trait for finite fields
All types generated by g2p! implement this trait.
The trait ensures that all the expected operations of a finite field are implemented.
In addition, some often used constants like ONE and ZERO are exported, as well as the more
esoteric GENERATOR.
Associated Constants
const SIZE: usize
Number of elements in the field
const ZERO: Self
The value 0 as a finite field constant
const ONE: Self
The value 1 as a finite field constant
const GENERATOR: Self
A generator of the multiplicative group of a finite field
The powers of this element will generate all non-zero elements of the finite field
use g2p::{GaloisField, g2p}; g2p!(GF4, 2); let g = GF4::GENERATOR; assert_ne!(g, GF4::ONE); assert_ne!(g * g, GF4::ONE); assert_eq!(g * g * g, GF4::ONE);
const MODULUS: G2Poly
Polynomial representation of the modulus used to generate the field
Provided methods
fn pow(self, p: usize) -> Self
Calculate the p-th power of a value
Calculate the value of x to the power p in finite field arithmethic
Example
use g2p::{GaloisField, g2p}; g2p!(GF16, 4); let g: GF16 = 2.into(); assert_eq!(g.pow(0), GF16::ONE); assert_eq!(g.pow(1), g); assert_eq!(g.pow(2), 4.into()); assert_eq!(g.pow(3), 8.into()); assert_eq!(g.pow(4), 3.into());