# @frostr/bifrost 中文文档

规范地址：https://npmcn.com/package/%40frostr/bifrost/

版本：2\.0\.2
npm 元数据更新时间：2026-11-08T13:59:52.721Z
中文译文更新时间：2026-11-15T15:44:46.437Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40frostr/bifrost
原文对照：https://npmcn.com/package/%40frostr/bifrost/?lang=original
项目主页：https://github.com/frostr-org/bifrost#readme
源码仓库：https://github.com/frostr-org/bifrost

弃用说明：SECURITY: Multi-hash signing in 2\.0\.2 reuses nonces and can expose secret shares and the full signing key\. This legacy TypeScript SDK is deprecated\. Every signer must reject sessions unless they contain exactly one hash\. See https://github\.com/FROSTR-ORG/bifrost\#readme for details and the bifrost-rs successor\.

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：5.4 MB，118 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：10 个
- 首次发布：2025-02-13T02:38:56.776Z
- 最新版本发布：2026-01-25T05:53:19.012Z
- 近 30 天下载量：4273（2026-10-16 至 2026-11-14，npm 官方下载统计）
- 已发布版本数：20（近 12 个月 1 个）

## 中文简介

FROSTER协议的参考节点和库.

## 安装

```sh
npm install @frostr/bifrost
```

也可以使用：`pnpm add @frostr/bifrost`、`yarn add @frostr/bifrost`、`bun add @frostr/bifrost`

## README

# 冰冻

> FROSTR 的 SDK 阈值签名 - 使用 Nostr接力分配密钥保管

[![npm version](https://img.shields.io/npm/v/@frostr/bifrost)](https://www.npmjs.com/package/@frostr/bifrost) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://npmcn.com/package/%40frostr/bifrost/LICENSE) [![TypeScript](https://img.shields.io/badge/TypeScript-5.0+-blue.svg)](https://www.typescriptlang.org/)

## 什么是FROSTER吗?

**弗罗斯特** (Frost Over Nostr)是一种阈值加密协议,它能够使用以Nostr中继为通信层来进行分布式密钥保管. 它执行灵活圆-优化的Schnorr阈值(FROST)签名计划.

**问题**: 传统密钥管理产生单一的失败点. 如果一个私人钥匙被损坏、丢失或被一个没有的当事方所持有,则失去获得资金或签字的能力.

**解决办法**: 阈值签名将一键分割为多股,分布于不同方. M-of-N股东必须合作制作签名. 没有一方拥有完整的钥匙,即使在签署期间。 由此产生的签名是标准的BIP-340 Schnor签名——与由单一签名人制作的签名不可区分.

**为什么是诺斯特?** 诺斯特提供了一个分散的中继网络,已经为消息传递进行了战斗测试. FROSTER利用这一现有的基础设施进行对等通信,端到端加密确保中继操作员永远看不到消息内容.

## 特征

-   **阈值签名**: M-o-of-N 签字时没有一方持有完整的密钥
-   **ECDH 密钥交换**:合作获取共同机密
-   **端到端加密**: 所有对等通讯都加密到 Chacha20-Poly1305
-   **鼻孔传输**: 使用现有的中继基础设施进行分散通信
-   **BIP-340 可兼容**: 制作可用于比特币和诺斯特尔的标准Schnor签名
-   **类型脚本第一**: 启用严格模式的完整类型安全

## 安装

```bash
npm install @frostr/bifrost
```

## 快速示例

```typescript
import { BifrostNode }             from '@frostr/bifrost'
import { generate_dealer_package } from '@frostr/bifrost/lib'

// Generate a 2-of-3 threshold group
const { group, shares } = generate_dealer_package(2, 3)

// Create and connect a node
const node = new BifrostNode(group, shares[0], ['wss://relay.example.com'])
await node.connect()

// Exchange nonces with a peer
await node.req.ping(shares[1].pubkey)

// Request a threshold signature
const result = await node.req.sign('Hello FROSTR!')

if (!result.ok) throw new Error('signing failed!')

console.log('Signature:', result.data)
```

见 [指南](https://npmcn.com/package/%40frostr/bifrost/docs/GUIDE.md) 用于完整的例子.

## API 概览

| 方法 | 说明 |
| --- | --- |
| `node.req.sign(message)` | 请求阈值签名 |
| `node.req.sign_batch(messages)` | 请求多个阈值签名 |
| `node.req.ecdh(pubkey)` | ECDH 协作关键交换 |
| `node.req.ecdh_batch(pubkeys)` | 批量 ECDH 键交换多个密钥 |
| `node.req.ping(peer)` | 平平对等和交换非对等 |
| `node.req.echo(message)` | 测试中继连接 |
| `node.req.onboard(pubkey)` | 装入有组证书的新端点 |

见 [API 参考](https://npmcn.com/package/%40frostr/bifrost/docs/API.md) 用于完整文档.

## 活动

BifrostNode 为生命周期和操作发射输入的事件 :

### 生命周期事件

| 活动 | 有效载荷 | 说明 |
| --- | --- | --- |
| `ready` | `BifrostNode` | 节点连接并准备运行 |
| `closed` | `BifrostNode` | 节点断开 |
| `message` | `RpcMessageData` | 收到原始消息( 用于调试) |
| `bounced` | `[reason, msg]` | 信件被拒绝( 未经授权或无效) |

### 签名事件

| 活动 | 有效载荷 | 说明 |
| --- | --- | --- |
| `/sign/sender/req` | `SignSessionPackage` | 向同行发送签名请求 |
| `/sign/sender/res` | `PartialSigPackage[]` | 从同行收到的部分签名 |
| `/sign/sender/sig` | `[SignatureEntry[], msgs]` | 最后签名合计 |
| `/sign/sender/rej` | `[reason, session]` | 签名请求阶段失败 |
| `/sign/sender/err` | `[reason, msgs]` | 签名聚合失败 |
| `/sign/handler/req` | `msg` | 端点收到的签名请求 |
| `/sign/handler/res` | `msg` | 向请求者发送部分签名 |
| `/sign/handler/rej` | `[reason, msg]` | 签名请求被拒绝 |

### ECDH 活动

| 活动 | 有效载荷 | 说明 |
| --- | --- | --- |
| `/ecdh/sender/res` | `msgs` | 从同行收到的ECDH份额 |
| `/ecdh/sender/ret` | `[ecdh_pk, secret]` | 共享秘密来源 |
| `/ecdh/sender/rej` | `[reason, pkg]` | ECDH 请求阶段失败 |
| `/ecdh/sender/err` | `[reason, msgs]` | ECDH 生成失败 |
| `/ecdh/handler/req` | `msg` | 同行提出的ECDH请求 |
| `/ecdh/handler/res` | `msg` | ECDH 共享发送给请求者 |
| `/ecdh/handler/rej` | `[reason, msg]` | 驳回欧洲人权法院的请求 |

## 文档

| 文档 | 说明 |
| --- | --- |
| [指南](https://npmcn.com/package/%40frostr/bifrost/docs/GUIDE.md) | 从代码示例和交互式演示开始 |
| [API 参考](https://npmcn.com/package/%40frostr/bifrost/docs/API.md) | 完整的 API 文档 |
| [担保模式](https://npmcn.com/package/%40frostr/bifrost/docs/SECURITY.md) | 威胁模式、保障和部署指导 |
| [技术文件](https://npmcn.com/package/%40frostr/bifrost/docs/INDEX.md) | 建筑、协议和密码 |

## 发展

```bash
npm install        # Install dependencies
npm test           # Run test suite
npm run build      # Build for production
```

### 交互式演示

见正在采取行动的议定书:

```bash
npm run demo:keygen   # Generate test credentials
npm run demo          # Launch 4-pane tmux demo (auto-cleanup on close)
```

见 [指南](https://npmcn.com/package/%40frostr/bifrost/docs/GUIDE.md) 需要完整的指示.

## 捐款

欢迎捐款! 请:

1.  在开始工作前打开一个讨论重大变革的问题
2.  叉开存储器并创建一个特性分支
3.  新功能的写入测试
4.  确保所有测试合格(`npm test`(中文(简体) )
5.  提交带有清晰描述的拉动请求

## 警卫

见 [警卫](https://npmcn.com/package/%40frostr/bifrost/docs/SECURITY.md) 用于:

-   威胁模式和安全保障
-   FROSTTR 所保护的(和它没有的)
-   安全部署清单
-   报告安全弱点

## 许可证

麻省理工学院执照 - 看 [自由主义](https://npmcn.com/package/%40frostr/bifrost/LICENSE) 详细情况.

## 承认

-   [冷冻纸](https://eprint.iacr.org/2020/852) 由切尔西·科姆洛和伊恩·戈德伯格主演
-   [贵族密码学](https://paulmillr.com/noble/) 保罗·米勒著
-   [诺斯特协议](https://github.com/nostr-protocol/nostr) 社区

## 常见问题

### @frostr/bifrost 是什么？

FROSTER协议的参考节点和库\.注意：该包已被作者标记为弃用——SECURITY: Multi-hash signing in 2\.0\.2 reuses nonces and can expose secret shares and the full signing key\. This legacy TypeScript SDK is deprecated\. Every signer must reject sessions unless they contain exactly one hash\. See https://github\.com/FROSTR-ORG/bifrost\#readme for details and the bifrost-rs successor\.

### 如何安装 @frostr/bifrost？

在项目目录运行 npm install @frostr/bifrost，或使用 pnpm add / yarn add / bun add。

### @frostr/bifrost 支持 TypeScript 吗？

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

### @frostr/bifrost 支持 ESM 还是 CommonJS？

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

### @frostr/bifrost 可以商用吗？

@frostr/bifrost 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @frostr/bifrost 的下载量有多少？

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

### @frostr/bifrost 还在维护吗？

最新版本 2\.0\.2 发布于 2026/01/25（9 个月前）；至今共发布 20 个版本，其中过去 12 个月发布了 1 个；首次发布于 2025/02/13。作者已将其标记为弃用，新项目建议寻找替代方案。

