@digitalcredentials/keypair

中文文档
3.0.0发布于 2025/10/16MITTypeScriptES Module近 30 天下载 2.1万

Cryptographic key pair data model in Javascript/Typescript, for Node.js, browsers, and React Native. Useful for Verifiable Credentials, DIDs (Decentralized Identifiers), and other uses of Data Integrity.

原始使用文档
文档目录10 节
  1. Table of Contents
  2. Background
  3. Choosing a Key Type
  4. Security
  5. Install
  6. NPM
  7. Development
  8. Usage
  9. Contribute
  10. License

Cryptographic Key Pair (@digitalcredentials/keypair)

Node.js CI NPM Version

Cryptographic key pair data model in Javascript/Typescript, for Node.js, browsers, and React Native. Useful for Verifiable Credentials, DIDs (Decentralized Identifiers), and other uses of Data Integrity.

Table of Contents

Background

Extracted from Digital Bazaar's crypto-ld library, and converted to Typescript.

This is an abstract key pair data model, meant to be used in individual subclass key pair implementations, such as:

Choosing a Key Type

For digital signatures using the linked-data-integrity library, signing of Verifiable Credentials using vc library, authorization capabilities, and DIDAuth operations:

  • Prefer Ed25519VerificationKey2020 type keys, by default.
  • Use EcdsaSepc256k1 keys if your use case requires it (for example, if you're developing for a Bitcoin-based or Ethereum-based ledger), or if you require Hierarchical Deterministic (HD) wallet functionality.

For key agreement protocols for encryption operations:

Security

As with most security- and cryptography-related tools, the overall security of your system will largely depend on your design decisions.

Install

  • Node.js 16+ is recommended.

NPM

To install via NPM:

npm install @digitalcredentials/keypair

Development

To install locally (for development):

git clone https://github.com/digitalcredentials/keypair.git
cd keypair
npm install

Usage

This library is meant to be used only by implementers of new cryptographic key suite libraries.

When adding support for a new suite type subclass of keypair, developers should do the following:

  1. Create their own npm package / Github repo, such as example-key-pair.
  2. Subclass KeyPair.
  3. Override relevant methods (such as export() and fingerprint()).
  4. Add to the key type table in the crypto-suite-manager README.md.

Contribute

PRs accepted.

If editing the Readme, please conform to the standard-readme specification.

License

MIT License © 2022 Digital Credentials Consortium.

版本与发布记录

@digitalcredentials/keypair 共发布 13 个版本,首次发布于 2022/12/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
3.0.0latest2025/10/161.1 年前
2.0.52025/05/011.5 年前
2.0.42025/04/301.5 年前
2.0.32025/04/301.5 年前
2.0.22025/04/301.5 年前
2.0.12025/04/301.5 年前

关于 @digitalcredentials/keypair 的常见问题

@digitalcredentials/keypair 是什么?

Cryptographic key pair data model in Javascript/Typescript, for Node.js, browsers, and React Native. Useful for Verifiable Credentials, DIDs (Decentralized Identifiers), and other uses of Data Integrity.

如何安装 @digitalcredentials/keypair?

在项目目录运行 npm install @digitalcredentials/keypair,或使用 pnpm add / yarn add / bun add。

@digitalcredentials/keypair 支持 TypeScript 吗?

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

@digitalcredentials/keypair 支持 ESM 还是 CommonJS?

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

@digitalcredentials/keypair 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=18.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@digitalcredentials/keypair 可以商用吗?

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

@digitalcredentials/keypair 的下载量有多少?

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

@digitalcredentials/keypair 还在维护吗?

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