@@ -113,7 +113,7 @@ def __init__(self, x, y, a, b):
113
113
return
114
114
# make sure that the elliptic curve equation is satisfied
115
115
# y**2 == x**3 + a*x + b
116
- if self .y ** 2 != self .x ** 3 + a * x + b :
116
+ if self .y ** 2 != self .x ** 3 + a * x + b :
117
117
# if not, raise a ValueError
118
118
raise ValueError (f"({ self .x } , { self .y } ) is not on the curve" )
119
119
@@ -158,7 +158,7 @@ def __add__(self, other):
158
158
# s=(y2-y1)/(x2-x1)
159
159
s = (other .y - self .y ) / (other .x - self .x )
160
160
# x3=s**2-x1-x2
161
- x = s ** 2 - self .x - other .x
161
+ x = s ** 2 - self .x - other .x
162
162
# y3=s*(x1-x3)-y1
163
163
y = s * (self .x - x ) - self .y
164
164
return self .__class__ (x , y , self .a , self .b )
@@ -167,9 +167,9 @@ def __add__(self, other):
167
167
else :
168
168
# Formula (x3,y3)=(x1,y1)+(x1,y1)
169
169
# s=(3*x1**2+a)/(2*y1)
170
- s = (3 * self .x ** 2 + self .a ) / (2 * self .y )
170
+ s = (3 * self .x ** 2 + self .a ) / (2 * self .y )
171
171
# x3=s**2-2*x1
172
- x = s ** 2 - 2 * self .x
172
+ x = s ** 2 - 2 * self .x
173
173
# y3=s*(x1-x3)-y1
174
174
y = s * (self .x - x ) - self .y
175
175
return self .__class__ (x , y , self .a , self .b )
@@ -192,7 +192,7 @@ def __rmul__(self, coefficient):
192
192
193
193
A = 0
194
194
B = 7
195
- P = 2 ** 256 - 2 ** 32 - 977
195
+ P = 2 ** 256 - 2 ** 32 - 977
196
196
N = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141
197
197
198
198
@@ -384,7 +384,7 @@ def parse_sec(cls, sec_bin):
384
384
is_even = sec_bin [0 ] == 2
385
385
x = S256Field (int (sec_bin [1 :].hex (), 16 ))
386
386
# right side of the equation y^2 = x^3 + 7
387
- alpha = x ** 3 + S256Field (B )
387
+ alpha = x ** 3 + S256Field (B )
388
388
# solve for left side
389
389
beta = alpha .sqrt ()
390
390
if beta .num % 2 == 0 :
@@ -407,7 +407,7 @@ def parse_bip340(cls, bip340_bin):
407
407
return cls (None , None )
408
408
x = S256Field (n )
409
409
# right side of the equation y^2 = x^3 + 7
410
- alpha = x ** 3 + S256Field (B )
410
+ alpha = x ** 3 + S256Field (B )
411
411
# solve for left side
412
412
beta = alpha .sqrt ()
413
413
if beta .num % 2 == 1 :
0 commit comments