summaryrefslogtreecommitdiffstats
path: root/viris/coin/a.py
diff options
context:
space:
mode:
Diffstat (limited to 'viris/coin/a.py')
-rwxr-xr-xviris/coin/a.py38
1 files changed, 38 insertions, 0 deletions
diff --git a/viris/coin/a.py b/viris/coin/a.py
new file mode 100755
index 0000000..6bd19c6
--- /dev/null
+++ b/viris/coin/a.py
@@ -0,0 +1,38 @@
+#!/usr/bin/python3
+from ecdsa import SigningKey, NIST384p
+import paramiko
+from cryptography.hazmat.primitives.serialization import (
+ Encoding, PrivateFormat, PublicFormat, NoEncryption
+)
+sk = SigningKey.generate(curve=NIST384p)
+sk_string = sk.to_string()
+sk2 = SigningKey.from_string(sk_string, curve=NIST384p)
+print(sk_string.hex())
+print(sk2.to_string().hex())
+print("--------------")
+pk0 = bytes.fromhex("06cadf8035a6102e6ad0d1ef86c8a68c34a680d5f488d4ba45ef768033ef89ee5f818f4980c2f284c05a176049876ada")
+myO = SigningKey.from_string(bytes.fromhex("06cadf8035a6102e6a38d1ef86c8a68c34a680d5ce88d4ba45ef768033ef89ee5f818f4980c2f284c05a176049876ada"), curve=NIST384p);
+my0 = SigningKey.from_string(pk0, curve=NIST384p)
+print(myO.to_string().hex())
+print(my0.to_string().hex())
+with open("/tmp/O", "wb") as f:
+ f.write(myO.to_pem())
+ print(myO.to_pem())
+with open("/tmp/0", "wb") as f:
+ f.write(my0.to_pem())
+ print(my0.to_pem())
+print("___________");
+keyO = paramiko.ECDSAKey.from_private_key_file("/tmp/O")
+key0 = paramiko.ECDSAKey.from_private_key_file("/tmp/0")
+with open("/tmp/O_ecdsa", "wb") as fh:
+ data = keyO.signing_key.private_bytes(Encoding.PEM, PrivateFormat.OpenSSH, NoEncryption())
+ fh.write(data)
+with open("/tmp/O_ecdsa.pub", "wb") as fh:
+ data = keyO.verifying_key.public_bytes(Encoding.OpenSSH, PublicFormat.OpenSSH)
+ fh.write(data + b"\n")
+with open("/tmp/0_ecdsa", "wb") as fh:
+ data = key0.signing_key.private_bytes(Encoding.PEM, PrivateFormat.OpenSSH, NoEncryption())
+ fh.write(data)
+with open("/tmp/0_ecdsa.pub", "wb") as fh:
+ data = key0.verifying_key.public_bytes(Encoding.OpenSSH, PublicFormat.OpenSSH)
+ fh.write(data + b"\n")