跳到主要内容

benfenGetPublicKey

Benfen:获取公钥

根据指定的 BIP32 路径在设备端读取公钥。

使用要求

  • 固件版本要求
    • UKey Lite 24 / UKey Lite 25 / UKey Core 26: 1.1.0
const result = await HardwareSDK.benfenGetPublicKey(connectId, deviceId, {
path: "m/44'/728'/1'/0'/0'",
showOnUKey: false,
});

参数

可选通用参数

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

返回值

  • success - boolean,请求是否成功。
  • payload.path - string,本次使用的 BIP32 路径。
  • payload.pub - string,十六进制格式的公钥。

示例

const params = {
path: "m/44'/728'/1'/0'/0'",
showOnUKey: false,
};

// 读取单个公钥
const response = await HardwareSDK.benfenGetPublicKey(
connectId,
deviceId,
params,
);

// 多个公钥
const batchParams = {
bundle: [
{
path: "m/44'/728'/3'/0'/0'",
showOnUKey: false,
},
{
path: "m/44'/728'/4'/0'/0'",
showOnUKey: false,
},
{
path: "m/44'/728'/5'/0'/0'",
showOnUKey: false,
},
],
};
const batchResponse = await HardwareSDK.benfenGetPublicKey(
connectId,
deviceId,
batchParams,
);