Sign your first event
This tutorial walks you through producing your first cryptographically signed CDS event. You will install the SDK, generate an RSA-4096 keypair, build an event in code, and sign it. The whole exercise takes under five minutes.
Prerequisites
Section titled “Prerequisites”- Python 3.12+ or Node.js 20+
- An empty working directory
-
Install the SDK
Terminal window pip install signeddata-cdsTerminal window npm install @signeddata/cds-sdk -
Generate an RSA-4096 keypair
The producer holds the private key. Consumers only ever need the public key.
from cds import generate_keypairimport osos.makedirs("keys", exist_ok=True)generate_keypair("keys/private.pem", "keys/public.pem")import { generateKeypair } from "@signeddata/cds-sdk";import { mkdirSync } from "node:fs";mkdirSync("keys", { recursive: true });generateKeypair("keys/private.pem", "keys/public.pem"); -
Build a CDS event
This example builds a weather event for London using the canonical
WEATHER_CURRENTcontent type.from cds import CDSEvent, SourceMeta, ContextMeta, CDSVocab, CDSSourcesfrom datetime import datetime, timezoneevent = CDSEvent(content_type = CDSVocab.WEATHER_CURRENT,source = SourceMeta(id=CDSSources.OPEN_METEO),occurred_at = datetime.now(timezone.utc),lang = "en",payload = {"location": {"city": "London", "lat": 51.51, "lon": -0.13},"temperature": {"current": 14.0, "feels_like": 12.0},"condition": "overcast",},event_context = ContextMeta(summary = "London: overcast, 14C (feels 12C).",model = "rule-based-v1",),)import { CDSEvent, CDSVocab, CDSSources } from "@signeddata/cds-sdk";const event = new CDSEvent({content_type: CDSVocab.WEATHER_CURRENT,source: { "@id": CDSSources.OPEN_METEO },occurred_at: new Date(),lang: "en",payload: {location: { city: "London", lat: 51.51, lon: -0.13 },temperature: { current: 14.0, feels_like: 12.0 },condition: "overcast",},context: {summary: "London: overcast, 14C (feels 12C).",model: "rule-based-v1",generated_at: new Date().toISOString(),},}); -
Sign the event
from cds import CDSSignersigner = CDSSigner("keys/private.pem", issuer="https://myorg.example.com")signer.sign(event)print(event.integrity.hash) # sha256:...print(event.integrity.signed_by) # https://myorg.example.comimport { CDSSigner } from "@signeddata/cds-sdk";const signer = new CDSSigner("keys/private.pem", "https://myorg.example.com");signer.sign(event);console.log(event.integrity?.hash); // sha256:...console.log(event.integrity?.signed_by); // https://myorg.example.com -
Inspect the signed JSON-LD
import jsonprint(json.dumps(event.to_jsonld(), indent=2))console.log(JSON.stringify(event.toJSON(), null, 2));You should see a JSON document with
@context,@type,@id, and anintegrityblock containing the SHA-256 hash and base64-encoded RSA-PSS signature. This is a complete, verifiable CDS v0.2.0 event.
Next steps
Section titled “Next steps”- Verify a CDS event — verify the signature with the public key
- Connect Claude to an MCP server — give Claude access to signed data
- Self-host an issuer — run your own production setup
- Signing — the cryptographic details