跳到主要内容

starcoinVerifyMessage

Starcoin:验证消息

根据签名者地址、签名结果校验该消息。

ES6

const result = await HardwareSDK.starcoinVerifyMessage(
connectId,
deviceId,
params,
);

参数

可选通用参数

  • publicKey - 必需 string,用于验证签名的公钥。
  • messageHex - 必需 string,待验证消息的十六进制文本。
  • signature - 必需 string,对应消息的十六进制签名结果。

示例

HardwareSDK.starcoinVerifyMessage(connectId, deviceId, {
publicKey: "cf90aea8962229869bcba527f0cf0de73ad4c22fe27ad2875007e967db7056f5",
messageHex: "0x6578616d706c65206d657373616765",
signature:
"447d2c3131c32d176106482d8fc780d933f13b37b0f06beee27de5e73a945e8c807f7764d269a196306f53383a26ab632913f4076457e3230b9defafe1c6ba0b",
});

返回结果

{
success: true,
payload: {
message: "Message verified" // 验证成功
}
}

错误

{
success: false,
payload: {
error: string, // 错误消息
code: number // 错误码
}
}