Skip to content

Instantly share code, notes, and snippets.

@enigbe
Created February 12, 2022 10:15
Show Gist options
  • Save enigbe/05c233830819c1c045a9ad270fcae93e to your computer and use it in GitHub Desktop.
Save enigbe/05c233830819c1c045a9ad270fcae93e to your computer and use it in GitHub Desktop.
Finite field element
class FiniteFieldElement:
"""An element belonging to a finite set"""
def __init__(self, eleemnt: int, order: int) -> "FieldElement":
"""
Initializes a FiniteElement
Args:
element (int): a number belonging to the set, e.g. 5
order (int): depicting the size of the set e.g 7
Returns:
FieldElement
"""
if element >= order or num < 0:
error = f'Element {element} not in the finite field range of 0 to {order - 1}'
raise ValueError(error)
self.element = element
self.order = order
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment