newKeyPairFromSeed method

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

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

@override
Future<EcKeyPair> newKeyPairFromSeed(List<int> seed) {
  return fallback.newKeyPairFromSeed(seed);
}