ECPair.makeRandom constructor

ECPair.makeRandom({Network network, bool compressed, Function rng })

Creates a random keypair

Implementation

factory ECPair.makeRandom({Network network, bool compressed, Function rng}) {
  final rfunc = rng ?? _randomBytes;
  Uint8List d;
//    int beginTime = DateTime.now().millisecondsSinceEpoch;
  do {
    d = rfunc(32);
    if (d.length != 32) throw ArgumentError("Expected Buffer(Length: 32)");
//      if (DateTime.now().millisecondsSinceEpoch - beginTime > 5000) throw ArgumentError("Timeout");
  } while (!ecc.isPrivate(d));
  return ECPair.fromPrivateKey(d, network: network, compressed: compressed);
}