0

As far as I understand, a private key in the context of Ethereum is simply 256 random bits. The actual application of secp256k1 comes in when converting this to the public key, signing, etc. Based on this, is there anything wrong with generating a private key in python by simply doing the following (and doing any other operations using a library such as the web3 family) ?

import random
key = hex(random.getrandbits(256))

Or are there, for example, security issues when doing this?

  • 1
    In Ethereum private keys has to be in a range defined by secp256k1 curve, see https://ethereum.stackexchange.com/a/2320 for the precise numbers. – Ismael May 20 '20 at 15:28
  • 1
    Exactly the answer I was looking for, thank you! –  May 20 '20 at 16:28

0 Answers0