newKeyPairFromSeed method

  1. @override
Future<SimpleKeyPair> newKeyPairFromSeed(
  1. List<int> bytes
)
override

Implementation

@override
Future<SimpleKeyPair> newKeyPairFromSeed(List<int> bytes) async {
  if (usePlugin) {
    try {
      final result = await channel.invokeMethod(
        'ed25519_new_key',
        {
          'seed': Uint8List.fromList(bytes),
        },
      );
      if (result is! Map) {
        throw StateError('Invalid output');
      }
      final privateKey = result['privateKey'] as Uint8List;
      final publicKey = SimplePublicKey(
        result['privateKey'] as Uint8List,
        type: KeyPairType.ed25519,
      );
      return SimpleKeyPairData(
        privateKey,
        publicKey: publicKey,
        type: KeyPairType.ed25519,
      );
    } catch (error, stackTrace) {
      usePlugin = false;
      reportError(error, stackTrace);
    }
  }
  return fallback.newKeyPairFromSeed(bytes);
}