formatPrivateKey static method
Format a HexInput to an AIP-80 compliant string.
privateKey is the hex string or bytes format of the private key.
type is the private key type.
Implementation
static String formatPrivateKey(HexInput privateKey, PrivateKeyVariants type) {
final aip80Prefix = aip80Prefixes[type]!;
// Remove the prefix if it exists.
var formattedPrivateKey = privateKey;
if (formattedPrivateKey is String &&
formattedPrivateKey.startsWith(aip80Prefix)) {
formattedPrivateKey = formattedPrivateKey.split('-')[2];
}
return '$aip80Prefix${Hex.fromHexInput(formattedPrivateKey)}';
}