decodeAddr method

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

Decode an Algorand (Algo) blockchain address to its corresponding public key bytes.

This method decodes the specified addr by performing the following steps:

  1. Decode the Base32-encoded address string into bytes.
  2. Validate the length of the decoded bytes, ensuring it matches the expected length.
  3. Split the decoded bytes into two parts: the public key bytes and the checksum bytes.
  4. Validate the checksum by comparing it with a computed checksum using _AlgoAddrUtils.computeChecksum.

Parameters:

  • addr: The Algorand blockchain address to decode.

Returns:

  • A List

This method is used to convert an Algorand blockchain address back to its public key bytes.

Implementation

@override
List<int> decodeAddr(String addr, [Map<String, dynamic> kwargs = const {}]) {
  final addrDecBytes = Base32Decoder.decode(addr);
  const expectedLength =
      Ed25519KeysConst.pubKeyByteLen + AlgoAddrConst.checksumByteLen;
  AddrDecUtils.validateBytesLength(addrDecBytes, expectedLength);
  final parts = AddrDecUtils.splitPartsByChecksum(
      addrDecBytes, AlgoAddrConst.checksumByteLen);
  final pubKeyBytes = parts.item1;
  final checksumBytes = parts.item2;
  AddrDecUtils.validateChecksum(
      pubKeyBytes, checksumBytes, _AlgoAddrUtils.computeChecksum);

  // Validate public key
  // AddrDecUtils.validatePubKey(pubKeyBytes, Ed25519PublicKey);

  return pubKeyBytes;
}