Ed25519PrivateKey.fromBytes constructor

Ed25519PrivateKey.fromBytes(
  1. List<int> keyBytes
)

Factory method for creating an Ed25519PrivateKey from a byte array. It checks the length of the provided keyBytes to ensure it matches the expected length. Then, it initializes an EdDSA private key using the Edward generator and SHA512 hash function.

Implementation

factory Ed25519PrivateKey.fromBytes(List<int> keyBytes) {
  if (keyBytes.length != Ed25519KeysConst.privKeyByteLen) {
    throw const ArgumentException("invalid private key length");
  }
  final edwardGenerator = Curves.generatorED25519;
  final eddsaPrivateKey =
      EDDSAPrivateKey(edwardGenerator, keyBytes, () => SHA512());
  return Ed25519PrivateKey._(eddsaPrivateKey);
}