Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions py_ecc/optimized_bn128/optimized_field_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ def __sub__(self, other: IntOrFQ) -> "FQ":
on = other.n if isinstance(other, FQ) else other
return FQ((self.n - on) % field_modulus)

def __mod__(self, other: Union[int, "FQ"]) -> "FQ":
return self.__mod__(other)

def __div__(self, other: IntOrFQ) -> "FQ":
on = other.n if isinstance(other, FQ) else other
assert isinstance(on, int)
Expand Down Expand Up @@ -171,6 +174,9 @@ def __sub__(self, other: "FQP") -> "FQP":
in zip(self.coeffs, other.coeffs)
])

def __mod__(self, other: Union[int, "FQP"]) -> "FQP":
return self.__mod__(other)

def __mul__(self, other: Union[int, "FQP"]) -> "FQP":
if isinstance(other, int):
return type(self)([int(c) * other % field_modulus for c in self.coeffs])
Expand Down