ECPair.makeRandom constructor

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

Implementation

factory ECPair.makeRandom({NetworkType? network, bool? compressed, 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);
}