decodeAddr method
Decode an Algorand (Algo) blockchain address to its corresponding public key bytes.
This method decodes the specified addr
by performing the following steps:
- Decode the Base32-encoded address string into bytes.
- Validate the length of the decoded bytes, ensuring it matches the expected length.
- Split the decoded bytes into two parts: the public key bytes and the checksum bytes.
- 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;
}