Created
February 16, 2020 12:25
-
-
Save arthurk/fbc876951379e2b0c889ea71b5167b4e to your computer and use it in GitHub Desktop.
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 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