KeyPair.generateEd25519 constructor

KeyPair.generateEd25519()

Generates a random Ed25519 (OKP) KeyPair (RFC 8037).

Implementation

factory KeyPair.generateEd25519() {
  final pair = ed.generateKey();
  return KeyPair(
    publicKey: OkpPublicKey(
      rawBytes: Uint8List.fromList(pair.publicKey.bytes),
      curve: curves.ed25519,
    ),
    privateKey: OkpPrivateKey(
      // RFC 8037 `d` is the RFC 8032 seed, not the expanded private key.
      rawBytes: ed.seed(pair.privateKey),
      curve: curves.ed25519,
    ),
  );
}