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 (Go)

REFERENCE Source reference/go/obsp/README.md

On this page
  1. What it covers
  2. What it does not cover
  3. Tests
FieldValue
StatusReference code; no conformance claim
ToolchainGo 1.24 (go.mod)

A Go module for Observatory Protocol documents, written against the standard library only (no third-party modules). Module path obsp.example/obsp; it is a reference for reading and testing, not a product. This library makes no conformance claim.

What it covers

File What it does
jcs.go RFC 8785 canonical JSON. Numbers use the ECMAScript Number-to-String rules (ESNumber), member names sort by UTF-16 code units, strings escape as JSON.stringify does. ParseJSON refuses duplicate member names, trailing data and invalid UTF-8; numbers are IEEE 754 doubles
digest.go The Digest form <alg>:<hex> (specification section 4.1): ParseDigest, DigestBytes, ComputeDigest (over canonical bytes), VerifyDigest; sha256, sha384, sha512; any other well-formed algorithm parses but is not computed
uni.go UNI syntax of the live specification and both scheme forms of the OIP-0016 draft: uni:<kind>:<local> and uni:<authority>:<kind>:<local> (DNS name or did:web:<host>)
cbor.go A minimal deterministic CBOR codec (RFC 8949 section 4.2.1): integers, byte and text strings, arrays, maps (sorted by encoded key), tags, booleans, null. Floats and indefinite lengths are refused when decoding
signature.go, algorithms.go Signature envelope verification as the OIP-0008 draft proposes: COSE_Sign1 (RFC 9052) with a detached JCS payload, protected header checks, key resolution by UNI or RFC 7638 thumbprint, failure codes OBS-SIG-0001 to OBS-SIG-0008; Ed25519 (crypto/ed25519), ES256 and ES384 (crypto/ecdsa)
schema.go, ecmare.go A JSON Schema 2020-12 validator for the keywords the repository’s schemas use (same approach as reference/typescript/obsp-sdk: local $ref only, format as an annotation, an unsupported keyword is refused when the schema is compiled). Go’s RE2 has no lookahead, so ecmare.go is a small ECMA-262 pattern matcher with lookahead
cmd/obsp-go obsp-go digest and obsp-go verify (run obsp-go help)

What it does not cover

  • ML-DSA, SLH-DSA, composite and RS256 signatures: there is no verifier in this module, so the result is unavailable, never valid (the two ML-DSA vectors that need the signature itself are reported as skipped).
  • DSSE envelopes, signing, key management, key-record status checks beyond REVOKED, and trust decisions.
  • Schema keywords outside the supported list (for example unevaluatedProperties, $dynamicRef), remote $ref, and format assertions. Lone UTF-16 surrogates written as \uD800 escapes are replaced by Go’s JSON decoder before canonicalization and so are not refused.
  • Any claim that an implementation is conformant, certified or secure. Levels stop at SELF_TESTED.

OIP-0008 and OIP-0016 are DRAFT proposals. signature.go and algorithms.go follow the OIP-0008 proposal, not the live specification, which defines no signature; uni.go reads the OIP-0016 forms in addition to the live syntax.

Tests

make go from the repository root (or go vet ./... && go test ./... here; Go 1.24 or later):

  • every fixture of fixtures/positive validates and every one of fixtures/negative fails against the schema its _schemaTitle names (skipped outside a checkout of this repository);
  • RFC 8785 examples and key order; 20 000 doubles formatted by ESNumber and by Node.js String(number) compared, and the canonical bytes of every fixture and vector compared with reference/typescript/obsp-sdk (both run only when node is on the path);
  • digest known answers, UNI forms, CBOR known answers from RFC 8949 Appendix A, the ECMA pattern matcher;
  • every OIP-0008 draft vector (testdata/oip-0008/, copied from the draft, test keys only) reproduces its published bytes and verifies or fails with the code it states; the deterministic Ed25519 vectors are reproduced by signing.
go run ./cmd/obsp-go digest ../../../fixtures/positive/observation-record.valid.json
go run ./cmd/obsp-go verify --keys testdata/oip-0008/keys.json --class receipt object.json

Exit status: 0 ok or valid, 1 invalid or mismatch, 2 usage or input error, 3 unavailable.