summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRahiel Kasim <rahielkasim@gmail.com>2017-03-07 12:10:11 +0100
committerRahiel Kasim <rahielkasim@gmail.com>2017-03-07 12:10:11 +0100
commit4b96b938afe1f99da2ccd7df87fc42208ec60bdd (patch)
treef53ca41a1f34a87c6b5792e73a9e804fab9a9417
parent6d129c5073dde1ba8009a32882bc916eb23827cf (diff)
10: Elliptic Curve Private Key Recovery
-rw-r--r--.gitignore1
-rw-r--r--10-elliptic-curve-private-key-recovery.sage26
2 files changed, 27 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
index bee8a64..f0386da 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,2 @@
__pycache__
+*.sage.py
diff --git a/10-elliptic-curve-private-key-recovery.sage b/10-elliptic-curve-private-key-recovery.sage
new file mode 100644
index 0000000..f0c4c98
--- /dev/null
+++ b/10-elliptic-curve-private-key-recovery.sage
@@ -0,0 +1,26 @@
+#!/usr/bin/env sage
+
+# The curve parameters
+p = 0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff
+a = -0x3
+b = 0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b
+G = (0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296,
+ 0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5)
+
+# The public-key
+Q = (0x52910a011565810be90d03a299cb55851bab33236b7459b21db82b9f5c1874fe,
+ 0xe3d03339f660528d511c2b1865bcdfd105490ffc4c597233dd2b2504ca42a562)
+
+F = FiniteField(p)
+C = EllipticCurve(F, [a, b])
+
+G = C.point(G)
+Q = C.point(Q)
+
+P = G + G
+d = 2
+while P != Q:
+ P += G
+ d += 1
+
+print("d=%d" % d)