Key Path
CryptoKeypath 用于描述 BIP-44 等 HD 钱包派生路径。离线签名请求会依赖它告诉设备应该使用哪个账户或地址对应的密钥。
参数说明
| 字段 | 值类型 | 用途 |
|---|---|---|
components | PathComponent[] | 路径组件,默认可为空 |
sourceFingerprint | Buffer | 来源指纹,可选 |
depth | number | 路径深度,可选 |
PathComponent
PathComponent 类用于描述密钥路径中的单个组件,例如 44'、60'、0。
参数说明
| 字段 | 值类型 | 用途 |
|---|---|---|
index | number | 当前组件的索引值(可选) |
hardened | boolean | 是否为硬化派生 |
示范
import { CryptoKeypath, PathComponent } from "@keystonehq/bc-ur-registry";
// path note: BIP44: m/44'/60'/0'/0/0
const keypath = new CryptoKeypath([
new PathComponent({ index: 44, hardened: true }),
new PathComponent({ index: 60, hardened: true }),
new PathComponent({ index: 0, hardened: true }),
new PathComponent({ index: 0, hardened: false }),
new PathComponent({ index: 0, hardened: false }),
]);
UR例子
ur:crypto-keypath/xxxxx