Skip to main content

Hierarchical 64-bit identifiers with HMAC-derived prefixes for stateless local validation.

Project description

HID64

Compact 64-bit hierarchical identifier with cryptographic local validation.

HID64 binds a child identifier to an externally-authenticated root_id and to its immediate parent_id via HMAC-SHA256, fitting the result into a 64-bit unsigned integer suitable for BIGINT storage and compact wire formats. Validation is local: a holder of the per-tenant secret can verify hierarchical relationships without database lookups or central coordination.

Install

pip install hierarchical-id64

Requires Python ≥ 3.8 and cryptography>=41. The module is imported as hid64; the distribution is named hierarchical-id64 on PyPI to keep the naming consistent with the companion package hierarchical-uuid.

Quick start

from hid64 import derive_key, generate_hid64, validate_hid64

master_key = b"replace-with-securely-stored-master-key"
tenant_key = derive_key(master_key, "tenant:acme")

root_id   = "tenant:acme"   # must be authenticated externally (JWT/OAuth/etc.)
parent_id = "app:42"

hid = generate_hid64(root_id, parent_id, tenant_key)
assert validate_hid64(root_id, parent_id, hid, tenant_key)

Specification and security model

The full v1.0 specification — including threat model, key rotation guidance, secret-custody as the security perimeter, complementary (not substitutive) authoritative integrity checks, and the graceful-degradation property under secret compromise — is at:

Related

For the companion 128-bit UUIDv8-compatible variant, see HUUID.

For the umbrella repository (specifications, threat-model note, IETF-style draft, both reference implementations), see github.com/hektorv/hid.

License

MIT — see LICENSE.

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

hierarchical_id64-1.0.0.tar.gz (4.0 kB view details)

Uploaded Source

Built Distribution

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

hierarchical_id64-1.0.0-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file hierarchical_id64-1.0.0.tar.gz.

File metadata

  • Download URL: hierarchical_id64-1.0.0.tar.gz
  • Upload date:
  • Size: 4.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for hierarchical_id64-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0c9f50860da5c43a0f168a049e1968394f974359a852305ea8c9209343082536
MD5 f291d3c5a9948eade5657ac48abf425b
BLAKE2b-256 b87132768f53c1d905d12e3bc7dcde4feb4e13cbe09f384b6ff75f793dea6994

See more details on using hashes here.

File details

Details for the file hierarchical_id64-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hierarchical_id64-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 484d4608650be7f53816823dd464343a774c0214f8df3135c56de0fceb7d881d
MD5 7034e3affe6dbbfc1d76e2a231d57cfb
BLAKE2b-256 48344fadc8d9aebec9e3593ee4eb2fcb7f551ac5a20ff9042853b1e2806331ca

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