Ed25519KholawPrivateKey.fromBytes constructor

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

Factory method for creating an Ed25519-KholawPrivateKey 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 Ed25519 generator and the specified keyBytes, and stores any extended key data.

Implementation

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