Skip to content

An implementation of the W3C DID Method `did:key` for static cryptographic keys. Supports Multikey and JsonWebKey representations (Ed25519, Bls12381, P-256, P-384, secp256k1).

License

Notifications You must be signed in to change notification settings

filip26/carbon-did-key

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🔐 Carbon DID Key Method

The did:key method represents static cryptographic keys as Decentralized Identifiers (DIDs).

did:key is self-contained. The identifier encodes the public key material required to verify signatures or perform encryption without relying on any external registry or multi-party resolution process.

did:key is suited for portable and lightweight use cases such as verifiable credentials, decentralized identifiers (DIDs), and other decentralized or domain-specific deployments that operate without blockchains or centralized registries. It can also be used for testing and local development where a simple, self-contained DID method is required.

Java 8 CI Codacy Badge javadoc Maven Central License

✨ Features

  • DidKey API & Resolver – work with did:key identifiers programmatically.
  • Verification Methods
    • Multikey
    • JSON Web Key (JWK):
      • Ed25519
      • Bls12381G1, Bls12381G2
      • P-256 (secp256r1)
      • P-384 (secp384r1)
      • secp256k1

Examples

// Create a resolver for did:key 
DidKeyResolver resolver = DidKeyResolver
    // Initialize the resolver builder with a multicodec decoder
    .with(codecs)
    // Configure the resolver to emit Multikey verification methods
    .multikey()
    // Also configure the resolver to emit JWK verification methods
    .jwk()
    // Override how verification method identifiers are constructed.
    // In this example, each method will be given a fragment "#vm"
    // relative to the did:key identifier.
    .verificationMethodId(key -> DidUrl.fragment(key, "vm"))
    // Build the resolver instance
    .build();

// Parse an existing `did:key`
var didKey = Did.of("did:key:z6MkvG5D...", ...);

// Resolve the did:key into a minimal DID Document
var didDoc = resolver.resolve(didKey);

// Print the DID Document identifier
System.out.println(didDoc.document().id());

// Print all verification method identifiers contained in the DID Document
didDooc.document().verification().forEach(vm -> System.out.println(vm.id()));

Installation

Maven

<dependency>
    <groupId>com.apicatalog</groupId>
    <artifactId>carbon-did-key</artifactId>
    <version>0.10.0</version>
</dependency>

Contributing

All PR's welcome!

Building

Fork and clone the project repository.

> cd carbon-did-key
> mvn package

Resources

Sponsors

Commercial Support

Commercial support and consulting are available.
For inquiries, please contact: filip26@gmail.com

About

An implementation of the W3C DID Method `did:key` for static cryptographic keys. Supports Multikey and JsonWebKey representations (Ed25519, Bls12381, P-256, P-384, secp256k1).

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages