fromPrivateKey static method

Future<KeyPair> fromPrivateKey(
  1. String hexEncodedPrivateKey
)

Creates a key pair from a hexEncodedPrivateKey. The public key is extracted from the private key.

Throws a CryptoException when the private key has an invalid length.

Implementation

static Future<KeyPair> fromPrivateKey(final String hexEncodedPrivateKey) async {
  final privateKeySeed = hexToBytes(hexEncodedPrivateKey);
  if (32 != privateKeySeed.length) {
    throw ArgumentError('Private key has an unexpected size. '
        'Expected: 32, Got: ${privateKeySeed.length}');
  }

  final publicKey = await extractPublicKey(privateKeySeed);
  return _create(Uint8List.fromList(privateKeySeed), publicKey);
}