AptosBasePrivateKey<PUBLICKEY extends AptosCryptoPublicKey<IPublicKey> , SIGNATURE extends AptosAnySignature>.fromAIP80 constructor
AptosBasePrivateKey<PUBLICKEY extends AptosCryptoPublicKey<IPublicKey> , SIGNATURE extends AptosAnySignature>.fromAIP80 (
- String privateKey
decode aptos AIP-80 private key style to private key.
Implementation
factory AptosBasePrivateKey.fromAIP80(String privateKey) {
try {
final decode = AptosCryptoUtils.decodeAptosPrivateKey(privateKey);
final algorithm = decode.$1;
final keyBytes = decode.$2;
final key = switch (algorithm) {
AptosKeyAlgorithm.ed25519 => AptosED25519PrivateKey.fromBytes(keyBytes),
AptosKeyAlgorithm.secp256k1 =>
AptosSecp256k1PrivateKey.fromBytes(keyBytes)
};
return key as AptosBasePrivateKey<PUBLICKEY, SIGNATURE>;
} catch (e) {
throw DartAptosPluginException("Invalid aptos AIP-80 private key style.",
details: {"error": e.toString()});
}
}