Skip to content

First-party self-declaration as a Verifiable Credential

Generated file

This page is generated by docs/notebooks/render_notebooks.py from the marimo notebook declaration.py. Do not edit it here: edit the notebook and regenerate. The CI notebooks job runs every cell, so the outputs below are from a real execution. The plumbing the example imports - graph setup, SHACL check, JWT signing - is in common.py, deliberately kept out of the page.

Builds a cap:Declaration - the ISO 17000 first-party case, where the supplier declares its own conformity - against a named external scheme, traces the scheme to the criteria it must meet, and issues it as a signed Verifiable Credential.

Import modules

The graph setup, the SHACL check and the JWT signing come from common.py, the module shared by both worked examples; only the CAP modelling is here.

from datetime import datetime, timedelta

from dateutil.relativedelta import relativedelta
from rdflib import RDF, RDFS, Graph, Literal, Node, URIRef
from rdflib.namespace import FOAF, SDO, XSD

from common import issue_signed_vcs, new_graph, validate_against_cap_shapes

Pick the Eclipse CAP version and the other vocabularies

example = new_graph(cap_version="v0")
g, CAP, CRED, GX, EX = example.g, example.CAP, example.CRED, example.GX, example.EX

The scheme being declared against

CRITERIA = (
    "https://docs.gaia-x.eu/policy-rules-committee/compliance-document/25.03/criteria_cloud_services/#P5.1.2",
    "https://docs.gaia-x.eu/policy-rules-committee/compliance-document/25.03/criteria_cloud_services/#P5.1.4",
)


def generate_cap_scheme(graph: Graph) -> Node:
    scheme = URIRef("https://docs.gaia-x.eu/label/level3/25.03#")
    graph.add((scheme, RDF.type, CAP.ConformityAssessmentScheme))
    graph.add((scheme, RDFS.label, Literal("Gaia-X Label level 3")))
    graph.add((scheme, RDFS.comment, Literal("version 25.03")))

    system = URIRef("https://docs.gaia-x.eu/framework/25.03#")
    graph.add((system, RDF.type, CAP.ConformityAssessmentSystem))
    graph.add((system, RDFS.label, Literal("Gaia-X Framework 25.03")))
    graph.add((scheme, CAP.managedWithin, system))

    for criterion in CRITERIA:
        requirement = URIRef(criterion)
        graph.add((scheme, CAP.hasSpecifiedRequirement, requirement))
        graph.add((requirement, RDF.type, CAP.SpecifiedRequirement))
    return scheme

Generate the cap:Declaration

def generate_cap_declaration(graph: Graph) -> Node:
    declaration = EX.my_declaration
    graph.add((declaration, RDF.type, CAP.Declaration))
    graph.add((declaration, CAP.hasConformityAssessmentScheme, generate_cap_scheme(graph)))

    subject = EX.OutScaleSAS_IaaS
    graph.add((declaration, CAP.hasObjectOfConformityAssessment, subject))
    graph.add((subject, RDF.type, CAP.ObjectOfConformityAssessment))

    issuance_date = datetime(year=2025, month=3, day=1)
    graph.add((declaration, CAP.issuedAt, Literal(issuance_date.isoformat(), datatype=XSD.dateTime)))
    graph.add((declaration, CAP.validFrom, Literal(issuance_date.isoformat(), datatype=XSD.dateTime)))
    graph.add(
        (
            declaration,
            CAP.validUntil,
            Literal((issuance_date + relativedelta(years=1)).isoformat(), datatype=XSD.dateTime),
        )
    )

    declarant = EX.SuperCSP
    graph.add((declaration, CAP.issuedBy, declarant))
    graph.add((declarant, RDF.type, CAP.ConformityAssessmentBody))
    graph.add((declarant, RDF.type, GX.LegalPerson))
    graph.add((declarant, FOAF.name, Literal("SuperCSP", lang="en")))
    graph.add((declarant, SDO.vatID, Literal("FR00000000001")))

    print(f"The cap:Declaration is {declaration.n3()}")
    print(f"It is issued by {declarant.n3()}, declaring its own conformity")
    return declaration


declaration = generate_cap_declaration(g)
The cap:Declaration is <http://example.com/#my_declaration>
It is issued by <http://example.com/#SuperCSP>, declaring its own conformity

Create the Verifiable Credential

vc = EX.myvc
g.add((vc, RDF.type, CRED.VerifiableCredential))
g.add((vc, CRED.issuer, Literal("did:web:super-cloud.eu")))
# Fixed instant: this notebook's output is committed as a generated page,
# so it must not churn on every regeneration.
valid_from = datetime(2026, 11, 16, 12, 0, 0)
valid_until = valid_from + timedelta(days=90)
g.add((vc, CRED.validFrom, Literal(valid_from.isoformat(), datatype=XSD.dateTime)))
g.add((vc, CRED.validUntil, Literal(valid_until.isoformat(), datatype=XSD.dateTime)))

# attach the cap:Declaration to the VC
g.add((vc, CRED.credentialSubject, declaration))

Display RDF data in Turtle format

print(g.serialize(format="ttl"))
@prefix cap: <https://w3id.org/eclipse-cap/v0/#> .
@prefix cred: <https://www.w3.org/ns/credentials/v2/> .
@prefix ex: <http://example.com/#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
@prefix gx: <https://w3id.org/gaia-x/development#> .
@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .
@prefix schema: <https://schema.org/> .

ex:myvc a cred:VerifiableCredential ;
    cred:credentialSubject ex:my_declaration ;
    cred:issuer "did:web:super-cloud.eu" ;
    cred:validFrom "2026-11-16T12:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
    cred:validUntil "2027-02-14T12:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

ex:OutScaleSAS_IaaS a cap:ObjectOfConformityAssessment .

ex:SuperCSP a cap:ConformityAssessmentBody,
        gx:LegalPerson ;
    foaf:name "SuperCSP"@en ;
    schema:vatID "FR00000000001" .

ex:my_declaration a cap:Declaration ;
    cap:hasConformityAssessmentScheme <https://docs.gaia-x.eu/label/level3/25.03#> ;
    cap:hasObjectOfConformityAssessment ex:OutScaleSAS_IaaS ;
    cap:issuedAt "2025-03-01T00:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
    cap:issuedBy ex:SuperCSP ;
    cap:validFrom "2025-03-01T00:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> ;
    cap:validUntil "2026-03-01T00:00:00"^^<http://www.w3.org/2001/XMLSchema#dateTime> .

<https://docs.gaia-x.eu/framework/25.03#> a cap:ConformityAssessmentSystem ;
    rdfs:label "Gaia-X Framework 25.03" .

<https://docs.gaia-x.eu/label/level3/25.03#> a cap:ConformityAssessmentScheme ;
    rdfs:label "Gaia-X Label level 3" ;
    rdfs:comment "version 25.03" ;
    cap:hasSpecifiedRequirement <https://docs.gaia-x.eu/policy-rules-committee/compliance-document/25.03/criteria_cloud_services/#P5.1.2>,
        <https://docs.gaia-x.eu/policy-rules-committee/compliance-document/25.03/criteria_cloud_services/#P5.1.4> ;
    cap:managedWithin <https://docs.gaia-x.eu/framework/25.03#> .

<https://docs.gaia-x.eu/policy-rules-committee/compliance-document/25.03/criteria_cloud_services/#P5.1.2> a cap:SpecifiedRequirement .

<https://docs.gaia-x.eu/policy-rules-committee/compliance-document/25.03/criteria_cloud_services/#P5.1.4> a cap:SpecifiedRequirement .

Verify the document with SHACL

validate_against_cap_shapes(g)
********************************************************************************
True [a rdfg:Graph;rdflib:storage [a rdflib:Store;rdfs:label 'Memory']]. Validation Report
Conforms: True

Issue the signed Verifiable Credential

issue_signed_vcs(g, CRED)
Public Key in JWK format: {"crv":"Ed25519","kid":"zD6Ku27DiffK3Eo53dEThwg7azhZfXYV0x8egjO42jA","kty":"OKP","x":"7p4c1IU6aA65FWn6YZ-Bya5dRbfd4P6d4a6H0u9-gCg"}
eyJhbGciOiJFZERTQSIsImN0eSI6InZjIiwidHlwIjoidmMrand0In0.eyJAY29udGV4dCI6eyJjYXAiOiJodHRwczovL3czaWQub3JnL2VjbGlwc2UtY2FwL3YwLyMiLCJjcmVkIjoiaHR0cHM6Ly93d3cudzMub3JnL25zL2NyZWRlbnRpYWxzL3YyLyIsImV4IjoiaHR0cDovL2V4YW1wbGUuY29tLyMiLCJmb2FmIjoiaHR0cDovL3htbG5zLmNvbS9mb2FmLzAuMS8iLCJneCI6Imh0dHBzOi8vdzNpZC5vcmcvZ2FpYS14L2RldmVsb3BtZW50IyIsInJkZnMiOiJodHRwOi8vd3d3LnczLm9yZy8yMDAwLzAxL3JkZi1zY2hlbWEjIiwic2NoZW1hIjoiaHR0cHM6Ly9zY2hlbWEub3JnLyJ9LCJAaWQiOiJleDpteXZjIiwiQHR5cGUiOiJjcmVkOlZlcmlmaWFibGVDcmVkZW50aWFsIiwiY3JlZDpjcmVkZW50aWFsU3ViamVjdCI6eyJAaWQiOiJleDpteV9kZWNsYXJhdGlvbiIsIkB0eXBlIjoiY2FwOkRlY2xhcmF0aW9uIiwiY2FwOmhhc0NvbmZvcm1pdHlBc3Nlc3NtZW50U2NoZW1lIjp7IkBpZC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