# @digitalbazaar/eddsa-jcs-2022-cryptosuite 中文文档

规范地址：https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/

版本：1\.0\.0
npm 元数据更新时间：2025-02-14T21:39:56.140Z
中文译文更新时间：2026-11-12T08:41:59.189Z
软件包许可：BSD-3-Clause

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

原始 npm 页面：https://www.npmjs.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite
原文对照：https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/?lang=original
项目主页：https://github.com/digitalbazaar/eddsa-jcs-2022-cryptosuite
源码仓库：https://github.com/digitalbazaar/eddsa-jcs-2022-cryptosuite

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

- 包体积（解压后）：14.3 kB，10 个文件
- 模块格式：ES Module
- TypeScript 类型：未声明
- Node.js 要求：\>=18
- 运行依赖：2 个
- 首次发布：2024-11-08T17:34:31.910Z
- 最新版本发布：2024-11-08T17:34:32.260Z
- 近 30 天下载量：11834（2026-10-12 至 2026-11-10，npm 官方下载统计）
- 已发布版本数：1（近 12 个月 0 个）

## 中文简介

EdDSA-JCS-2022 数据完整性密码套接字.

## 安装

```sh
npm install @digitalbazaar/eddsa-jcs-2022-cryptosuite
```

也可以使用：`pnpm add @digitalbazaar/eddsa-jcs-2022-cryptosuite`、`yarn add @digitalbazaar/eddsa-jcs-2022-cryptosuite`、`bun add @digitalbazaar/eddsa-jcs-2022-cryptosuite`

## README

# EdDSA JCS 2022 数据完整性密码套件 _(@digitalbazaar/eddsa-jcs-2022-cryptosuite) (中文(简体) )_

[![Build status](https://img.shields.io/github/actions/workflow/status/digitalbazaar/eddsa-jcs-2022-cryptosuite/main.yml)](https://github.com/digitalbazaar/eddsa-jcs-2022-cryptosuite/actions?query=workflow%3A%22Node.js+CI%22) [![Coverage status](https://img.shields.io/codecov/c/github/digitalbazaar/eddsa-jcs-2022-cryptosuite)](https://codecov.io/gh/digitalbazaar/eddsa-jcs-2022-cryptosuite) [![NPM Version](https://img.shields.io/npm/v/@digitalbazaar/eddsa-jcs-2022-cryptosuite.svg)](https://npm.im/@digitalbazaar/eddsa-jcs-2022-cryptosuite)

> EdDSA 2022 数据完整性 Cryptosuite.

## 目录

-   [背景情况](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-background)
-   [警卫](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-security)
-   [安装](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-install)
-   [使用量](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-usage)
-   [贡献](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-contribute)
-   [商业支助](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-commercial-support)
-   [许可证](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/#readme-license)

## 背景情况

用于与 [https://github.com/digitalbazaar/jsonld-signers (中文(简体) )](https://github.com/digitalbazaar/jsonld-signatures) v11.0及以上编.

另见相关的规格:

-   [可验证的可信数据完整性](https://w3c.github.io/vc-data-integrity/)

## 警卫

传统发展

## 安装

-   浏览器和Node.js 16+得到支持.

从国家预防机制安装:

```
npm install @digitalbazaar/eddsa-jcs-2022-cryptosuite
```

在当地安装(用于开发):

```
git clone https://github.com/digitalbazaar/eddsa-jcs-2022-cryptosuite.git
cd eddsa-jcs-2022-cryptosuite
npm install
```

## 使用量

以下代码片段提供了一个完整的数字签名示例 使用此库的可核查证书:

```javascript
import * as Ed25519Multikey from '@digitalbazaar/ed25519-multikey';
import {DataIntegrityProof} from '@digitalbazaar/data-integrity';
import {createSignCryptosuite} from '@digitalbazaar/eddsa-jcs-2022-cryptosuite';
import jsigs from 'jsonld-signatures';
const {purposes: {AssertionProofPurpose}} = jsigs;


// create the unsigned credential
const unsignedCredential = {
  '@context': [
    'https://www.w3.org/2018/credentials/v1',
    {
      AlumniCredential: 'https://schema.org#AlumniCredential',
      alumniOf: 'https://schema.org#alumniOf'
    }
  ],
  id: 'http://example.edu/credentials/1872',
  type: [ 'VerifiableCredential', 'AlumniCredential' ],
  issuer: 'https://example.edu/issuers/565049',
  issuanceDate: '2010-01-01T19:23:24Z',
  credentialSubject: {
    id: 'https://example.edu/students/alice',
    alumniOf: 'Example University'
  }
};

// create the keypair to use when signing
const controller = 'https://example.edu/issuers/565049';
const keyPair = await Ed25519Multikey.from({
  '@context': 'https://w3id.org/security/multikey/v1',
  type: 'Multikey',
  controller,
  id: controller + '#z6MkwXG2WjeQnNxSoynSGYU8V9j3QzP3JSqhdmkHc6SaVWoT',
  publicKeyMultibase: 'z6MkwXG2WjeQnNxSoynSGYU8V9j3QzP3JSqhdmkHc6SaVWoT',
  secretKeyMultibase: 'zrv3rbPamVDGvrm7LkYPLWYJ35P9audujKKsWn3x29EUiGwwhdZQd' +
    '1iHhrsmZidtVALBQmhX3j9E5Fvx6Kr29DPt6LH'
});

// export public key and add to document loader
const publicKey = await keyPair.export({publicKey: true, includeContext: true});
addDocumentToLoader({url: publicKey.id, document: publicKey});

// create key's controller document
const controllerDoc = {
  '@context': [
    'https://www.w3.org/ns/did/v1',
    'https://w3id.org/security/multikey/v1'
  ],
  id: controller,
  assertionMethod: [publicKey]
};
addDocumentToLoader({url: controllerDoc.id, document: controllerDoc});

// create suite
const eddsaJcs2022CryptoSuite = createSignCryptosuite();
const suite = new DataIntegrityProof({
  signer: keyPair.signer(), cryptosuite: eddsaJcs2022CryptoSuite
});

// create signed credential
const signedCredential = await jsigs.sign(unsignedCredential, {
  suite,
  purpose: new AssertionProofPurpose(),
  documentLoader
});

// results in the following signed VC
{
  "@context": [
    "https://www.w3.org/2018/credentials/v1",
    {
      "AlumniCredential": "https://schema.org#AlumniCredential",
      "alumniOf": "https://schema.org#alumniOf"
    },
    "https://w3id.org/security/data-integrity/v2"
  ],
  "id": "http://example.edu/credentials/1872",
  "type": [
    "VerifiableCredential",
    "AlumniCredential"
  ],
  "issuer": "https://example.edu/issuers/565049",
  "issuanceDate": "2010-01-01T19:23:24Z",
  "credentialSubject": {
    "id": "https://example.edu/students/alice",
    "alumniOf": "Example University"
  },
  "proof": {
    "type": "DataIntegrityProof",
    "created": "2022-09-06T21:29:24Z",
    "verificationMethod": "https://example.edu/issuers/565049#z6MkwXG2WjeQnNxSoynSGYU8V9j3QzP3JSqhdmkHc6SaVWoT",
    "cryptosuite": "eddsa-jcs-2022",
    "proofPurpose": "assertionMethod",
    "@context": [
      "https://www.w3.org/2018/credentials/v1",
      {
        "AlumniCredential": "https://schema.org#AlumniCredential",
        "alumniOf": "https://schema.org#alumniOf"
      },
      "https://w3id.org/security/data-integrity/v2"
    ],
    "proofValue": "z3aKfEmARJBuiiBcmGtzPh5ZHaGm9EAehkyVRDJGRxnTJQwqpdoktM6CD8aJii1RobA34gjVcdSQ7cURYcXtEkav2"
  }
}
```

## 贡献

见 [贡献文件](https://github.com/digitalbazaar/bedrock/blob/master/CONTRIBUTING.md)来啊!

公关接受.

请遵照 [标准读取](https://github.com/RichardLitt/standard-readme) 规格.

## 商业支助

该图书馆的商务支助可应下列请求提供: 数字集市: [支持@ digitalbazaar.com](mailto:support@digitalbazaar.com)

## 许可证

[新建 BSD 许可证( 3- clause)](https://npmcn.com/package/%40digitalbazaar/eddsa-jcs-2022-cryptosuite/LICENSE) 2023年数字集市

## 常见问题

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 是什么？

EdDSA-JCS-2022 数据完整性密码套接字\.

### 如何安装 @digitalbazaar/eddsa-jcs-2022-cryptosuite？

在项目目录运行 npm install @digitalbazaar/eddsa-jcs-2022-cryptosuite，或使用 pnpm add / yarn add / bun add。

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 支持 TypeScript 吗？

该包的 package\.json 没有声明类型入口。需要类型提示时，可以在 npm 上查找社区维护的 @types/digitalbazaar\_\_eddsa-jcs-2022-cryptosuite 是否存在。

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 支持 ESM 还是 CommonJS？

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

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 需要什么版本的 Node\.js？

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

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 可以商用吗？

@digitalbazaar/eddsa-jcs-2022-cryptosuite 使用 BSD-3-Clause 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。另外不得用原作者名义为衍生产品背书。以上为概括，不构成法律意见，请以许可原文为准。

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 的下载量有多少？

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

### @digitalbazaar/eddsa-jcs-2022-cryptosuite 还在维护吗？

最新版本 1\.0\.0 发布于 2024/11/09（2 年前）；至今共发布 1 个版本，其中过去 12 个月发布了 0 个；首次发布于 2024/11/09。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

