signProsonalMessage method
Signs a personal message digest with an optional payload length.
The Tron personal sign prefix is applied to the message, and the resulting signature is returned as a byte list. Optionally, a payload length can be provided.
Parameters:
digest
: The personal message digest to be signed.payloadLength
: An optional payload length to include in the message prefix.useEthPrefix
: Whether to use the Ethereum or Tron personal sign prefix (default is false).
Returns:
- A byte list representing the signature of the personal message.
Implementation
List<int> signProsonalMessage(List<int> digest,
{int? payloadLength, bool useEthPrefix = false}) {
String prefix = useEthPrefix
? ETHSignerConst.ethPersonalSignPrefix
: TronSignerConst.tronPersonalSignPrefix;
prefix = prefix + (payloadLength?.toString() ?? digest.length.toString());
final prefixBytes = StringUtils.encode(prefix, type: StringEncoding.ascii);
return _signEcdsa(
QuickCrypto.keccack256Hash(<int>[...prefixBytes, ...digest]),
hashMessage: false);
}