blob: 6d8694dd871d81e56cb8dea5ecfdf6a7afb04d78 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
from public import public
from .curve import EllipticCurve
from .point import Point
@public
class AbelianGroup(object):
"""A (sub)group of an elliptic curve."""
curve: EllipticCurve
generator: Point
neutral: Point
order: int
cofactor: int
def __init__(self, curve: EllipticCurve, generator: Point, neutral: Point, order: int,
cofactor: int):
self.curve = curve
self.generator = generator
self.neutral = neutral
self.order = order
self.cofactor = cofactor
def is_neutral(self, point: Point) -> bool:
return self.neutral == point
def __eq__(self, other):
if not isinstance(other, AbelianGroup):
return False
return self.curve == other.curve and self.generator == other.generator and self.neutral == other.neutral and self.order == other.order and self.cofactor == other.cofactor
|