encodeKey method
Encodes a public key as a Tezos (XTZ) blockchain address using the specified prefix.
Implementation
@override
String encodeKey(List<int> pubKey, {XtzAddrPrefixes? addressPrefix}) {
addressPrefix = AddrKeyValidator.getAddrArg<XtzAddrPrefixes>(
addressPrefix,
"addressPrefix",
);
/// Validate the provided public key.
final pubKeyObj = AddrKeyValidator.validateAndGetEd25519Key(pubKey);
/// Derive the address by hashing and prepending the prefix.
final blakeBytes = QuickCrypto.blake2b160Hash(
pubKeyObj.compressed.sublist(1),
);
/// Encode the address using base58 and the specified prefix.
return Base58Encoder.checkEncode([...addressPrefix.value, ...blakeBytes]);
}