ECPair.makeRandom constructor

ECPair.makeRandom({
  1. NetworkType network = mainnet,
  2. bool compressed = true,
  3. Function? rng,
})

Implementation

factory ECPair.makeRandom(
    {NetworkType network = mainnet, bool compressed = true, Function? rng}) {
  final rfunc = rng ?? _randomBytes;
  Uint8List? d;
  do {
    d = rfunc(32);
    if (d!.length != 32) throw ArgumentError('Expected Buffer(Length: 32)');
  } while (!ecc.isPrivate(d));
  return ECPair.fromPrivateKey(d, network: network, compressed: compressed);
}