@achingbrain/libp2p-noise 中文文档教程
js-libp2p-noise
js-libp2p 的噪声 libp2p 握手
这个存储库包含噪声协议的 TypeScript 实现,噪声协议是 libp2p 中使用的加密协议。
Warning: Even though this package works in browser, it will bundle around 600Kb (200Kb gzipped) of code
https://bundlephobia.com/result?p=@chainsafe/libp2p-noise@latest
Usage
使用 yarn add @chainsafe/libp2p-noise
或 npm i @chainsafe/libp2p-noise< 安装/代码>。
使用默认噪声配置并将其传递给 libp2p 配置的示例:
import {NOISE, Noise} from "@chainsafe/libp2p-noise"
//custom noise configuration, pass it instead of NOISE instance
const noise = new Noise(privateKey, Buffer.alloc(x));
const libp2p = new Libp2p({
modules: {
connEncryption: [NOISE],
},
});
噪声构造函数的参数为:
- static Noise key - (optional) existing private Noise static key
- early data - (optional) an early data payload to be sent in handshake messages
API
该模块公开了一个加密接口,如存储库
Contribute
欢迎加入。 开个issue!
License
js-libp2p-noise
Noise libp2p handshake for js-libp2p
This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.
Warning: Even though this package works in browser, it will bundle around 600Kb (200Kb gzipped) of code
https://bundlephobia.com/result?p=@chainsafe/libp2p-noise@latest
Usage
Install with yarn add @chainsafe/libp2p-noise
or npm i @chainsafe/libp2p-noise
.
Example of using default noise configuration and passing it to the libp2p config:
import {NOISE, Noise} from "@chainsafe/libp2p-noise"
//custom noise configuration, pass it instead of NOISE instance
const noise = new Noise(privateKey, Buffer.alloc(x));
const libp2p = new Libp2p({
modules: {
connEncryption: [NOISE],
},
});
Where parameters for Noise constructor are:
- static Noise key - (optional) existing private Noise static key
- early data - (optional) an early data payload to be sent in handshake messages
API
This module exposes a crypto interface, as defined in the repository js-interfaces.
Contribute
Feel free to join in. All welcome. Open an issue!