MoneroPrivateKey.fromBytes constructor

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

Factory method for creating an MoneroPrivateKey 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.

Implementation

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