-
-
Save quesalltime/d43b29080bc2d8674f82ee22940a394d to your computer and use it in GitHub Desktop.
Generate ethereum key pairs and address
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
#!/bin/bash | |
# Source: https://kobl.one/blog/create-full-ethereum-keypair-and-address/ | |
# Install dependencies | |
sudo apt-get install openssl curl | |
# Download prebuilt sha3 keccak | |
if [ $(uname -m) == 'x86_64' ]; then | |
curl -L -O https://github.com/vkobel/ethereum-generate-wallet/raw/master/lib/x86-64/keccak-256sum | |
else | |
curl -L -O https://github.com/vkobel/ethereum-generate-wallet/raw/master/lib/i386/keccak-256sum | |
fi | |
chmod +x keccak-256sum | |
export PATH=$PATH:$(pwd) | |
keys=$(openssl ecparam -name secp256k1 -genkey -noout | openssl ec -text -noout 2> /dev/null) | |
# extract private key in hex format, removing newlines, leading zeroes and semicolon | |
priv=$(printf "%s\n" $keys | grep priv -A 3 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^00//') | |
# extract public key in hex format, removing newlines, leading '04' and semicolon | |
pub=$(printf "%s\n" $keys | grep pub -A 5 | tail -n +2 | tr -d '\n[:space:]:' | sed 's/^04//') | |
# get the keecak hash, removing the trailing ' -' and taking the last 40 chars | |
# https://github.com/maandree/sha3sum | |
addr=0x$(echo $pub | keccak-256sum -x -l | tr -d ' -' | tail -c 41) | |
echo 'Private key:' $priv | |
echo 'Public key: ' $pub | |
echo 'Address: ' $addr |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0x0f13858a75d4eE784B68499F3d8E0ca5CA9E26Be
Please donasi..!!