Choose what this site may use

This site uses strictly necessary cookies to work and to remember your privacy choices. With your permission it would also load content hosted by other services, such as videos, maps and fonts, which then receive your network address and device data. We do not sell or share your personal information and we run no advertising. Choose Accept all, Reject all or Customise. You can change your mind at any time through Privacy choices at the foot of every page.

  • Always on

    Needed for the site to work and to remember your privacy choices. Always on.

  • Remembers settings you choose, such as the light or dark display, in your browser.

  • Loads videos, maps and other content hosted by other services. Those services receive your address and device data.

Menu Close
In this section: Learn
Start
Guides
Domain packs
Participants
Security and privacy
Pilot kits
Operations
Ecosystem

Python SDK: the 0.2 candidate mode (DRAFT)

Source docs/guides/python-sdk.md

On this page
  1. Install
  2. What is in it
  3. Commands
  4. How the three agree
  5. Limits
  6. Tests

The obsp package (sdk/python) validates documents against the live obsp/0.1 schemas, computes RFC 8785 digests and runs the conformance suite. That behaviour is the default and does not change. This guide covers the opt-in 0.2 candidate mode, obsp.candidate, which brings the Python SDK level with the TypeScript SDK (reference/typescript/obsp-sdk) and the Rust verifier for the draft proposals.

Every proposal is a DRAFT. Nothing in obsp.candidate is part of the protocol until the editors accept the proposals, and nothing in it makes a conformance claim: a result describes the documents checked, never an implementation.

Install

python3 -m pip install -e 'sdk/python[candidate]'     # from the repository root; the extra adds the cryptography package

The default package needs only jsonschema and PyYAML. The candidate mode needs cryptography for signatures (Ed25519, ECDSA P-256 and P-384, and ML-DSA when the installed version offers it). Without it the default commands work as before and a candidate command says which package is missing. The package is typed (py.typed).

What is in it

Module What it does
obsp.candidate.objects_02, objects_05, objects_drafts dataclasses for every schema of the 0.2 candidate (46), of the 0.5 series end state (66) and of the schemas the drafts outside the series add (7), generated from the JSON Schemas
obsp.candidate.signature, algorithms signature envelopes (OIP-0008): sign and verify, the algorithm register, the payload rules
obsp.candidate.draft_checks (and proofs, plans, observation, mobile, triggers, coverage) the 23 checks the drafts define
obsp.candidate.verify a set of documents: schemas, identifiers, digests, signatures, references and the draft checks
obsp.candidate.compact compact CBOR (OIP-0027): the key tables and the converter in both directions
obsp.candidate.triggers the OIP-0018 trigger evaluator
obsp.candidate.schemas the bundled candidate schemas (CandidateSchemas)

Typed objects

from obsp.candidate import objects_02 as o

record = o.SCHEMAS["observation-record"].from_dict(document)   # a dataclass; nested objects are dataclasses too
record.observer.class_                                         # a member named like a Python keyword gets a trailing underscore
record.to_dict() == document                                   # the document comes back; unknown members are kept where the schema allows them

The classes check nothing: validation is the schema’s (obsp verify, or CandidateSchemas("0.2").validate(name, document)). A required member that is missing is a ValueError; from_dict(..., strict=True) also refuses a member a closed schema does not allow. An optional member that is absent is None and is left out again by to_dict, so an explicit null is not kept.

The classes and obsp/candidate/data/schemas.json are generated from the integration series (oips/integration/0.2, oips/integration/0.5) and the drafts, which are applied to a temporary copy of the files they touch, so the tree is never changed:

python3 tools/gen_python_objects.py            # rewrite the generated files
python3 tools/gen_python_objects.py --check    # exit 1 when a file is stale (a test runs the same comparison)

Regenerate after a schema, draft or series change. The generated files carry no hand edits.

Signatures

from obsp.candidate.signature import sign_envelope, verify_envelope, public_jwk

signed = sign_envelope(document, secret_bytes, "ed25519", "uni:key:example-1", payload_rule="integration-0.2")
result = verify_envelope(signed, [key_record], object_class="receipt", payload_rule="integration-0.2")
result.status, result.code      # 'valid' | 'invalid' | 'unavailable', and OBS-SIG-0001 to OBS-SIG-0008 on failure

A COSE_Sign1 (RFC 9052) with a detached JCS payload, as the OIP-0008 draft describes. Two payload rules (SIG-2): oip-0008 (the default, the draft as written: the payload leaves out signature) and integration-0.2 (the 0.2 series, which adopts OIP-0002’s proposal that it also leaves out transparencyReceipt; OIP-0002’s open question 2 stays open). Algorithms: ed25519, es256, es384, and ml-dsa-44, ml-dsa-65, ml-dsa-87 when cryptography provides them; otherwise the result is unavailable, never valid. Keys are resolved against key records by UNI or RFC 7638 thumbprint. The failure codes and the order of the checks are those of the TypeScript SDK, and the 18 published vectors give their stated results.

The 23 checks

run_draft_checks(items) takes documents with the schema each was detected as and returns one row per subject document and check: PASS, FAIL, or INCONCLUSIVE when the set lacks a document the check needs (or, for PRV-6, when a location proof has fewer than two independent sources). The ids, requirement ids and verdicts are those of the TypeScript SDK.

Check Draft Requirements Where
proof-challenge-window OIP-0002 PRV-1 0.2 series
proof-receipt-bound-to-challenge OIP-0002 PRV-2, PRV-3 0.2 series
proof-challenge-not-replayed OIP-0002 PRV-4 0.2 series
verification-report-inputs-match OIP-0002 PRV-9, PRV-5 0.2 series
location-proof-independent-sources OIP-0002 PRV-6 0.2 series
time-proof-trusted-time-quality OIP-0002 PRV-7 0.2 series
eo-custody-chain-linked OIP-0002 PRV-8 0.2 series
transparency-receipt-binds-statement OIP-0002 PRV-10 0.2 series
plan-threshold-signed OIP-0003 ORCH-3, ORCH-6 0.2 series
plan-metadata-consistent OIP-0003 ORCH-4 0.2 series
plan-version-unique OIP-0003 ORCH-1 0.2 series
plan-kind-reserved OIP-0003 ORCH-8 0.2 series
plan-not-expired-when-accepted OIP-0003 ORCH-2 0.2 series
plan-timestamp-fresh OIP-0003 ORCH-5 0.2 series
plan-version-monotonic OIP-0003 ORCH-1 0.2 series
receipt-references-plan OIP-0003 ORCH-7 0.2 series
observation-origin-consistent OIP-0006 OBS-3 0.2 series
observation-subject-policy OIP-0006 OBS-4 0.2 series
trajectory-time-ordered OIP-0013 MOB-2 draft outside the series
trajectory-speed-plausible OIP-0013 MOB-3 draft outside the series
trigger-evaluation-links-definition OIP-0018 TRG-6, TRG-4 draft outside the series
trigger-evaluation-reproducible OIP-0018 TRG-7 draft outside the series
coverage-chunks-in-manifest OIP-0020 EOP-2 draft outside the series

Commands

obsp routes verify, sign, compact and trigger to the candidate mode; every other command goes unchanged to the default command line (obsp --help names both).

obsp verify --profile 0.2 ./evidence                      # files or folders of JSON; --json for a report, --brief for no findings
obsp sign doc.json --key key.txt --alg ed25519 --kid uni:key:example-1 --payload-rule integration-0.2 --out signed.json
obsp compact tables
obsp compact encode observation record.json --hex         # JSON to compact CBOR (OIP-0027)
obsp compact decode observation record.cbor.hex --hex
obsp trigger evaluate --definition def.json --at 2026-11-01T12:00:00Z records.json
obsp trigger evaluate --definition def.json --check evaluation.json records.json   # TRG-7: does the evaluation reproduce?
  • verify checks, for each document: JSON, schema (found by _schemaTitle, apiVersion, kind, or by fit), identifier, digests, signature (against the key records in the set, payload rule integration-0.2), references between the documents (digest recomputed), and the draft checks. The report has the shape of the web verifier’s. Exit codes: 0 PASS, 1 FAIL, 3 INCONCLUSIVE (a key, a document or an algorithm the set lacks), 2 usage error. --profile 0.2 is the only profile.
  • sign reads a private key from a file (hex text, or JSON with seedHex: an Ed25519 seed, an EC scalar or an ML-DSA seed). Keep keys out of the command line and out of the tree; the test keys of the OIP-0008 vectors are published and protect nothing. --signer-role sets signature.signerRole, which some schemas require.
  • compact converts between a JSON document and its compact form for the tables observation, time-quality and evidence-batch, and refuses a member the table does not know and a CBOR item that is not deterministically encoded.
  • trigger evaluate prints the reproducible part of an evaluation (definition, basis, window, inputs, excluded, computed, result). Sums are correctly rounded and values are rounded half to even to six places, so the result does not depend on the order of the records. Time counts as trusted only through a time-quality record given with --time-quality.

How the three agree

sdk/python/tests/test_candidate_crosscheck.py runs Node.js on the web verifier’s example sets of the 0.2 mode and on 140 sets each changed in one place, and requires the Python report to equal the TypeScript one: verdict, detected schema, every check with its status and message key, and the findings of the draft checks. The published signature vectors (test_candidate_signature.py), the plan vectors of the series and the ten OIP-0018 evaluator vectors (test_candidate_checks.py) and the OIP-0027 vectors (test_candidate_compact.py) are run against the Python code directly. The cross-check is skipped when Node.js is not installed.

One difference is on purpose: the TypeScript evaluator throws when a trigger definition has lost a required member, while the Python check reports the evaluation as INCONCLUSIVE.

Limits

  • Draft material only: the schemas, the register, the payload rules and the checks follow proposals that may change. The results of the checks describe documents; none of them is a conformance level or a claim about an implementation.
  • No pure-Python signature fallback: without cryptography there is no signing or verifying, and without ML-DSA in the installed version those vectors are reported as unavailable.
  • The 0.5 series end state has classes but no profile: obsp verify validates against the 0.2 candidate only.
  • The Rust verifier and the TypeScript SDK are separate code; this module is a port checked against them, not a binding.

Tests

make sdk-test      # includes the candidate tests (part of make check)
make ts            # the TypeScript side, when Node.js is installed