generate static method

Future<Ed25519KeyIdentity> generate(
  1. Uint8List? seed
)

Implementation

static Future<Ed25519KeyIdentity> generate(Uint8List? seed) async {
  if (seed != null && seed.length != 32) {
    throw RangeError.value(seed.length, 'Expected 32-bytes long but got');
  }

  final Uint8List publicKey;
  final Uint8List secretKey; // Seed itself.
  final kp = await ed25519FromSeed(
    req: ED25519FromSeedReq(seed: seed ?? getRandomValues()),
  );
  publicKey = kp.publicKey;
  secretKey = kp.seed;
  return Ed25519KeyIdentity(Ed25519PublicKey.fromRaw(publicKey), secretKey);
}