第10条
此软件包是用于处理 SLIP10 密钥。 。 。 .
注:目前仅支持曲线Ed25519.
安装
pnpm add @exodus/slip10
使用量
SLIP10. 从种子(种子:Buffer QQUint8 Array) 出道
从种子创建主密钥
import SLIP10 from '@exodus/slip10'
const seed = Buffer.from(
'fffcf9f6f3f0edeae7e4e1dedbd8d5d2cfccc9c6c3c0bdbab7b4b1aeaba8a5a29f9c999693908d8a8784817e7b7875726f6c696663605d5a5754514e4b484542',
'hex'
)
const key = SLIP10.fromSeed(seed)
// `key` is an instance of SLIP10
SLIP10. from XPriv({ key, 链码})
从扩展的私人密钥导入 SLIP10 密钥, 由导出 键。to JSON ()。 。 。 .
import SLIP10 from '@exodus/slip10'
const key = SLIP10.fromXPriv({
chainCode: '5d70af781f3a37b829f0d060924d5e960bdc02e85423494afc0b1a41bbe196d4',
key: '551d333177df541ad876a60ea71f00447931c0a9da16f227c11ea080d7391b8d',
})
// `key` is an instance of SLIP10
键. devictive(路径:字符串)
const childKey = key.derive(`m/0'/0'`)
// `childKey` is an instance of SLIP10
密钥
找到私钥缓冲器.
const { privateKey } = key
键。公钥
给公用钥匙缓冲器.
const { publicKey } = key
键。to JSON ()
出口私钥数据.
const {
xpriv: {
// hex string
key,
// hex string
chainCode,
},
} = key.toJSON()
键.wipe privateData ()
擦去私钥数据的内部引用.
key.privateKey // Buffer
key.chainCode // Buffer
key.wipePrivateData()
key.privateKey // undefined
key.chainCode // undefined