encodeKey method
Encode a public key into an Algorand (Algo) blockchain address.
This method encodes the specified pubKey
into an Algorand blockchain address by performing the following steps:
- Validate and obtain the Ed25519 public key as a compressed byte array.
- Extract the public key bytes from the compressed key.
- Compute the checksum for the public key bytes using
_AlgoAddrUtils.computeChecksum
. - Concatenate the public key bytes and the checksum, then encode them using Base32 without padding.
Parameters:
pubKey
: A List representing the public key.
Returns:
- The Algorand blockchain address obtained by encoding the public key.
This method is used to create an Algorand blockchain address from a given public key.
Implementation
@override
String encodeKey(List<int> pubKey, [Map<String, dynamic> kwargs = const {}]) {
final pubkeyBytes =
AddrKeyValidator.validateAndGetEd25519Key(pubKey).compressed.sublist(1);
final checksumBytes = _AlgoAddrUtils.computeChecksum(pubkeyBytes);
final encodedAddress = Base32Encoder.encodeNoPaddingBytes(
List<int>.from([...pubkeyBytes, ...checksumBytes]));
return encodedAddress;
}