Ed25519Blake2bPrivateKey.fromBytes constructor

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

Factory method for creating an Ed25519Blake2bPrivateKey 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 BLAKE2b hash function.

Implementation

factory Ed25519Blake2bPrivateKey.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, () => BLAKE2b());
  return Ed25519Blake2bPrivateKey._(eddsaPrivateKey);
}