跳到主要内容

导出与解锁

导出会创建完整文档。解锁是唯一返回私钥材料的操作;返回前它会用存储的公钥验证恢复出的私钥。

const encoded = await exportPrivateKey(input);
const document = parseDocument(encoded);
const result = await unlockDocument(document, password);
// result.privateKey 是 Uint8Array;只在需要时保留于内存。

如果调用方已经拥有加密字节并只需要规范化序列化,可以使用 exportEncryptedState。它不需要密码或明文私钥。