Last active
November 8, 2022 11:19
-
-
Save njofce/b8136e7068cd14591ce5b05711bad5fe to your computer and use it in GitHub Desktop.
Generate ECDSA key pair
This file contains hidden or 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
#!/usr/bin/env sh | |
set -e | |
key=`openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout 2>/dev/null` | |
# Extract the public key and remove the EC prefix 0x04 | |
pub=`echo "${key}" | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//'` | |
# Extract the private key and remove the leading zero byte | |
priv=`echo "${key}" | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//'` | |
echo "" | |
echo "Private Key:" | |
echo "0x"$priv | |
echo "" | |
echo "Public Key:" | |
echo $pub | |
echo "" | |
echo "You can verify the script you just ran at keys.diagonal.new" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment