@digitalcredentials/ed25519-signature-2020

中文文档
7.0.0发布于 2025/04/30BSD-3-ClauseES Module近 30 天下载 2.3万

Ed25519Signature2020 Linked Data Proof suite for use with jsonld-signatures.

原始使用文档
文档目录7 节
  1. Table of Contents
  2. Background
  3. Security
  4. Install
  5. Usage
  6. Contribute
  7. License

Ed25519Signature2020 suite (@digitalcredentials/ed25519-signature-2020)

Build status NPM Version

Ed25519Signature2020 Linked Data Proof suite for use with jsonld-signatures.

Table of Contents

Background

(Forked from digitalbazaar/ed25519-signature-2020 v3.0.0 to provide TypeScript compatibility.)

For use with https://github.com/digitalbazaar/jsonld-signatures v9.0 and above.

See also related specs:

Security

TBD

Install

  • Node.js 14+ is required.

To install locally (for development):

git clone https://github.com/digitalcredentials/ed25519-signature-2020.git
cd ed25519-signature-2020
npm install

Usage

The following code snippet provides a complete example of digitally signing a verifiable credential using this library:

import jsigs from 'jsonld-signatures';
const {purposes: {AssertionProofPurpose}} = jsigs;
import {Ed25519VerificationKey2020} from
  '@digitalcredentials/ed25519-verification-key-2020';
import {Ed25519Signature2020, suiteContext} from
  '@digitalcredentials/ed25519-signature-2020';

// 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 Ed25519VerificationKey2020.from({
  type: 'Ed25519VerificationKey2020',
  controller,
  id: controller + '#z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T',
  publicKeyMultibase: 'z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T',
  privateKeyMultibase: 'zrv2EET2WWZ8T1Jbg4fEH5cQxhbUS22XxdweypUbjWVzv1YD6VqYu' +
    'W6LH7heQCNYQCuoKaDwvv2qCWz3uBzG2xesqmf'
});

const suite = new Ed25519Signature2020({key: keyPair});
suite.date = '2010-01-01T19:23:24Z';

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/suites/ed25519-2020/v1"
  ],
  "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": "Ed25519Signature2020",
    "created": "2010-01-01T19:23:24Z",
    "verificationMethod": "https://example.edu/issuers/565049#z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T",
    "proofPurpose": "assertionMethod",
    "proofValue": "z3MvGcVxzRzzpKF1HA11EjvfPZsN8NAb7kXBRfeTm3CBg2gcJLQM5hZNmj6Ccd9Lk4C1YueiFZvkSx4FuHVYVouQk"
  }
}

Contribute

See the contribute file!

PRs accepted.

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

License

  • MIT License - DCC - TypeScript compatibility.
  • New BSD License (3-clause) © 2020-2021 Digital Bazaar - Initial implementation.

版本与发布记录

@digitalcredentials/ed25519-signature-2020 共发布 8 个版本,首次发布于 2021/05/20;过去 12 个月发布了 0 个版本。

版本发布日期距今
7.0.0latest2025/04/301.5 年前
7.0.0-beta.1beta2025/03/141.7 年前
6.0.02024/09/182 年前
5.0.02024/08/042 年前
4.0.02024/02/082 年前
3.0.22021/09/215 年前

关于 @digitalcredentials/ed25519-signature-2020 的常见问题

@digitalcredentials/ed25519-signature-2020 是什么?

Ed25519Signature2020 Linked Data Proof suite for use with jsonld-signatures.

如何安装 @digitalcredentials/ed25519-signature-2020?

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

@digitalcredentials/ed25519-signature-2020 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/digitalcredentials__ed25519-signature-2020 是否存在。

@digitalcredentials/ed25519-signature-2020 支持 ESM 还是 CommonJS?

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

@digitalcredentials/ed25519-signature-2020 需要什么版本的 Node.js?

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

@digitalcredentials/ed25519-signature-2020 可以商用吗?

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

@digitalcredentials/ed25519-signature-2020 的下载量有多少?

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

@digitalcredentials/ed25519-signature-2020 还在维护吗?

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