跳到主要内容

nostrEncryptMessage

使用要求

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

Nostr:加密消息

使用指定 BIP32 路径派生的私钥加密消息,用户需要在 Ukey Wallet 上确认操作。

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

参数

可选通用参数

  • path - 必需 string | Array<number>,字符串数组最小长度限制为 3更多信息
  • pubkey - 必需 string,公钥。
  • plaintext - 必需 string,待加密的消息内容。
  • showOnUKey - 可选 boolean,决定是否在设备上显示地址;默认值为 true

示例

const response = await HardwareSDK.nostrEncryptMessage(connectId, deviceId, {
path: "m/44'/1237'/1'/0/0",
pubkey: "9f3c72b4a8d1e67f20cb59d4ef1836aa74d05bc98e1a43f26b7d9c4e5fa8123d",
plaintext: "Hello Nostr",
showOnUKey: true,
});

返回结果

{
success: true,
payload: {
path: string, // 使用的 BIP32 路径
pubkey: string, // 对方公钥
plaintext: string, // 原始消息内容
encryptedMessage: string, // 加密后的消息
}
}

错误

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