Skip to content

W3C

Description Value
Credential kind (literal) w3c
Credential kind (numeric) 2
Status list type W3C
Credential subject identifier DID

RDF canonicalization

Document Rails performs credential claims canonicalization when issuing/verifying W3C credentials.

If your credentials are using JSON-LD contexts incorrectly, this may lead to unexpected behavior, like credential signatures being valid even after editing them.

To make sure your credentials are valid, test them using the JSON-LD playground.

Issuance

To properly issue a W3C credential, make sure you supply all the necessary contexts required for correct JSON-LD resolution.

Context URLs can be added during the credential creation using the contexts parameter.

Credential subject type value can be provided using the credential_subject_type parameter.

Supported DID methods

  • did:key

    • did:key:z6Mk...

    • did:key:zDna...

  • did:web

Supported cryptosuites

Proof type / key type Multikey Ed25519VerificationKey2020
ecdsa-rdfc-2019
Ed25519Signature2020

FIPS mode

Ed25519Signature2020 and Ed25519VerificationKey2020 are not available when operating in FIPS mode.

JSON-LD contexts

W3C credentials utilize JSON-LD contexts to specify how tools should interpret them.

Document Rails automatically fetches remote JSON-LD contexts during the credential issuance/verification process.

Organization JSON-LD contexts

When a given JSON-LD context cannot be loaded, Document Rails will fallback to "organization JSON-LD contexts", which allow superadmins to manually add JSON-LD contexts for usage in their organizations.

import { createW3CContext } from "@vaultie/document-rails";

const response = await createW3CContext(
    client,
    accessToken,
    organizationId,
    {
        url: "https://example.com/ExampleContext/v2",
        context: {
            "@context": {
                // ...
            }
        }
    }
);
import { listW3CContexts } from "@vaultie/document-rails";

const response = await listW3CContexts(
    client,
    accessToken,
    organizationId
);
import { deleteW3CContext } from "@vaultie/document-rails";

await deleteW3CContext(
    client,
    accessToken,
    organizationId,
    w3cContextId
);

Generating JSON-LD contexts

Document Rails can generate basic JSON-LD contexts using information about your existing credentials and their fields.

To describe the resulting JSON-LD context, the following format is utilized as an input:

{
    // The "underscore" record.
    "_": {
        // Base URL of the resulting context for all entities that either utilize relative IRIs,
        // or that rely on Document Rails automatically generating terms for them.
        "baseUrl": "https://example.com/ExampleContext/v2",

        // Optional list of entities to include.
        //
        // The format is `${namespace}/[...]`, where `namespace`
        // is a statically-defined namespace name, and `[...]` is a namespace-specific path.
        "include": ["credentials/1", "credentials/2"]
    }
}

Example

import { generateJSONLDContext } from "@vaultie/document-rails";

const response = await generateJSONLDContext(
    client,
    accessToken,
    organizationId,
    {
        "_": {
            "baseUrl": "https://example.com/ExampleContext/v2",
            "include": ["credentials/1"]
        }
    }
);

Namespaces

Credentials
Name Can be included in the underscore record
credentials

Upon resolution, the resulting entity will contain terms for the credential type and the credential subject type (if it was provided during the credential creation), with all the related fields added as terms within the nested context.

If the credential subject type is provided, the nested context will be attached to the credential subject type term. Otherwise, it will be attached to the credential type term.

DID document generator

Document Rails can generate DID documents for you by fetching the existing information about signing keys from your organization.

DID resolution

DID document generator doesn't resolve DID and DIDURL values by itself, so make sure you provide correct information in the credential_issuer_vm field when creating signing keys.

import { generateDIDDocument, VerificationRelationship } from "@vaultie/document-rails";

const response = await generateDIDDocument(
    client,
    accessToken,
    organizationId,
    {
        // DID document identifier.
        id: "did:web:example.com",

        // `keys` object contains a mapping from a signing key ID to a list of verification relationship IDs.
        keys: {
            [firstKeyId]: [
                VerificationRelationship.Authentication,
                VerificationRelationship.AssertionMethod
            ],
            [secondKeyId]: [
                VerificationRelationship.KeyAgreement
            ],
        }
    }
);

Verification relationship values

  • authentication

  • assertionMethod

  • keyAgreement

  • capabilityInvocation

  • capabilityDelegation