EthPrivateKey.createRandom constructor

EthPrivateKey.createRandom(
  1. Random random
)

Creates a new, random private key from the random number generator.

For security reasons, it is very important that the random generator used is cryptographically secure. The private key could be reconstructed by someone else otherwise. Just using Random() is a very bad idea! At least use Random.secure().

Implementation

factory EthPrivateKey.createRandom(Random random) {
  final key = generateNewPrivateKey(random);
  return EthPrivateKey(intToBytes(key));
}