Skip to content

Instantly share code, notes, and snippets.

@banteg
Created November 25, 2017 08:24
Show Gist options
  • Save banteg/7da85ee45ceaae6bd5447305d99c8c92 to your computer and use it in GitHub Desktop.
Save banteg/7da85ee45ceaae6bd5447305d99c8c92 to your computer and use it in GitHub Desktop.
from ecdsa import SigningKey, SECP256k1
from sha3 import keccak_256
priv = SigningKey.generate(curve=SECP256k1)
pub = priv.get_verifying_key().to_string()
address = keccak_256(pub).hexdigest()[24:]
print(f'private key: 0x{priv.to_string().hex()}')
print(f'public key: 0x{pub.hex()}')
print(f'address: 0x{address}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment