@frostr/bifrost

中文文档
2.0.2发布于 2026/01/25MITTypeScriptES Module近 30 天下载 4273

Reference node and library for the FROSTR protocol.

此软件包已被标记为弃用

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.

原始使用文档
文档目录16 节
  1. What is FROSTR?
  2. Features
  3. Installation
  4. Quick Example
  5. API Overview
  6. Events
  7. Lifecycle Events
  8. Signature Events
  9. ECDH Events
  10. Documentation
  11. Development
  12. Interactive Demo
  13. Contributing
  14. Security
  15. License
  16. Acknowledgments

Bifrost

Threshold signing SDK for FROSTR - Distributed key custody using Nostr relays

npm version License: MIT TypeScript

What is FROSTR?

FROSTR (Frost Over Nostr) is a threshold cryptography protocol that enables distributed key custody using Nostr relays as the communication layer. It implements the FROST (Flexible Round-Optimized Schnorr Threshold) signature scheme.

The problem: Traditional key management creates single points of failure. If a private key is compromised, lost, or held by a single party that becomes unavailable, access to funds or signing capability is lost.

The solution: Threshold signatures split a key into multiple shares distributed among different parties. M-of-N shareholders must collaborate to produce a signature. No single party ever possesses the complete key, even during signing. The resulting signature is a standard BIP-340 Schnorr signature - indistinguishable from one produced by a single signer.

Why Nostr? Nostr provides a decentralized relay network that's already battle-tested for message passing. FROSTR leverages this existing infrastructure for peer communication, with end-to-end encryption ensuring relay operators never see message contents.

Features

  • Threshold Signing: M-of-N signing where no single party holds the complete key
  • ECDH Key Exchange: Collaborative derivation of shared secrets
  • End-to-End Encryption: All peer communication encrypted with ChaCha20-Poly1305
  • Nostr Transport: Uses existing relay infrastructure for decentralized communication
  • BIP-340 Compatible: Produces standard Schnorr signatures usable on Bitcoin and Nostr
  • TypeScript First: Full type safety with strict mode enabled

Installation

npm install @frostr/bifrost

Quick Example

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)

See the Guide for complete examples.

API Overview

MethodDescription
node.req.sign(message)Request threshold signature
node.req.sign_batch(messages)Request multiple threshold signatures
node.req.ecdh(pubkey)Collaborative ECDH key exchange
node.req.ecdh_batch(pubkeys)Batch ECDH key exchange for multiple pubkeys
node.req.ping(peer)Ping peer and exchange nonces
node.req.echo(message)Test relay connectivity
node.req.onboard(pubkey)Onboard a new peer with group credentials

See API Reference for full documentation.

Events

BifrostNode emits typed events for lifecycle and operations:

Lifecycle Events

EventPayloadDescription
readyBifrostNodeNode connected and ready for operations
closedBifrostNodeNode disconnected
messageRpcMessageDataRaw message received (for debugging)
bounced[reason, msg]Message rejected (unauthorized or invalid)

Signature Events

EventPayloadDescription
/sign/sender/reqSignSessionPackageSignature request sent to peers
/sign/sender/resPartialSigPackage[]Partial signatures received from peers
/sign/sender/sig[SignatureEntry[], msgs]Final signatures aggregated
/sign/sender/rej[reason, session]Signature request phase failed
/sign/sender/err[reason, msgs]Signature aggregation failed
/sign/handler/reqmsgIncoming sign request from peer
/sign/handler/resmsgPartial signature sent to requester
/sign/handler/rej[reason, msg]Sign request rejected

ECDH Events

EventPayloadDescription
/ecdh/sender/resmsgsECDH shares received from peers
/ecdh/sender/ret[ecdh_pk, secret]Shared secret derived
/ecdh/sender/rej[reason, pkg]ECDH request phase failed
/ecdh/sender/err[reason, msgs]ECDH derivation failed
/ecdh/handler/reqmsgIncoming ECDH request from peer
/ecdh/handler/resmsgECDH share sent to requester
/ecdh/handler/rej[reason, msg]ECDH request rejected

Documentation

DocumentDescription
GuideGetting started with code examples and interactive demo
API ReferenceFull API documentation
Security ModelThreat model, guarantees, and deployment guidance
Technical DocsArchitecture, protocol, and cryptography

Development

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

Interactive Demo

See the protocol in action:

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

See Guide for full instructions.

Contributing

Contributions are welcome! Please:

  1. Open an issue to discuss significant changes before starting work
  2. Fork the repository and create a feature branch
  3. Write tests for new functionality
  4. Ensure all tests pass (npm test)
  5. Submit a pull request with a clear description

Security

See SECURITY.md for:

  • Threat model and security guarantees
  • What FROSTR protects against (and what it doesn't)
  • Secure deployment checklist
  • Reporting security vulnerabilities

License

MIT License - see LICENSE for details.

Acknowledgments

版本与发布记录

@frostr/bifrost 共发布 20 个版本,首次发布于 2025/02/13;过去 12 个月发布了 1 个版本。

版本发布日期距今
2.0.2latest2026/01/259 个月前
1.0.72025/05/231.5 年前
1.0.62025/05/231.5 年前
1.0.52025/05/231.5 年前
1.0.42025/05/231.5 年前
1.0.32025/05/231.5 年前

关于 @frostr/bifrost 的常见问题

@frostr/bifrost 是什么?

Reference node and library for the FROSTR protocol.注意:该包已被作者标记为弃用——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。作者已将其标记为弃用,新项目建议寻找替代方案。