Skip to content

Credentials

Define a schema

schema = node.schemas.add({
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object", "required": ["a"],
    "properties": {"a": {"type": "object", "required": ["role"], "properties": {
        "role": {"type": "string"}, "delegates": {"type": "array", "items": {"type": "string"}}}}}
}, {"role": "member"})

The result is the digest of the schema and identical everywhere. The second argument is a template of default attributes.

Issue

bundle = node.issuer.issue(schema, subject_aid, {"role": "manager", "delegates": ["operator"]})

The registry, the issuance and the credential are anchored in the issuer's log. The bundle contains everything a verifier needs: credential, issuance event, registry event, schema and chain.

Attribute Meaning
role Role used by policies
delegates Roles the holder may issue to others
not_before, expires Validity, ISO 8601 with time zone

Chain

The holder of manager with delegates: ["operator"] can issue an operator credential by naming its own as parent:

child = block.issuer.issue(schema, instance_aid, {"role": "operator"}, parent=bundle)

Verify

facts = node.verifier.verify(bundle, holder_aid, node.roots, 4)

Verification checks digests, schema, subject, registry, anchors in the issuer's log, witnesses, revocation (including what watchers report), validity, and the chain up to a trusted root. The result lists one fact for each credential of the chain, with issuer, role and attributes.

trusted_roots in the policy lists the identities whose credentials are accepted as roots. "self" is the node itself.

Revoke

node.issuer.revoke(credential_said)

Revocation takes effect for verifiers as soon as they see the issuer's log. Children of a revoked credential no longer verify.