fromSeedSync method

Ed25519Keypair fromSeedSync(
  1. Uint8List seed
)

Creates a keypair from a 32-byte seed.

Throws an AssertionError if the seed is invalid.

Implementation

Ed25519Keypair fromSeedSync(final Uint8List seed) {
  check(seed.length == maxSeedLength, '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);
  check(result == 0, 'Failed to create keypair from seed $seed.');
  return Ed25519Keypair(pubkey: pubkey, seckey: seckey);
}