Skip to main content

Official SDK for the Grundnorm grounded source-of-law truth layer — resolve a legal norm by open identifier (ELI/ECLI) + date and verify its cryptographic seal locally.

Project description

grundnorm (Python SDK)

Resolve a legal norm by its open identifier (ELI/ECLI) and a date, and get back its canonical, sealed meaning as an independently verifiable signed object. The SDK recomputes the content hash and verifies every Ed25519 signature locally — you never have to trust the server.

  • Deterministic, zero-LLM read path. Honest not_found instead of a guess.
  • Point-in-time: [validFrom, validUntil).
  • Python 3.9+. One dependency: cryptography.

Install

pip install grundnorm

Use

from grundnorm import GrundnormClient

# Defaults to the public GDPR demonstrator. For a pilot:
#   GrundnormClient(endpoint="https://.../api/grundnorm/resolve", api_key="nlk_...")
client = GrundnormClient()

r = client.resolve(
    id="http://data.europa.eu/eli/reg/2016/679/art_5",
    jurisdiction="EU",
    at="2026-07-07",   # omit for "today"
)

if r.status == "found":
    print(r.norm["atoms"])          # subject / modality / action / condition / exception / scope + evidence
    print(r.verification["ok"])     # True only if hash recomputes AND all signatures verify

resolve() verifies the seal by default. Skip with verify=False, or verify a stored envelope later:

from grundnorm import verify
v = verify(norm)  # {"ok", "hash_ok", "view_consistent", "recomputed_hash", "signatures", "quorum"}

v["ok"] is the one signal to trust — True only when all four checks below hold; inspect the component fields for anything less.

How verification works (no trust required)

  1. Hash: sha256(canonicalize(norm["canonical"]["content"])) equals norm["seal"]["contentHash"], where canonicalize = JSON with keys sorted recursively (UTF-16 order), no whitespace, UTF-8.
  2. View integrity: the ergonomic English atoms/purpose are exactly what the sealed canonical.content projects to (view_consistent); canonical.content is the source of truth.
  3. Signatures: each seal.signatures[].signatureHex is a valid Ed25519 signature by that signer's publicKeyHex over the UTF-8 bytes of the seal.contentHash hex string.
  4. Quorum: at least 2 valid signatures including at least one sovereign (quorum["meets"]).

Errors

  • Nothing sealed for (id, date) → returns NotFound (a normal outcome).
  • Bad key, bad input, or server error → raises GrundnormError (.status, .code).

Demonstrator note: the demo corpus (GDPR sample) is signed by demo keys, not institutions, and its accuracy is not yet jurist-graded. See the project's DEMO-TRUTHFULNESS.md.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grundnorm-0.1.1.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

grundnorm-0.1.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

Details for the file grundnorm-0.1.1.tar.gz.

File metadata

  • Download URL: grundnorm-0.1.1.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for grundnorm-0.1.1.tar.gz
Algorithm Hash digest
SHA256 ff65db5254d92b17385e9745327844000e9cfc788656048fe4feead954f80f2e
MD5 42b5c5c4fc52189a170f2a0bd8a1e2f9
BLAKE2b-256 3ca62093205e46421dfc03c94f66fba1718666b55d109d3ea98c4dbd3fb54356

See more details on using hashes here.

File details

Details for the file grundnorm-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: grundnorm-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.5

File hashes

Hashes for grundnorm-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8341c7e3a21632af3a1e3b43ce2fc7cd30ad74b8c3a614d9621afe5e325ba9f4
MD5 9df1cdec2bd654a5e787084333b8aead
BLAKE2b-256 db8331133348ed820cb135fc72165309c13e7b9cf99ad34fdbb329b48f1bd53e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page