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