Generate a new Private Key and associated Public Address
#!/usr/bin/python3 import sha3 from ecdsa import SigningKey, SECP256k1 keccak = sha3.keccak_256() sk = SigningKey.generate(curve=SECP256k1) keccak.update(sk.get_verifying_key().to_string()) address = "0x{0}".format(keccak.hexdigest()[24:]) private = sk.to_string().hex() print("Private Key : {0}n" "Public Address: {1}n".format(private,address))
Generate the Public Address from a Private Key expressed in hex
#!/usr/bin/python3 import sha3 import binascii from ecdsa import SigningKey, SECP256k1 private = binascii.unhexlify('8135253f1f5269f00b1a3740c463d478da369b6433f31139a4337250fc249e83') keccak = sha3.keccak_256() keccak.update(SigningKey.from_string(private, curve=SECP256k1).get_verifying_key().to_string()) address = "0x{0}".format(keccak.hexdigest()[24:]) print("Public Address: {0}".format(address))
Be First to Comment