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: Build
Start
Reference code
Tools
API reference
Public services
Agents
Bindings and crosswalks

obsp-core (Rust reference library)

REFERENCE Source reference/rust/obsp-core/README.md

On this page
  1. What it covers
  2. What it does not cover
  3. How to test
FieldValue
StatusReference code; live harness checks pass; no conformance claim
Version0.0.2

A small Rust library and command line tool for the building blocks of the Observatory Protocol. It is a reference aid for implementers, not a conformance claim: passing these tests says nothing about any implementation’s conformance level (see registers/conformance-profiles.yaml for how levels are evidenced).

A member of the workspace in reference/rust/ (see its README). Licence: Apache-2.0 (LICENSES/Apache-2.0.txt); the copied draft vectors under tests/vectors/ keep their source licence, CC-BY-4.0. The crate is self-contained: it reads the protocol’s schemas and fixtures at run time and does not build anything from the rest of the repository, so it can move to a repository of its own later.

What it covers

Module What it does
canonical RFC 8785 JSON Canonicalization Scheme over serde_json::Value: members sorted by UTF-16 code units, minimal string escapes, numbers written as ECMAScript Number.prototype.toString writes an IEEE 754 double (shortest round-trip digits, closest and then even on a tie)
digest The Digest form <alg>:<hex> of specification section 4.1 (request-context.schema.json $defs.Digest): parse, compute over canonical bytes, verify; sha256, sha384 and sha512
uni UNI syntax ^[A-Za-z0-9][A-Za-z0-9:._/@-]{7,255}$ and the durable scheme uni:<kind>:<local>
schema Validation against schemas/json/*.schema.json (JSON Schema 2020-12), indexed by $id, title and file name; fixtures are checked against the schema their _schemaTitle names, as tools/validate.py does
verify Ed25519 (RFC 8032) strict verification of a raw signature over a detached payload
cbor The CBOR subset (RFC 8949) the envelope needs: deterministic encoding (section 4.2.1: shortest heads, map keys in bytewise order of their encodings) and strict decoding (definite lengths, no floats, no duplicate keys, no trailing bytes)
algorithms The algorithm register of the draft proposal OIP-0008 (registers/algorithms.yaml on acceptance), loaded from YAML at run time: rows with family, status and COSE code points; object classes with the algorithms they accept and the family they require from a protocol version
signature The OIP-0008 draft signature envelope: signed bytes (RFC 8785 form of the object without its signature member), protected header {1: alg, 4: kid}, Sig_structure and tagged detached COSE_Sign1 (RFC 9052 sections 4.2 and 4.4), JWK thumbprint key ids (RFC 7638 in the RFC 9278 form), signing and verification with Ed25519, ECDSA P-256 and P-384 (RFC 6979 nonces when signing) and ML-DSA-44/65/87 (FIPS 204, pure, empty context; deterministic variant when signing), and the rejection codes OBS-SIG-0001 to OBS-SIG-0008 in the order of the repository’s reference verifier

Command line:

obsp digest [--alg sha256|sha384|sha512] <file.json>   # Digest of the file's canonical bytes
obsp validate [--schema <$id|title|name>] [--schemas <dir>] <file.json>

validate without --schema expects a fixture wrapper (_schemaTitle, document). The schema directory is --schemas, else the OBSP_SCHEMAS environment variable, else schemas/json in the nearest ancestor directory of the file. Exit status: 0 valid, 1 invalid, 2 usage or input error.

What it does not cover

  • The envelope follows a DRAFT proposal (OIP-0008) and changes with it. DSSE envelopes (supply-chain statements), the provisional composite and SLH-DSA rows (no COSE code point yet), key validity windows (validFrom, validUntil) and certificate chains (x5chain) are not verified; a verifier here resolves key ids against the key records it is given and nothing else.
  • Digest algorithms other than the three above. Other names that fit the Digest syntax parse but cannot be computed or verified.
  • Resolution of UNIs, or checks of a UNI kind against any register.
  • Invariants the schemas cannot express (they live in the Python suite), conformance cases, transport bindings and every protocol function above these building blocks.
  • Format assertion: format keywords are annotations, as in the repository’s own validator.

One deliberate strictness in canonical: an integer that an IEEE 754 double cannot hold exactly (magnitude above 2^53 and not representable) is refused instead of being rounded, because a rounded value would digest as a different document.

How to test

With a stable Rust toolchain (1.87 or later):

cd reference/rust
cargo test -p obsp-core

or make rust from the repository root, which runs the whole workspace’s tests only when cargo is installed. make rust is not part of make check: continuous integration has no Rust toolchain yet.

The tests include every OIP-0008 draft signature vector (copied into tests/vectors/oip-0008/; 4 valid, 14 invalid, each with its byte strings recomputed and, for the deterministic Ed25519 vectors, its signature reproduced by signing), the CBOR examples of RFC 8949 Appendix A, the RFC 8037 thumbprint example, the number and ordering examples of RFC 8785, the RFC 8032 Ed25519 test vectors, the FIPS 180-4 “abc” digests, every fixture under fixtures/positive (must validate) and fixtures/negative (must fail), and two cross-checks that are skipped when the tool is not installed: canonical output against Python’s json.dumps(sort_keys=True, separators=(',', ':'), ensure_ascii=False) for documents without floats, and number text against an ECMAScript engine (Node.js String(x)) for 40,000 pseudo-random doubles. Set OBSP_REPO_ROOT to run the repository-backed tests from a copy of the crate outside the repository.