Last active
August 29, 2015 14:00
-
-
Save paxswill/11224904 to your computer and use it in GitHub Desktop.
Generating Core keypairs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from binascii import hexlify | |
from ecdsa import SigningKey, NIST256p | |
# Generate the private key and the corresponding public key | |
sk = SigningKey.generate(curve=NIST256p) | |
vk = sk.get_verifying_key() | |
# Write the keys to disk in hex format | |
with open('signing_key.txt', 'wb') as f: | |
f.write(hexlify(sk.to_string())) | |
with open('verifying_key.txt', 'wb') as f: | |
f.write(hexlify(vk.to_string())) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Generate a private key and store it (PEM encoded) to private.pem | |
openssl ecparam -outform PEM -out private.pem -name prime256v1 -genkey | |
# Generate the corresponding public key and store it (again, PEM encoded) to public.pem | |
openssl ec -inform PEM -in private.pem -outform PEM -out public.pem -pubout | |
# Get the hex form of just the public key (no encoded parameters) | |
openssl ec -in public.pem -pubin -text -noout 2>/dev/null | grep -o -e ' *[0-9a-f:]*' | tr -d ' \n:' | |
# And the same for the private key | |
openssl ec -in private.pem -text -noout 2>/dev/null | tr -d '\n' | sed s,".*priv:[:space:]*\([0-9a-f:\t\n ]*\)pub:.*","\1", | tr -d ' :' | cut -c 3- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment