{"id":19123013,"url":"https://github.com/digitalbazaar/ed25519-verification-key-2020","last_synced_at":"2025-04-15T14:56:04.238Z","repository":{"id":38848892,"uuid":"309161768","full_name":"digitalbazaar/ed25519-verification-key-2020","owner":"digitalbazaar","description":"Javascript library for generating and working with Ed25519VerificationKey2020 key pairs, for use with crypto-ld.","archived":false,"fork":false,"pushed_at":"2024-10-03T01:16:51.000Z","size":132,"stargazers_count":4,"open_issues_count":4,"forks_count":10,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-03-28T21:23:06.421Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/digitalbazaar.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-01T18:31:40.000Z","updated_at":"2025-02-14T15:11:10.000Z","dependencies_parsed_at":"2024-11-09T05:34:49.978Z","dependency_job_id":null,"html_url":"https://github.com/digitalbazaar/ed25519-verification-key-2020","commit_stats":{"total_commits":176,"total_committers":6,"mean_commits":"29.333333333333332","dds":0.5568181818181819,"last_synced_commit":"84f727ec01a8ce77f329955121077fde07b158e9"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fed25519-verification-key-2020","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fed25519-verification-key-2020/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fed25519-verification-key-2020/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fed25519-verification-key-2020/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalbazaar","download_url":"https://codeload.github.com/digitalbazaar/ed25519-verification-key-2020/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249016316,"owners_count":21198832,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T05:23:56.537Z","updated_at":"2025-04-15T14:56:04.209Z","avatar_url":"https://github.com/digitalbazaar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Ed25519VerificationKey2020 Key Pair Library for Linked Data _(@digitalbazaar/ed25519-verification-key-2020)_\n\n[![Node.js CI](https://github.com/digitalbazaar/ed25519-verification-key-2020/workflows/Node.js%20CI/badge.svg)](https://github.com/digitalbazaar/ed25519-verification-key-2020/actions?query=workflow%3A%22Node.js+CI%22)\n[![NPM Version](https://img.shields.io/npm/v/@digitalbazaar/ed25519-verification-key-2020.svg)](https://npm.im/@digitalbazaar/ed25519-verification-key-2020)\n\n\u003e Javascript library for generating and working with Ed25519VerificationKey2020 key pairs, for use with crypto-ld.\n\n## Table of Contents\n\n- [Background](#background)\n- [Security](#security)\n- [Install](#install)\n- [Usage](#usage)\n- [Contribute](#contribute)\n- [Commercial Support](#commercial-support)\n- [License](#license)\n\n## Background\n\nFor use with:\n\n* [`crypto-ld`](https://github.com/digitalbazaar/crypto-ld) `^5.0.0`.\n* [`@digitalbazaar/ed25519-signature-2020`](https://github.com/digitalbazaar/ed25519-signature-2020) `^2.1.0`\n  crypto suite (with [`jsonld-signatures`](https://github.com/digitalbazaar/jsonld-signatures) `^9.0.0`)\n* [`@digitalbazaar/vc`](https://github.com/digitalbazaar/vc-js) `^1.0.0`\n\nSee also (related specs):\n\n* [Ed25519VerificationKey2020](https://w3c-ccg.github.io/lds-ed25519-2020/#ed25519verificationkey2020) spec.\n\n## Security\n\nAs with most security- and cryptography-related tools, the overall security of\nyour system will largely depend on your design decisions.\n\n## Install\n\n- Node.js 14+ is required.\n\nTo install locally (for development):\n\n```\ngit clone https://github.com/digitalbazaar/ed25519-verification-key-2020.git\ncd ed25519-verification-key-2020\nnpm install\n```\n\n## Usage\n\n### Generating a new public/private key pair\n\nTo generate a new public/private key pair:\n\n* `{string} [controller]` Optional controller URI or DID to initialize the\n  generated key. (This will also init the key id.) \n* `{string} [seed]` Optional deterministic seed value from which to generate the \n  key.\n\n```js\nimport {Ed25519VerificationKey2020} from '@digitalbazaar/ed25519-verification-key-2020';\n\nconst edKeyPair = await Ed25519VerificationKey2020.generate();\n```\n\n### Importing a key pair from storage\n\nTo create an instance of a public/private key pair from data imported from\nstorage, use `.from()`:\n\n```js\nconst serializedKeyPair = { ... };\n\nconst keyPair = await Ed25519VerificationKey2020.from(serializedKeyPair);\n````\n\n### Exporting the public key only\n\nTo export just the public key of a pair:\n\n```js\nawait keyPair.export({publicKey: true});\n// -\u003e\n{ \n  type: 'Ed25519VerificationKey2020',\n  id: 'did:example:1234#z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3',\n  controller: 'did:example:1234',\n  publicKeyMultibase: 'zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf'\n}\n```\n\n### Exporting the full public-private key pair\n\nTo export the full key pair, including private key (warning: this should be a\ncarefully considered operation, best left to dedicated Key Management Systems):\n\n```js\nawait keyPair.export({publicKey: true, privateKey: true});\n// -\u003e\n{\n  type: 'Ed25519VerificationKey2020',\n  id: 'did:example:1234#z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3',\n  controller: 'did:example:1234',\n  publicKeyMultibase: 'zEYJrMxWigf9boyeJMTRN4Ern8DJMoCXaLK77pzQmxVjf',\n  privateKeyMultibase: 'z4E7Q4neNHwv3pXUNzUjzc6TTYspqn9Aw6vakpRKpbVrCzwKWD4hQDHnxuhfrTaMjnR8BTp9NeUvJiwJoSUM6xHAZ'\n}\n```\n\n### Generating and verifying key fingerprint\n\nTo generate a fingerprint:\n\n```js\nkeyPair.fingerprint();\n// -\u003e\n'z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3'\n```\n\nTo verify a fingerprint:\n\n```js\nconst fingerprint = 'z6MkszZtxCmA2Ce4vUV132PCuLQmwnaDD5mw2L23fGNnsiX3';\nkeyPair.verifyFingerprint({fingerprint});\n// -\u003e\n{valid: true}\n```\n\n### Creating a signer function\n\nIn order to perform a cryptographic signature, you need to create a `sign`\nfunction, and then invoke it.\n\n```js\nconst keyPair = Ed25519VerificationKey2020.generate();\n\nconst {sign} = keyPair.signer();\n\n// data is a Uint8Array of bytes\nconst data = (new TextEncoder()).encode('test data goes here');\n// Signing also outputs a Uint8Array, which you can serialize to text etc.\nconst signatureValueBytes = await sign({data});\n```\n\n### Creating a verifier function\n\nIn order to verify a cryptographic signature, you need to create a `verify`\nfunction, and then invoke it (passing it the data to verify, and the signature).\n\n```js\nconst keyPair = Ed25519VerificationKey2020.generate();\n\nconst {verify} = keyPair.verifier();\n\nconst valid = await verify({data, signature});\n// true\n```\n\n### Converting from previous Ed25519VerificationKey2018 key type\n\nIf you have serialized and stored keys of the previous \n`Ed25519VerificationKey2018` key type (for example, generated using\nthe [`ed25519-verification-key-2018`](https://github.com/digitalbazaar/ed25519-verification-key-2018))\nlibrary, or using the `Ed25519KeyPair` keys bundled with `crypto-ld v3.x`),\nthings to keep in mind:\n\n* Instances of those key types still contain the same key material, the only\n  thing that has changed from the 2018 suite to the 2020 suite is the way the public\n  and private key material is serialized when exporting. The 2018 suite key \n  types serialize using the `publicKeyBase58` and `privateKeyBase58` properties,\n  and the 2020 suite key (this repo) serializes using corresponding\n  `publicKeyMultibase` and `privateKeyMultibase` property.\n* You can convert from the 2018 key type to the 2020 key type using the provided\n  `Ed25519VerificationKey2020.fromEd25519VerificationKey2018()` method (see below).\n* They `generate()` the same key material, given the same `seed` parameter.\n* Both the 2018 and 2020 keys produce and verify the same signatures.\n\nExample of converting:\n\n```js\nimport {Ed25519VerificationKey2018}\n  from '@digitalbazaar/ed25519-verification-key-2018';\nimport {Ed25519VerificationKey2020}\n  from '@digitalbazaar/ed25519-verification-key-2020';\n\nconst keyPair2018 = await Ed25519VerificationKey2018.generate({\n  controller: 'did:example:1234'\n});\n\nconst keyPair2020 = await Ed25519VerificationKey2020\n  .fromEd25519VerificationKey2018({keyPair: keyPair2018});\n\n// The resulting keyPair2020 will have the same `id` and `controller` properties\n// as its 2018 source. They will also produce and verify the same signatures.\n\n// data is a Uint8Array of bytes\nconst data = (new TextEncoder()).encode('test data goes here');\nconst signatureBytes2018 = await keyPair2018.signer().sign({data});\n\n// this is the same signature as that produced by the 2020 key. And will verify\n// the same.\nawait keyPair2020.verifier().verify({data, signature: signatureBytes2018})\n// true\n```\n\n## Contribute\n\nSee [the contribute file](https://github.com/digitalbazaar/bedrock/blob/master/CONTRIBUTING.md)!\n\nPRs accepted.\n\nIf editing the Readme, please conform to the\n[standard-readme](https://github.com/RichardLitt/standard-readme) specification.\n\n## Commercial Support\n\nCommercial support for this library is available upon request from\nDigital Bazaar: support@digitalbazaar.com\n\n## License\n\n[New BSD License (3-clause)](LICENSE) © 2020 Digital Bazaar\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fed25519-verification-key-2020","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalbazaar%2Fed25519-verification-key-2020","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fed25519-verification-key-2020/lists"}