Skip to content

Instantly share code, notes, and snippets.

@arthurk
Created February 16, 2020 12:25
Embed
What would you like to do?
#!/usr/bin/env python3
from secrets import token_bytes
from coincurve import PublicKey
from sha3 import keccak_256
def generate_address():
private_key = keccak_256(token_bytes(32)).digest()
public_key = PublicKey.from_valid_secret(private_key).format(compressed=False)[1:]
addr = keccak_256(public_key).digest()[-20:]
return private_key.hex(), addr.hex()
if __name__ == '__main__':
import timeit
print(timeit.timeit(
stmt="generate_address()",
setup="from __main__ import generate_address",
number=1000000))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment