-
-
Save dendisuhubdy/6d566fc8aa29372e751af66811172389 to your computer and use it in GitHub Desktop.
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 ecdsa import SigningKey, SECP256k1 | |
from sha3 import keccak_256 | |
import click | |
@click.command() | |
@click.argument('count', type=click.types.IntRange(1, 1000), default=1) | |
def main(count): | |
for i in range(count): | |
priv, addr = generate_pair() | |
print(priv, '0x' + addr) | |
def generate_pair(): | |
priv = generate_private_key() | |
pubc = generate_public_key(priv) | |
address = generate_public_address(pub) | |
return priv.to_string().hex(), address | |
def generate_private_key(): | |
priv = SigningKey.generate(curve=SECP256k1) | |
return priv | |
def generate_public_key(priv): | |
pub = priv.get_verifying_key().to_string() | |
return pub | |
def generate_public_address(pub): | |
address = keccak_256(pub).hexdigest()[24:] | |
return address | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment