@empe/identity
v3.9.0
Published
A TypeScript implementation of Self-Sovereign Identity (SSI) components following W3C standards for Decentralized Identifiers (DIDs) and Verifiable Credentials (VCs).
Downloads
74
Readme
@empe/identity
A TypeScript implementation of Self-Sovereign Identity (SSI) components following W3C standards for Decentralized Identifiers (DIDs) and Verifiable Credentials (VCs).
Overview
This package provides comprehensive functionality for working with decentralized identity, including:
- Decentralized Identifiers (DIDs): Creation, management, and resolution of DIDs
- Verifiable Credentials (VCs): Issuance, verification, and storage of credentials
- Verifiable Presentations (VPs): Creation and verification of credential presentations
- Cryptographic Primitives: Key management, signatures, and proofs
The implementation follows the W3C Decentralized Identifiers and W3C Verifiable Credentials Data Model specifications.
Key Components
Decentralized Identifiers (DIDs)
CoreDID: Core implementation of DIDs following the standard formatdid:method:idCoreDocument: Basic DID Document implementationEmpeDocument: Extended DID Document for the Empe method
Verifiable Credentials
VerifiableCredential: Implementation of the W3C Verifiable Credential data modelVerifiablePresentation: Container for presenting one or more credentials with proof of ownership
Identity Roles
Issuer: Entity that creates and signs verifiable credentialsHolder: Entity that receives and stores credentials and can create presentationsVerifier: Entity that verifies credentials and presentations (implicit in the verification methods)
Key Management
KeyService: Management of cryptographic keysJwkService: JSON Web Key operationsMnemonicService: Mnemonic phrase generation and handling
Cryptography
Proof: Cryptographic proofs for credentials and presentationsJWS: JSON Web Signature implementationSignature: Digital signature creation and verification
Usage
Creating a DID
import { CoreDID, JwkService, Secp256k1Factory } from '@empe/identity';
import { MemKeyStorageAdapter } from '@empe/common';
// Create a new DID
const storage = new MemKeyStorageAdapter();
const keyService = new JwkService(storage, new Secp256k1Factory());
const did = await CoreDID.from(keyService);Creating a Verifiable Credential
import { VerifiableCredential, Issuer, IssuerConfiguration, Client, Network, CoreDID } from '@empe/identity';
import { MemKeyStorageAdapter } from '@empe/common';
// Create a client and document
const storage = new MemKeyStorageAdapter();
const client = new Client({ storage, network: Network.TESTNET });
const document = await client.createEmpeDocument();
// Configure issuer
const config: IssuerConfiguration = {
document: document,
};
const issuer = client.issuerFromConfiguration(config);
// Issue a verifiable credential
const holderDid = CoreDID.parse('did:empe:testnet:example');
const credential = await issuer.issueVerifiableCredential(holderDid, {
name: 'John Doe',
degree: 'Bachelor of Science',
});Creating a Verifiable Presentation
import { Holder, HolderConfiguration, VerifiablePresentation } from '@empe/identity';
import { MemKeyStorageAdapter } from '@empe/common';
// Configure holder
const config: HolderConfiguration = {
document: document,
};
const holder = new Holder(config, keyService);
// Create and sign a presentation
const presentation = await holder.issueVerifiablePresentation(
recipientDid, // DID of the entity receiving the presentation
holderDid, // DID of the holder creating the presentation
[credential] // Array of credentials to include
);Core Standards Support
- DID Core: Support for did:empe method
- VC Data Model: Implementation of Verifiable Credentials and Presentations
- Cryptographic Suites: Support for various cryptographic algorithms
- JSON-LD Context: Standard contexts for semantic interoperability
- Proof Formats: JWT and JSON-LD proof formats
Additional Features
- Schema validation for credentials
- Key derivation and management
- Mnemonics for key recovery
- JWT serialization
Related Packages
This package is part of a larger SSI ecosystem and works with other packages like @empe/common for shared functionality.
License
MIT
