Metadata-Version: 2.4
Name: hierarchical-id64
Version: 1.0.0
Summary: Hierarchical 64-bit identifiers with HMAC-derived prefixes for stateless local validation.
Author: Héctor Villa
License: MIT License
        
        Copyright (c) 2025 Héctor Villa
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Homepage, https://github.com/hektorv/hid
Project-URL: Specification, https://github.com/hektorv/hid/blob/main/hid64/specs/HID64-spec-v1.0.md
Project-URL: Source, https://github.com/hektorv/hid
Project-URL: Issues, https://github.com/hektorv/hid/issues
Keywords: identifier,hierarchical,hmac,cryptography,distributed-systems,multi-tenant,uuid,stateless-validation
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: Intended Audience :: System Administrators
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Security :: Cryptography
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Topic :: Internet :: WWW/HTTP
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: cryptography>=41
Dynamic: license-file

# 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

```sh
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

```python
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:

- [HID64 v1.0 Specification](https://github.com/hektorv/hid/blob/main/hid64/specs/HID64-spec-v1.0.md)

## Related

For the companion 128-bit UUIDv8-compatible variant, see
[HUUID](https://pypi.org/project/hierarchical-uuid/).

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

## License

MIT — see [LICENSE](https://github.com/hektorv/hid/blob/main/LICENSE).
