{"id":19122934,"url":"https://github.com/digitalbazaar/did-method-key","last_synced_at":"2025-10-26T23:07:08.364Z","repository":{"id":38668463,"uuid":"187105172","full_name":"digitalbazaar/did-method-key","owner":"digitalbazaar","description":"A did-io driver for the DID \"key\" method","archived":false,"fork":false,"pushed_at":"2024-09-19T18:19:04.000Z","size":229,"stargazers_count":31,"open_issues_count":16,"forks_count":10,"subscribers_count":11,"default_branch":"main","last_synced_at":"2025-09-21T15:54:33.643Z","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":"other","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":"2019-05-16T21:43:11.000Z","updated_at":"2025-09-16T02:45:51.000Z","dependencies_parsed_at":"2024-06-18T16:39:09.213Z","dependency_job_id":"be1884c0-017d-41a5-a852-f22d45cbb573","html_url":"https://github.com/digitalbazaar/did-method-key","commit_stats":{"total_commits":253,"total_committers":9,"mean_commits":28.11111111111111,"dds":0.6600790513833992,"last_synced_commit":"7418248b3592d68a5f3519d8310e1d9611ed5167"},"previous_names":["digitalbazaar/did-method-key-js"],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/digitalbazaar/did-method-key","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fdid-method-key","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fdid-method-key/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fdid-method-key/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fdid-method-key/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/digitalbazaar","download_url":"https://codeload.github.com/digitalbazaar/did-method-key/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/digitalbazaar%2Fdid-method-key/sbom","scorecard":{"id":342338,"data":{"date":"2025-08-11","repo":{"name":"github.com/digitalbazaar/did-method-key","commit":"7418248b3592d68a5f3519d8310e1d9611ed5167"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3.9,"checks":[{"name":"Dangerous-Workflow","score":10,"reason":"no dangerous workflow patterns detected","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Code-Review","score":1,"reason":"Found 3/17 approved changesets -- score normalized to 1","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Token-Permissions","score":0,"reason":"detected GitHub workflow tokens with excessive permissions","details":["Warn: no topLevel permission defined: .github/workflows/main.yml:1","Info: no jobLevel write permissions found"],"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Pinned-Dependencies","score":0,"reason":"dependency not pinned by hash detected -- score normalized to 0","details":["Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:13: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:15: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:29: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:31: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:45: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:47: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/main.yml:63: update your workflow using https://app.stepsecurity.io/secureworkflow/digitalbazaar/did-method-key/main.yml/main?enable=pin","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:35","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:51","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:67","Warn: npmCommand not pinned by hash: .github/workflows/main.yml:19","Info:   0 out of   8 GitHub-owned GitHubAction dependencies pinned","Info:   0 out of   4 npmCommand dependencies pinned"],"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"License","score":9,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Warn: project license file does not contain an FSF or OSI license."],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"Branch-Protection","score":-1,"reason":"internal error: error during branchesHandler.setup: internal error: githubv4.Query: Resource not accessible by integration","details":null,"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}},{"name":"SAST","score":0,"reason":"SAST tool is not run on all commits -- score normalized to 0","details":["Warn: 0 commits out of 18 are checked with a SAST tool"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}}]},"last_synced_at":"2025-08-18T06:10:58.814Z","repository_id":38668463,"created_at":"2025-08-18T06:10:58.814Z","updated_at":"2025-08-18T06:10:58.814Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":281185454,"owners_count":26457747,"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","status":"online","status_checked_at":"2025-10-26T02:00:06.575Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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:40.175Z","updated_at":"2025-10-26T23:07:08.346Z","avatar_url":"https://github.com/digitalbazaar.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# did:key method driver _(@digitalbazaar/did-method-key)_\n\n[![Node.js CI](https://github.com/digitalbazaar/did-method-key/workflows/Node.js%20CI/badge.svg)](https://github.com/digitalbazaar/did-method-key/actions?query=workflow%3A%22Node.js+CI%22)\n[![Coverage status](https://img.shields.io/codecov/c/github/digitalbazaar/did-method-key)](https://codecov.io/gh/digitalbazaar/did-method-key)\n[![NPM Version](https://img.shields.io/npm/v/@digitalbazaar/did-method-key)](https://www.npmjs.com/package/@digitalbazaar/did-method-key)\n\n\u003e A [DID](https://w3c.github.io/did-core) (Decentralized Identifier) method driver for the `did-io` library and for standalone use\n\n## Table of Contents\n\n- [Background](#background)\n  * [Example DID Document](#example-did-document)\n- [Security](#security)\n- [Install](#install)\n- [Usage](#usage)\n- [Contribute](#contribute)\n- [Commercial Support](#commercial-support)\n- [License](#license)\n\n## Background\n\nSee also (related specs):\n\n* [Decentralized Identifiers (DIDs)](https://w3c.github.io/did-core)\n* [Linked Data Cryptographic Suite Registry](https://w3c-ccg.github.io/ld-cryptosuite-registry/)\n* [Linked Data Proofs](https://w3c-dvcg.github.io/ld-proofs/)\n\nA `did:key` method driver for the [`did-io`](https://github.com/digitalbazaar/did-io)\nclient library and for standalone use.\n\nThe `did:key` method is used to express public keys in a way that doesn't\nrequire a DID Registry of any kind. Its general format is:\n\n```\ndid:key:\u003cmultibase encoded, multicodec identified, public key\u003e\n```\n\nSo, for example, the following DID would be derived from a base-58 encoded\ned25519 public key:\n\n```\ndid:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\n```\n\nThat DID would correspond to the following DID Document:\n\n### Example DID Document\n\n```json\n{\n  \"@context\": [\n    \"https://www.w3.org/ns/did/v1\",\n    \"https://w3id.org/security/suites/ed25519-2020/v1\",\n    \"https://w3id.org/security/suites/x25519-2020/v1\"\n  ],\n  \"id\": \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\",\n  \"verificationMethod\": [\n    {\n      \"id\": \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\",\n      \"type\": \"Ed25519VerificationKey2020\",\n      \"controller\": \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\",\n      \"publicKeyMultibase\": \"z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\"\n    }\n  ],\n  \"authentication\": [\n    \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\"\n  ],\n  \"assertionMethod\": [\n    \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\"\n  ],\n  \"capabilityDelegation\": [\n    \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\"\n  ],\n  \"capabilityInvocation\": [\n    \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\"\n  ],\n  \"keyAgreement\": [\n    {\n      \"id\": \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH#z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc\",\n      \"type\": \"X25519KeyAgreementKey2020\",\n      \"controller\": \"did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH\",\n      \"publicKeyMultibase\": \"z6LSbysY2xFMRpGMhb7tFTLMpeuPRaqaWM1yECx2AtzE3KCc\"\n    }\n  ]\n}\n```\n\n## Security\n\nThe `keyAgreement` key is a Curve25519 public key (suitable for\nDiffie-Hellman key exchange) that is deterministically _derived_ from the source\nEd25519 key, using  [`ed2curve-js`](https://github.com/dchest/ed2curve-js).\n\nNote that this derived key is optional -- there's at least\n[one proof](https://eprint.iacr.org/2021/509) that this is safe to do.\n\n## Install\n\nRequires Node.js 16+\n\nTo install from `npm`:\n\n```\nnpm install --save @digitalbazaar/did-method-key\n```\n\nTo install locally (for development):\n\n```\ngit clone https://github.com/digitalbazaar/did-method-key.git\ncd did-method-key\nnpm install\n```\n\n## Usage\n\n### `use()`\n\nThis method registers a multibase-multikey header and a multibase-multikey\ndeserializer and configures a driver to use a multibase-multikey deserializer\nto handle data using that multibase-multikey header.\n\n```js\nimport * as EcdsaMultikey from '@digitalbazaar/ecdsa-multikey';\nimport {driver} from '@digitalbazaar/did-method-key';\n\nconst didKeyDriverMultikey = driver();\n\ndidKeyDriverMultikey.use({\n  multibaseMultikeyHeader: 'zDna',\n  fromMultibase: EcdsaMultikey.from\n});\n```\n\n### `createFromMultibase()`\n\nThis utility function can be used to adapt legacy verification suites such as\n`Ed25519VerificationSuite2018` to work properly with `fromMultibase()`\ncalls in `DidKeyDriver`.\n\n```js\nimport {driver} from '@digitalbazaar/did-method-key';\nimport {Ed25519VerificationKey2018} from\n  '@digitalbazaar/ed25519-verification-key-2018';\n\nconst didKeyDriver2018 = driver();\n\ndidKeyDriver2018.use({\n  multibaseMultikeyHeader: header,\n  fromMultibase: createFromMultibase(Ed25519VerificationKey2018)\n});\n```\n\n### `fromKeyPair()`\n\nTo generate a new key and get its corresponding `did:key` method DID Document\nfrom a verification keypair.\n\n```js\nimport {driver} from '@digitalbazaar/did-method-key';\nimport {Ed25519VerificationKey2020} from\n  '@digitalbazaar/ed25519-verification-key-2020';\n\nconst didKeyDriver = driver();\n\ndidKeyDriver.use({\n  multibaseMultikeyHeader: 'z6Mk',\n  fromMultibase: Ed25519VerificationKey2020.from\n});\n\nconst publicKeyMultibase = 'z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH';\nconst verificationKeyPair = await Ed25519VerificationKey2020.from({\n  publicKeyMultibase\n});\n// or perhaps:\n// const verificationKeyPair = await Ed25519VerificationKey2020.generate();\n\nconst {didDocument, keyPairs, methodFor} = await didKeyDriver.fromKeyPair({\n  verificationKeyPair\n});\n\n// print the DID Document above\nconsole.log(JSON.stringify(didDocument, null, 2));\n\n// keyPairs will be set like so =\u003e\nMap(2) {\n  'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T#z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T' =\u003e Ed25519VerificationKey2020 {\n    id: 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T#z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T',\n    controller: 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T',\n    revoked: undefined,\n    type: 'Ed25519VerificationKey2020',\n    publicKeyMultibase: 'z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T',\n    privateKeyMultibase: undefined\n  },\n  'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T#z6LSotGbgPCJD2Y6TSvvgxERLTfVZxCh9KSrez3WNrNp7vKW' =\u003e X25519KeyAgreementKey2020 {\n    id: 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T#z6LSotGbgPCJD2Y6TSvvgxERLTfVZxCh9KSrez3WNrNp7vKW',\n    controller: 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T',\n    revoked: undefined,\n    type: 'X25519KeyAgreementKey2020',\n    publicKeyMultibase: 'z6LSotGbgPCJD2Y6TSvvgxERLTfVZxCh9KSrez3WNrNp7vKW',\n    privateKeyMultibase: undefined\n  }\n}\n```\n\n`methodFor` is a convenience function that returns a key pair instance that\ncontains `publicKeyMultibase` for given purpose. For example, a verification key\n(containing a `signer()` and `verifier()` functions) are frequently useful for\n[`jsonld-signatures`](https://github.com/digitalbazaar/jsonld-signatures) or\n[`vc-js`](https://github.com/digitalbazaar/vc-js) operations. After generating\na new did:key DID, you can do:\n\n```js\n// For signing Verifiable Credentials\nconst assertionKeyPair = methodFor({purpose: 'assertionMethod'});\n// For Authorization Capabilities (zCaps)\nconst invocationKeyPair = methodFor({purpose: 'capabilityInvocation'});\n// For Encryption using `@digitalbazaar/minimal-cipher`\nconst keyAgreementPair = methodFor({purpose: 'keyAgreement'});\n```\n\nNote that `methodFor` returns a key pair that contains a `publicKeyMultibase`.\nThis makes it useful for _verifying_ and _encrypting_ operations.\n\n### `publicKeyToDidDoc()`\n\nIf you already have an `Ed25519VerificationKey2020` public key object (as an\nLDKeyPair instance, or a plain key description object), you can turn it into\na DID Document:\n\n```js\nconst {didDocument} = await didKeyDriver.publicKeyToDidDoc({publicKeyDescription});\n```\n\n### `get()`\n\n#### Getting a full DID Document from a `did:key` DID\n\nTo get a DID Document for an existing `did:key` DID:\n\n```js\nconst did = 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T';\nconst didDocument = await didKeyDriver.get({did});\n```\n\n(Results in the [example DID Doc](#example-did-document) above).\n\n#### Getting the DID Document from key id\n\nYou can also use a `.get()` to retrieve an individual key, if you know its id\nalready (this is useful for constructing `documentLoader`s for JSON-LD Signature\nlibs, and the resulting key does include the appropriate `@context`).\n\n```js\nconst verificationKeyId = 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T#z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T';\n\nconst keyAgreementKeyId = 'did:key:z6MknCCLeeHBUaHu4aHSVLDCYQW9gjVJ7a63FpMvtuVMy53T#z6LSotGbgPCJD2Y6TSvvgxERLTfVZxCh9KSrez3WNrNp7vKW';\nconst didDocument = await didKeyDriver.get({url: verificationKeyId});\n// OR\nconst didDocument = await didKeyDriver.get({url: keyAgreementKeyId});\n\n// DID Document -\u003e\nconsole.log(JSON.stringify(didDocument, null, 2));\n```\n\n### `publicMethodFor()`\n\nOften, you have just a `did:key` DID, and you need to get a key for a\nparticular _purpose_ from it, such as an `assertionMethod` key to verify a\nVC signature, or a `keyAgreement` key to encrypt a document for that DID's\ncontroller.\n\nFor that purpose, you can use a combination of `get()` and `publicMethodFor`:\n\n```js\n// Start with the DID\nconst didDocument = await didKeyDriver.get({did});\n// This lets you use `publicMethodFor()` to get a key for a specific purpose\nconst keyAgreementMethod = didKeyDriver.publicMethodFor({\n  didDocument, purpose: 'keyAgreement'\n});\nconst assertionMethod = didKeyDriver.publicMethodFor({\n  didDocument, purpose: 'assertionMethod'\n});\n\n// If you have a known key type, for example, `Ed25519VerificationKey2020`,\n// you can create key instances which allow you to get access to a\n// `verify()` function.\nconst assertionMethodPublicKey = await Ed25519VerificationKey2020.from(\n  assertionMethod);\nconst {verify} = assertionMethodPublicKey.verifier();\n```\n\n`publicMethodFor` will throw an error if no key is found for a given purpose.\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) © Digital Bazaar\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fdid-method-key","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdigitalbazaar%2Fdid-method-key","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdigitalbazaar%2Fdid-method-key/lists"}