# Web5 Crypto API
| A cryptography and JOSE library for building secure Web5 applications |
| --------------------------------------------------------------------- |
[![NPM Package][crypto-npm-badge]][crypto-npm-link]
[![NPM Downloads][crypto-downloads-badge]][crypto-npm-link]
[![Build Status][crypto-build-badge]][crypto-build-link]
[![Open Issues][crypto-issues-badge]][crypto-issues-link]
[![Code Coverage][crypto-coverage-badge]][crypto-coverage-link]
---
- [Introduction](#introduction)
- [Supported Algorithms & Key Types](#supported-algorithms--key-types)
- [Extensions](#extensions)
- [Getting Started](#getting-started)
- [Node.js](#nodejs)
- [Web Browsers](#web-browsers)
- [React Native](#react-native)
- [Contributing](#contributing)
- [Core Concepts](#usage)
- [Key URIs](#key-uris)
- [Using a Local KMS](#using-a-local-kms)
- [JSON Web Key (JWK)](#json-web-key-jwk)
- [Random Number Generation](#random-number-generation)
- [Customization](#customization)
- [Persistent Local KMS Key Store](#persistent-local-kms-key-store)
- [Cryptographic Primitives](#cryptographic-primitives)
---
The Web5 Crypto API is a core component of the [Web5 JS](https://github.com/TBD54566975/web5-js)
ecosystem, providing the cryptography and JSON Object Signing and Encryption (JOSE) capabilities
essential for building secure applications and services with Decentralized Identifiers
([DID](https://www.w3.org/TR/did-core/)) and Verifiable Credentials
([VC](https://w3c.github.io/vc-data-model/)).
This JavaScript library was designed for modern development runtimes, including Node.js, web
browsers, and React Native. It provides cryptographic functionality for cipher, hash, and signature
algorithms and basic JOSE support for JSON Web Key (JWK). Additionally, it includes the crypto
interfaces and local Key Management System (KMS) implementation that are used by
[other libraries](https://github.com/TBD54566975/web5-js) in this monorepo.
### Supported Algorithms & Key Types
The following algorithms and key types are currently supported, with plans to expand its offerings
as the library progresses towards a 1.0 release.
| Capability | Details |
| -------------- | ----------------------------------------------- |
| Cipher | AES-CTR, AES-GCM, XChaCha20, XChaCha20-Poly1305 |
| Signature | ECDSA, EdDSA |
| Hash | SHA-256 |
| Key Derivation | ConcatKDF, ECDH, PBKDF2 |
| ECC Curves | Ed25519, secp256k1, X25519 |
### Extensions
Packages that extend the functionality of the `@web5/crypto` library:
| Extension | Repository |
| ----------------- | ------------------------------------------------------ |
| AWS KMS extension | [TBD54566975/crypto-aws-kms][crypto-aws-kms-repo-link] |
## Getting Started
The Web5 Crypto API is distributed as `@web5/crypto` via [npmjs.com][crypto-npm-link],
[jsdelivr.com][crypto-jsdelivr-link], [unpkg.com][crypto-unpkg-link], and
[github.com][crypto-repo-link].
### Node.js
This library is designed and tested for the _active_ (`v20`) and _maintenance_
(`v18`) [LTS releases](https://nodejs.org/en/about/previous-releases) of Node.js
Install the latest version of `@web5/crypto` using `npm` or your preferred package manager:
```shell
npm install @web5/crypto
```
Example ESM import:
```js
import { Ed25519 } from "@web5/crypto";
```
Example CJS require:
```js
const { Ed25519 } = require("@web5/crypto");
```
### Web Browsers
A polyfilled distribution is published to [jsdelivr.com][crypto-jsdelivr-browser] and
[unpkg.com][crypto-unpkg-browser] that can imported in a module `