toSuiAddress method
Return the Sui address associated with this public key
Implementation
@override
String toSuiAddress() {
// max length = 1 flag byte + (max pk size + max weight size (u8)) * max signer size + 2 threshold bytes (u16)
const maxLength = 1 + (64 + 1) * MAX_SIGNER_IN_MULTISIG + 2;
final tmp = Uint8List(maxLength);
tmp.setAll(0, [SIGNATURE_SCHEME_TO_FLAG.MultiSig]);
tmp.setAll(1, bcs.ser('u16', _multisigPublicKey.threshold).toBytes());
// The initial value 3 ensures that following data will be after the flag byte and threshold bytes
int i = 3;
for (var item in publicKeys) {
final publicKey = item.publicKey;
final weight = item.weight;
final bytes = publicKey.toSuiBytes();
tmp.setAll(i, bytes);
i += bytes.length;
tmp.setAll(i++, [weight]);
}
return normalizeSuiAddress(Hex.encode(blake2b(tmp.sublist(0, i))));
}