generateKeyPair method

  1. @override
AsymmetricKeyPair<PublicKey, PrivateKey> generateKeyPair()
override

Generate a key pair.

Implementation

@override
AsymmetricKeyPair generateKeyPair() {
  var n = _params.n;
  var nBitLength = n.bitLength;
  BigInt? d;

  do {
    d = _random.nextBigInteger(nBitLength);
  } while (d == BigInt.zero || (d >= n));

  var Q = _params.G * d;

  return AsymmetricKeyPair(ECPublicKey(Q, _params), ECPrivateKey(d, _params));
}