encodeKey method

  1. @override
String encodeKey(
  1. List<int> pubKey, [
  2. Map<String, dynamic> kwargs = const {}
])
override

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:

  1. Validate and obtain the Ed25519 public key as a compressed byte array.
  2. Extract the public key bytes from the compressed key.
  3. Compute the checksum for the public key bytes using _AlgoAddrUtils.computeChecksum.
  4. 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;
}