aboutsummaryrefslogtreecommitdiff
path: root/pyecsca/ec/point.py
blob: 265a0ea3d07c11cee808dd83a515d51b330f4e24 (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
from typing import Mapping

from .coordinates import CoordinateModel
from .mod import Mod


class Point(object):
    coordinate_model: CoordinateModel
    coords: Mapping[str, Mod]

    def __init__(self, model: CoordinateModel, **coords: Mod):
        if not set(model.variables) == set(coords.keys()):
            raise ValueError
        self.coordinate_model = model
        self.coords = coords

    def __eq__(self, other):
        if type(other) is not Point:
            return False
        return self.coordinate_model == other.coordinate_model and self.coords == other.coords

    def __repr__(self):
        args = ", ".join([f"{key}={val}" for key, val in self.coords.items()])
        return f"Point([{args}] in {self.coordinate_model})"