Keystore.fromSeed constructor

Keystore.fromSeed(
  1. String seed
)

A factory that generates a keystore from a seed.

final keystore = Keystore.fromSeed('edsk3RR5U7JsUJ8ctjsuymUPayxMm4LHXaB7VJSfeyMb8fAvbJUnsa');

Throws CryptoError if:\

  • seed length is != 54
  • seed checksum is invalid

Implementation

factory Keystore.fromSeed(String seed) {
  return crypto.catchUnhandledErrors(() {
    if (seed.length != _seedLength) {
      throw crypto.CryptoError(type: crypto.CryptoErrorTypes.seedLengthError);
    }
    _validateChecksum(seed);

    return Keystore._(secretKey: crypto.seedToSecretKey(seed));
  });
}