encodeAptosPrivateKey static method

String encodeAptosPrivateKey(
  1. List<int> privateKey, {
  2. EllipticCurveTypes? type,
  3. AptosKeyAlgorithm? keyScheme,
})

encode aptos private key to AIP-80 style.

Implementation

static String encodeAptosPrivateKey(List<int> privateKey,
    {EllipticCurveTypes? type, AptosKeyAlgorithm? keyScheme}) {
  if (keyScheme == null && type == null) {
    throw DartAptosPluginException(
        "Key scheme or Elliptic curve type required for generate Aptos AIP-80 private key.");
  }
  keyScheme ??= AptosKeyAlgorithm.fromEllipticCurveType(type!);
  final key = IPrivateKey.fromBytes(privateKey, keyScheme.curveType);
  return keyScheme.aip80 + key.toHex(prefix: "0x");
}