跳到主要内容

cardanoSignMessage

使用要求

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

Cardano:签名消息

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

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

参数

可选通用参数

  • path - 必需 string | Array<number>,字符串数组最小长度限制为 3更多信息
  • message - 必需 string,以十六进制文本表示的待签名消息。
  • networkId - 必需 Integer,主网为 1,测试网为 0
  • derivationType - 可选 CardanoDerivationType 枚举,用于指定派生类型;默认值为 ICARUS=1

示例

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

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

HardwareSDK.cardanoSignMessage(connectId, deviceId, {
path: "m/1852'/1815'/1'/0/1",
message: messageHex,
networkId: 1,
});

返回结果

{
success: true,
payload: {
signature: string; // 签名结果
key: string; // 签名公钥
}
}

错误

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