KeyPair.generateEc constructor

KeyPair.generateEc(
  1. Identifier curve
)

Implementation

factory KeyPair.generateEc(Identifier curve) {
  var generator = pc.ECKeyGenerator()
    ..init(
      pc.ParametersWithRandom(
        pc.ECKeyGeneratorParameters(
          _AsymmetricOperator.createCurveParameters(curve),
        ),
        DefaultSecureRandom(),
      ),
    );

  var pair = generator.generateKeyPair();

  return KeyPair(
      publicKey: EcPublicKey(
          xCoordinate:
              (pair.publicKey as pc.ECPublicKey).Q!.x!.toBigInteger()!,
          yCoordinate:
              (pair.publicKey as pc.ECPublicKey).Q!.y!.toBigInteger()!,
          curve: curve),
      privateKey: EcPrivateKey(
          eccPrivateKey: (pair.privateKey as pc.ECPrivateKey).d!,
          curve: curve));
}