跳到主要内容

scdoSignMessage

使用要求

  • 固件版本要求
    • UKey Lite 24 / UKey Lite 25 / UKey Core 26: 4.10.0

SCDO:签名消息

使用指定 BIP32 路径派生的私钥对消息进行签名。签名前请确保消息内容和业务场景清晰可验证。

// 原始消息内容
const message = "Hello SCDO";

// 转换为十六进制消息
const messageHex = Buffer.from(message).toString("hex");

const response = await HardwareSDK.scdoSignMessage(connectId, deviceId, {
path: "m/44'/541'/1'/0/0",
messageHex,
});

参数

可选通用参数

  • path - 必需 string | Array<number>,字符串数组最小长度限制为 3更多信息
  • messageHex - 必需 string,以十六进制文本表示的待签名消息。

示例

// 原始消息内容
const message = "Hello SCDO";

// 转换为十六进制消息
const messageHex = Buffer.from(message).toString("hex");

const response = await HardwareSDK.scdoSignMessage(connectId, deviceId, {
path: "m/44'/541'/1'/0/0",
messageHex,
});

返回结果

{
success: true,
payload: {
signature: string, // 签名结果
address: string // 返回的地址
}
}

错误

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