Web5 cryptographic library
npm install @web5/crypto| 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]
---
- Web5 Crypto API
- Supported Algorithms \& Key Types
- Extensions
- Getting Started
- Node.js
- Web Browsers
- React Native
- Contributing
- Core Concepts
- Key URIs
- Using a Local KMS
- JSON Web Key (JWK)
- Random Number Generation
- randomBytes()
- randomUuid()
- Customization
- Persistent Local KMS Key Store
- Cryptographic Primitives
- AES-CTR
- AES-GCM
- ConcatKDF
- Ed25519
- PBKDF2
- secp256k1
- SHA-256
- X25519
- XChaCha20
- XChaCha20-Poly1305
- Project Resources
---
The Web5 Crypto API is a core component of the 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) and Verifiable Credentials
(VC).
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 in this monorepo.
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 |
Packages that extend the functionality of the @web5/crypto library:
| Extension | Repository |
| ----------------- | ------------------------------------------------------ |
| AWS KMS extension | [TBD54566975/crypto-aws-kms][crypto-aws-kms-repo-link] |
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].
This library is designed and tested for the _active_ (v20) and _maintenance_
(v18) LTS 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");
A polyfilled distribution is published to [jsdelivr.com][crypto-jsdelivr-browser] and
[unpkg.com][crypto-unpkg-browser] that can imported in a module