@achingbrain/libp2p-noise 中文文档教程

发布于 3年前 浏览 19 项目主页 更新于 3年前

js-libp2p-noise

npm CI

Discourse 帖子

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-noisenpm 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

该模块公开了一个加密接口,如存储库

» API 文档

Contribute

欢迎加入。 开个issue!

License

麻省理工学院

js-libp2p-noise

npm CI

Discourse posts

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.

» API Docs

Contribute

Feel free to join in. All welcome. Open an issue!

License

MIT

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文