from ecc import Point
class Point(Point):
def __add__(self, other):
if self.a != other.a or self.b != other.b:
raise RuntimeError('Points {}, {} are not on the same curve'.format(self, other))
# Case 0.0: self is the point at infinity, return other
if self.x is None:
return other
# Case 0.1: other is the point at infinity, return self
if other.x is None:
return self
# Case 1: self.x == other.x, self.y != other.y
# Result is point at infinity
if self.x == other.x and self.y != other.y:
# Remember to return an instance of this class:
# self.__class__(x, y, a, b)
return self.__class__(None, None, self.a, self.b)
# Case 2: self.x != other.x
# Formula (x3,y3)==(x1,y1)+(x2,y2)
# s=(y2-y1)/(x2-x1)
# x3=s**2-x1-x2
# y3=s*(x1-x3)-y1
# Remember to return an instance of this class:
# self.__class__(x, y, a, b)
pass