Interface DidJwkCreateOptions<TKms>

Defines the set of options available when creating a new Decentralized Identifier (DID) with the 'did:jwk' method.

Either the algorithm or verificationMethods option can be specified, but not both.

  • A new key will be generated using the algorithm identifier specified in either the algorithm property or the verificationMethods object's algorithm property.
  • If verificationMethods is given, it must contain exactly one entry since DID JWK only supports a single verification method.
  • If neither is given, the default is to generate a new Ed25519 key.

Example

// DID Creation

// By default, when no options are given, a new Ed25519 key will be generated.
const did = await DidJwk.create();

// The algorithm to use for key generation can be specified as a top-level option.
const did = await DidJwk.create({
options: { algorithm = 'ES256K' }
});

// Or, alternatively as a property of the verification method.
const did = await DidJwk.create({
options: {
verificationMethods: [{ algorithm = 'ES256K' }]
}
});

// DID Creation with a KMS
const keyManager = new LocalKeyManager();
const did = await DidJwk.create({ keyManager });

// DID Resolution
const resolutionResult = await DidJwk.resolve({ did: did.uri });

// Signature Operations
const signer = await did.getSigner();
const signature = await signer.sign({ data: new TextEncoder().encode('Message') });
const isValid = await signer.verify({ data: new TextEncoder().encode('Message'), signature });

// Import / Export

// Export a BearerDid object to the PortableDid format.
const portableDid = await did.export();

// Reconstruct a BearerDid object from a PortableDid
const did = await DidJwk.import(portableDid);
interface DidJwkCreateOptions<TKms> {
    algorithm?: TKms extends CryptoApi<KmsGenerateKeyParams, string, KmsGetPublicKeyParams, KmsDigestParams, KmsSignParams, KmsVerifyParams>
        ? InferKeyGeneratorAlgorithm<TKms<TKms>>
        : "Ed25519" | "secp256k1" | "secp256r1";
    verificationMethods?: DidCreateVerificationMethod<TKms>[];
}

Type Parameters

  • TKms

Hierarchy (view full)

Properties

algorithm?: TKms extends CryptoApi<KmsGenerateKeyParams, string, KmsGetPublicKeyParams, KmsDigestParams, KmsSignParams, KmsVerifyParams>
    ? InferKeyGeneratorAlgorithm<TKms<TKms>>
    : "Ed25519" | "secp256k1" | "secp256r1"

Optionally specify the algorithm to be used for key generation.

verificationMethods?: DidCreateVerificationMethod<TKms>[]

Alternatively, specify the algorithm to be used for key generation of the single verification method in the DID Document.