newKeyPairFromSeed method

Future<KeyPair> newKeyPairFromSeed(
  1. List<int> seed
)

Generates a key pair from the seed.

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

Example

In this example, we use X25519:

import 'dart:convert';
import 'package:cryptography/cryptography.dart';

Future<void> main() async {
  // X25519 seed is any 32 bytes.
  // We can use SHA256, which computes a 32-byte hash from any input.
  final seed = utf8.encode('example');
  final seedWith32Bytes = (await Sha256().hash(seed)).bytes;

  final algorithm = X25519();
  final keyPair = await algorithm.newKeyPairFromSeed(seedWith32Bytes);
}

Implementation

Future<KeyPair> newKeyPairFromSeed(List<int> seed) {
  throw UnsupportedError(
    'newKeyPairFromSeed() is unsupported by this algorithm',
  );
}