getPublicKey static method
Gets the recovered ECDSAPublicKey from a message and signature.
Parameters:
message
: The message.signature
: The signature bytes.hashMessage
: Whether to hash the message before recovering the public key (default is true).payloadLength
: An optional payload length to include in the message prefix.
Returns:
- The recovered ECDSAPublicKey.
Implementation
static ECDSAPublicKey? getPublicKey(List<int> message, List<int> signature,
{bool hashMessage = true, int? payloadLength}) {
final List<int> messagaeHash = _hashMessage(message,
hashMessage: hashMessage, payloadLength: payloadLength);
final ethSignature = ETHSignature.fromBytes(signature);
final toBytes = ethSignature.toBytes(false);
final recoverId = toBytes[ETHSignerConst.ethSignatureLength];
final signatureBytes = ECDSASignature.fromBytes(
toBytes.sublist(0, ETHSignerConst.ethSignatureLength),
ETHSignerConst.secp256);
return signatureBytes.recoverPublicKey(
messagaeHash, ETHSignerConst.secp256, recoverId);
}