Skip to content

Commit 971399d

Browse files
authored
Changed Parameter
1 parent 94fae0c commit 971399d

File tree

1 file changed

+14
-15
lines changed

1 file changed

+14
-15
lines changed

Diff for: secp256k1.py

+14-15
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
"""
22
© Yanni8 https://github.com/Yanni8
3-
This algorithmus is not efficient and also probaly not 100% secure.
3+
This algorythmus is not efficient and also probaly not 100% secure.
44
Attackers could use Timing Attack (https://en.wikipedia.org/wiki/Timing_attack) to get informations about the private key
55
"""
66

7-
a = 0
8-
b = 7
9-
p = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 - 1
10-
Gx = 55066263022277343669578718895168534326250603453777594175500187360389116729240
11-
Gy = 32670510020758816978083085130507043184471273380659243275938904335757337482424
12-
G = (Gx, Gy)
7+
A = 0
8+
B = 7
9+
P = 2**256 - 2**32 - 2**9 - 2**8 - 2**7 - 2**6 - 2**4 - 1
10+
GX = 55066263022277343669578718895168534326250603453777594175500187360389116729240
11+
GY = 32670510020758816978083085130507043184471273380659243275938904335757337482424
12+
G = (GX, GY)
1313

1414
def point_add(p1 : tuple, p2 : tuple) -> tuple:
1515
if p1 != p2:
16-
lam = (p1[1] - p2[1]) * pow(p1[0] - p2[0], p-2, p)
17-
x3 = (pow(lam, 2) - p1[0] - p2[0]) % p
18-
y3 = (lam * (p1[0] - x3) - p1[1]) % p
16+
lam = (p1[1] - p2[1]) * pow(p1[0] - p2[0], P-2, P)
17+
x3 = (pow(lam, 2) - p1[0] - p2[0]) % P
18+
y3 = (lam * (p1[0] - x3) - p1[1]) % P
1919
return (x3, y3)
2020
return point_dubl(p1)
2121

2222
def point_dubl(p1 : tuple) -> tuple:
23-
lam = (3*p1[0]**2 + a) * pow(2*p1[1], p-2, p)
24-
v = p1[1] - lam*p1[0] % p
25-
x3 = (lam**2 - 2*p1[0]) % p
26-
y3 = (lam*x3 + v) * -1 % p
23+
lam = (3*p1[0]**2 + A) * pow(2*p1[1], P-2, P)
24+
v = p1[1] - lam*p1[0] % P
25+
x3 = (lam**2 - 2*p1[0]) % P
26+
y3 = (lam*x3 + v) * -1 % P
2727
return (x3, y3)
2828

2929

@@ -40,4 +40,3 @@ def calc_publ(private_key):
4040
Q = point_dubl(Q)
4141
binar = binar//2
4242
return publ
43-

0 commit comments

Comments
 (0)