🕓Galois Fields
Galois Fields (aka Finite Fields)
A Galois field is finite set of elements and two operations (addition) and (multiplication), with the following properties:
Closure: if and are in the set, and are also in the set.
Additive identity:
Multiplicative identity:
Additive inverse:
Multiplicative inverse:
Field size is the number of elements in the set.
Let's define a PrimeGaloisField class that contains the intrinsic property of a finite field, prime. We also define a membership rule for a value in a given finite field, by overriding the __contains__ method.
@dataclass
class PrimeGaloisField:
prime: int
def __contains__(self, field_element: "FieldElement") -> bool:
# called whenever you do: <FieldElement> in <PrimeGaloisField>
return 0 <= field_element.value < self.primeLet's also define a FieldElement class to make sure all mathematical operations are contained within a given PrimeGaloisField.
Last updated
Was this helpful?