X25519 关键协定Key2019 (@digitalbazaar/x25519-key-agreement-key-2019) (中文(简体) )
An X25519 (Curve25519) DH (Diffie-Hellman) 关键执行 与加密的LDKeyPair API合作.
目录
警卫
传统发展
背景情况
用于与 crypto-ld >= 5.0。 。 。 .
为了真正用这些密钥进行加密,我们建议您使用
页:1 minimal-cipher 图书馆.
这是一个低级库,用于生成并序列化 X25519 (Curve25519)
密钥对( 使用) nacl.box 盖下.
另见(相关规格):
安装
需要节点.js 12+
在当地安装(用于开发):
git clone https://github.com/digitalbazaar/x25519-key-agreement-key-2019.git
cd x25519-key-agreement-key-2019
npm install
使用量
导入中 :
const {X25519KeyAgreementKey2019} = require('@digitalbazaar/x25519-key-agreement-key-2019');
// Or, if you're testing code in the interactive Node CLI, right in this repo:
const {X25519KeyAgreementKey2019} = require('./');
生成中 :
const keyPair = await X25519KeyAgreementKey2019.generate({
controller: 'did:example:1234'
});
将公钥序列化 :
keyPair.export({publicKey: true});
// ->
{
id: 'did:example:1234#z6LSbh9HiAU2zzBdFMdKZGHfg1UjvAYF8C8kYnkfGKuCxYEB',
type: 'X25519KeyAgreementKey2019',
controller: 'did:example:1234',
publicKeyBase58: '1y8BrfAuXTt9yFZ2cmiMRGG5218Raxbfp2ymsFgFATR'
}
私人和公共钥匙的序列:
// a different key pair than the previous example
await keyPair.export({publicKey: true, privateKey: true})
// ->
{
id: 'did:example:1234#z6LSjeJZaUHMvEKW7tEJXV4PrSm61NzxxHhDXF6zHnVtDu9g',
type: 'X25519KeyAgreementKey2019',
controller: 'did:example:1234',
publicKeyBase58: '8y8Q4AUVpmbm2VrXzqYSXrYcAETrFgX4eGPJoKrMWXNv',
privateKeyBase58: '95tmYuhqSuJqY77FEg78Zy3LFQ1cENxGv2wMvayk7Lqf'
}
切换 :
// Loading public key only
const keyPair = await X25519KeyAgreementKey2019.from({
id: 'did:example:1234#z6LSjeJZaUHMvEKW7tEJXV4PrSm61NzxxHhDXF6zHnVtDu9g',
type: 'X25519KeyAgreementKey2019',
controller: 'did:example:1234',
publicKeyBase58: '8y8Q4AUVpmbm2VrXzqYSXrYcAETrFgX4eGPJoKrMWXNv'
});
贡献
见 贡献文件来啊!
公关接受.
请遵照 标准读取 规格.
商业支助
该图书馆的商务支助可应下列请求提供: 数字集市: 支持@ digitalbazaar.com