@chainsafe/libp2p-noise

中文文档
17.0.0发布于 2025/09/25Apache-2.0 OR MITTypeScriptES Module构建来源已验证近 30 天下载 29.5万

Noise libp2p handshake for js-libp2p

原始使用文档
文档目录4 节
  1. Usage
  2. API
  3. Bring your own crypto
  4. Browser <script> tag

@chainsafe/libp2p-noise

npm License Apache 2.0 License MIT Twitter Discord

Noise libp2p handshake for js-libp2p

About

This repository contains TypeScript implementation of noise protocol, an encryption protocol used in libp2p.

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 {createLibp2p} from "libp2p"
import {noise} from "@chainsafe/libp2p-noise"

//custom noise configuration, pass it instead of `noise()`
//x25519 private key
const n = noise({ staticNoiseKey });

const libp2p = await createLibp2p({
  connectionEncrypters: [noise()],
  //... other options
})

See the NoiseInit interface for noise configuration options.

API

This module exposes an implementation of the ConnectionEncrypter interface.

Bring your own crypto

You can provide a custom crypto implementation (instead of the default, based on @noble) by adding a crypto field to the init argument passed to the Noise factory.

The implementation must conform to the ICryptoInterface, defined in https://github.com/ChainSafe/js-libp2p-noise/blob/master/src/crypto.ts

Install

$ npm i @chainsafe/libp2p-noise

Browser <script> tag

Loading this module through a script tag will make its exports available as ChainsafeLibp2pNoise in the global namespace.

<script src="https://unpkg.com/@chainsafe/libp2p-noise/dist/index.min.js"></script>

API Docs

License

Licensed under either of

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

版本与发布记录

@chainsafe/libp2p-noise 共发布 55 个版本,首次发布于 2021/07/29;过去 12 个月发布了 0 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
17.0.0latest2025/09/251.1 年前
16.1.52025/09/231.1 年前
16.1.42025/06/261.4 年前
16.1.32025/04/231.5 年前
16.1.22025/04/161.6 年前
16.1.12025/04/161.6 年前

关于 @chainsafe/libp2p-noise 的常见问题

@chainsafe/libp2p-noise 是什么?

Noise libp2p handshake for js-libp2p

如何安装 @chainsafe/libp2p-noise?

在项目目录运行 npm install @chainsafe/libp2p-noise,或使用 pnpm add / yarn add / bun add。

@chainsafe/libp2p-noise 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@chainsafe/libp2p-noise 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@chainsafe/libp2p-noise 可以商用吗?

@chainsafe/libp2p-noise 使用 Apache-2.0 OR MIT 许可。可在 Apache-2.0、MIT 中任选其一遵守。选择 Apache-2.0 时,宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@chainsafe/libp2p-noise 的下载量有多少?

根据 npm 官方下载统计,@chainsafe/libp2p-noise 在 2026/10/10 – 2026/11/08 这 30 天内被下载 295,372 次,日均约 9,846 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@chainsafe/libp2p-noise 还在维护吗?

最新版本 17.0.0 发布于 2025/09/25(1.1 年前);至今共发布 55 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/07/29。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。