Skip to content

Commit

Permalink
Fixes Typing errors for points at infinity (NoneTypes) (#89)
Browse files Browse the repository at this point in the history
* Fixes Typing errors for points at infinity (NoneTypes)

* type: ignore -> type: ignore[misc]

* Adds @hwwhww's mypy fixes.

* Apply @hwwhww's suggestion [] -> ()

Co-authored-by: Hsiao-Wei Wang <[email protected]>

Co-authored-by: Hsiao-Wei Wang <[email protected]>
  • Loading branch information
CarlBeek and hwwhww authored May 9, 2020
1 parent 50ee33a commit 3d7d64f
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
2 changes: 1 addition & 1 deletion py_ecc/fields/field_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ class FQP(object):

def __init__(self,
coeffs: Sequence[IntOrFQ],
modulus_coeffs: Sequence[IntOrFQ] = None) -> None:
modulus_coeffs: Sequence[IntOrFQ] = ()) -> None:
if self.field_modulus is None:
raise AttributeError("Field Modulus hasn't been specified")

Expand Down
2 changes: 1 addition & 1 deletion py_ecc/fields/optimized_field_elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ class FQP(object):

def __init__(self,
coeffs: Sequence[IntOrFQ],
modulus_coeffs: Sequence[IntOrFQ] = None) -> None:
modulus_coeffs: Sequence[IntOrFQ] = ()) -> None:
if self.field_modulus is None:
raise AttributeError("Field Modulus hasn't been specified")

Expand Down
5 changes: 3 additions & 2 deletions py_ecc/typing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import (
Optional,
Tuple,
TypeVar,
Union,
Expand Down Expand Up @@ -64,8 +65,8 @@
bls12_381_FQ2,
bls12_381_FQ12,
)
Point2D = Tuple[Field, Field]
Point3D = Tuple[Field, Field, Field]
Point2D = Optional[Tuple[Field, Field]] # Point at infinity is encoded as a None
Point3D = Optional[Tuple[Field, Field, Field]] # Point at infinity is encoded as a None
GeneralPoint = Union[Point2D[Field], Point3D[Field]]


Expand Down

0 comments on commit 3d7d64f

Please sign in to comment.