# @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.

Latest version **3.0.0** (published 2025-10-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @digitalcredentials/keypair
pnpm add @digitalcredentials/keypair
yarn add @digitalcredentials/keypair
bun add @digitalcredentials/keypair
```

## Health

**Score 60/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 3.0.0 |
| Published | 2025-10-16 |
| First published | 2022-12-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=18.0 |
| Dependencies | 1 |
| Unpacked size | 21.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Digital Credentials Consortium |
| Maintainers | codenamedmitri, kimhd, uligall, alexander.muehle, stuartf, jchartrand, kiliankae, klemoie, kezike |
| Keywords | dcc, react native, keys, key pair, cryptography |

## Links

- npm: https://www.npmjs.com/package/@digitalcredentials/keypair
- Repository: https://github.com/digitalcredentials/keypair
- Issues: https://github.com/digitalcredentials/keypair/issues
- npm.io page: https://npm.io/package/@digitalcredentials/keypair

## Dependencies (1)

- [@digitalcredentials/ssi](https://npm.io/package/@digitalcredentials/ssi.md) ^5.2.0

## Alternatives

- [@gemini-wallet/core](https://npm.io/package/@gemini-wallet/core.md) — 515.6K weekly downloads
- [utility](https://npm.io/package/utility.md) — 416.6K weekly downloads
- [@primno/dpapi](https://npm.io/package/@primno/dpapi.md) — 7.2K weekly downloads
- [pi-readseek](https://npm.io/package/pi-readseek.md) — 3.7K weekly downloads
- [@emilia-protocol/verify](https://npm.io/package/@emilia-protocol/verify.md) — 1.1K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2025-10-16
- 2.0.5 — 2025-04-30
- 2.0.4 — 2025-04-30
- 2.0.3 — 2025-04-30
- 2.0.2 — 2025-04-29
- 2.0.1 — 2025-04-29
- 2.0.0 — 2025-04-29
- 1.0.5 — 2022-12-23
- 1.0.4 — 2022-12-23
- 1.0.3 — 2022-12-20
- 1.0.2 — 2022-12-20
- 1.0.1 — 2022-12-20
- 1.0.0 — 2022-12-19

## README

# Cryptographic Key Pair _(@digitalcredentials/keypair)_

[![Node.js CI](https://github.com/digitalcredentials/keypair/workflows/Node.js%20CI/badge.svg)](https://github.com/digitalcredentials/keypair/actions?query=workflow%3A%22Node.js+CI%22)
[![NPM Version](https://img.shields.io/npm/v/@digitalcredentials/keypair.svg)](https://npm.im/@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.

## Table of Contents

- [Background](#background)
- [Security](#security)
- [Install](#install)
- [Usage](#usage)
- [Contribute](#contribute)
- [License](#license)

## Background

Extracted from Digital Bazaar's [`crypto-ld`](https://github.com/digitalbazaar/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:

* [`ed25519-verification-key-2020`](https://github.com/digitalcredentials/ed25519-verification-key-2020)
* [`x25519-key-agreement-key-2020`](https://github.com/digitalcredentials/x25519-key-agreement-key-2020)

### Choosing a Key Type

For digital signatures using the
[`linked-data-integrity`](https://github.com/digitalcredentials/linked-data-integrity) library,
signing of Verifiable Credentials using [`vc`](https://github.com/digitalcredentials/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:

* Use **Curve25519** with the [`minimal-cipher`](https://github.com/digitalcredentials/minimal-cipher)
  library.

## 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](https://github.com/RichardLitt/standard-readme) specification.

## License

[MIT License](LICENSE.md) © 2022 Digital Credentials Consortium.

---
_Source: https://npm.io/package/@digitalcredentials/keypair · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
