fromSeedSync method

Ed25519Keypair fromSeedSync(
  1. Uint8List seed
)

Creates a keypair from a 32-byte seed.

Implementation

// Future<Ed25519Keypair> fromSeed(final Uint8List seed) =>
//     compute(fromSeedSync, seed);

/// Creates a keypair from a `32-byte` [seed].
Ed25519Keypair fromSeedSync(final Uint8List seed) {
  if (seed.length != maxSeedLength)
    throw Exception('Invalid seed length ${seed.length}.');
  final pubkey = Uint8List(pubkeyLength);
  final seckey = Uint8List(seckeyLength)..setAll(0, seed);
  final int result = TweetNaCl.crypto_sign_keypair(pubkey, seckey, seed);
  if (result != 0)
    throw Exception('Failed to create keypair from seed $seed.');
  return Ed25519Keypair(pubkey: pubkey, seckey: seckey);
}