newKeyPairFromSeed method

  1. @override
Future<EcKeyPair> newKeyPairFromSeed(
  1. List<int> seed
)

Generates a new KeyPair that uses the seed bytes.

This will throw UnsupportedError if the algorithm does not support seeds for private key generation.

Implementation

@override
Future<EcKeyPair> newKeyPairFromSeed(List<int> seed) async {
  if (isSupportedPlatform) {
    final result = await invokeMethod(
      'Ecdsa.newKeyPairFromSeed',
      {
        if (isAndroid) 'androidProvider': androidCryptoProvider,
        'curve': _curveName,
        'seed': asUint8List(seed),
      },
    );
    final der = result['der'] as Uint8List?;
    if (der != null) {
      return EcKeyPairData.parseDer(
        der,
        type: keyPairType,
      );
    }
    final d = result['d'] as Uint8List;
    final x = result['x'] as Uint8List;
    final y = result['y'] as Uint8List;
    return EcKeyPairData(
      d: d,
      x: x,
      y: y,
      type: keyPairType,
    );
  }
  final fallback = this.fallback;
  if (fallback == null) {
    throw UnsupportedError('Unsupported and no fallback implementation');
  }
  return await fallback.newKeyPair();
}