encodeKey method
Overrides the base class method to encode a public key as a Nano address.
Implementation
@override
String encodeKey(List<int> pubKey) {
/// Validate and obtain the Ed25519 Blake2b public key.
final pubKeyObj = AddrKeyValidator.validateAndGetEd25519Blake2bKey(pubKey);
/// Extract public key bytes and calculate the checksum.
final pubKeyBytes = pubKeyObj.compressed.sublist(1);
final checksumBytes = _NanoAddrUtils.computeChecksum(pubKeyBytes);
/// Create the Nano address payload by combining padding, public key, and checksum.
final payloadBytes = [
...NanoAddrConst.payloadPadDec,
...pubKeyBytes,
...checksumBytes,
];
/// Encode the payload using a custom Nano Base32 alphabet and prepend the Nano address prefix.
final b32Enc = Base32Encoder.encodeNoPaddingBytes(
payloadBytes,
NanoAddrConst.base32Alphabet,
);
return AddrKeyValidator.getConfigArg(
CoinsConf.nano.params.addrPrefix,
"addrPrefix",
) +
b32Enc.substring(NanoAddrConst.payloadPadEnc.length);
}