Skip to main content

hdp-core-py

hdp-core-py provides Python signing and verification for HDP protocol versions 0.1 and 0.2. The protocol is described in the HDP Internet-Draft, draft-helixar-hdp-agentic-delegation-04.

Install

python -m pip install hdp-core-py

Quick start

This example creates and signs one root record for each version, adds a signed hop, then verifies each record under the transition and strict policies. It generates fresh keys for both algorithms.

from time import time_ns
from uuid import uuid4

from hdp_core import TrustedKey, generate_key_pair, sign_hop, sign_root, verify_token


def sign_and_verify(alg: str, version: str) -> None:
    private_key, public_key = generate_key_pair(alg)
    kid = f"demo-{version}-{alg.lower()}"
    issued_at = time_ns() // 1_000_000
    unsigned_token = {
        "hdp": version,
        "header": {
            "token_id": str(uuid4()),
            "issued_at": issued_at,
            "expires_at": issued_at + 3_600_000,
            "session_id": "session-demo",
            "version": version,
        },
        "principal": {"id": "user-42", "id_type": "opaque"},
        "scope": {
            "intent": "Prepare a report",
            "data_classification": "internal",
            "network_egress": False,
            "persistence": False,
            "max_hops": 1,
        },
        "chain": [],
    }
    token = {
        **unsigned_token,
        "signature": sign_root(unsigned_token, private_key, kid=kid, alg=alg),
    }

    unsigned_hop = {
        "seq": 1,
        "agent_id": "researcher",
        "agent_type": "assistant",
        "timestamp": issued_at + 1_000,
        "action_summary": "Prepare an outline.",
        "parent_hop": 0,
    }
    token["chain"] = [{
        **unsigned_hop,
        "hop_signature": sign_hop(
            [unsigned_hop], token["signature"]["value"], private_key, alg=alg
        ),
    }]

    trusted_key = TrustedKey(alg=alg, public_key=public_key, status="active", kid=kid)
    transition = verify_token(token, trusted_key, policy="transition")
    strict = verify_token(token, trusted_key, policy="strict")
    assert transition.valid, transition

    if alg == "Ed25519":
        assert not strict.valid
        assert strict.error_code == "ALGORITHM_NOT_ACCEPTED"
        strict_result = f"rejected ({strict.error_code})"
    else:
        assert strict.valid, strict
        strict_result = "valid"

    print(f"{alg} (HDP {version}): transition valid, strict {strict_result}")


sign_and_verify("Ed25519", "0.1")
sign_and_verify("ML-DSA-65-Ed25519", "0.2")

Expected output:

Ed25519 (HDP 0.1): transition valid, strict rejected (ALGORITHM_NOT_ACCEPTED)
ML-DSA-65-Ed25519 (HDP 0.2): transition valid, strict valid

The example verifies the root and hop signatures with the same trusted key. The key's alg and optional kid must match the token signature.

Algorithms

Algorithm HDP version Class
Ed25519 0.1 Classical
ML-DSA-65-Ed25519 0.2 Composite
ML-DSA-87-ES384 0.2 Composite

generate_key_pair(alg) returns (private_key, public_key) as bytes. Composite keys contain the ML-DSA material and their registered classical component. sign_root(...) returns the {kid, alg, value} object stored as token["signature"]; sign_hop(...) returns the unpadded base64url string stored as hop_signature.

Verification policies

Pass a TrustedKey and a policy name to verify_token(token, trusted_key, policy=...).

Policy Accepted records
legacy Any registered algorithm with an active or retired key.
transition Composite algorithms with an active or retired key, and Ed25519 0.1 records with an active key. This is the default.
strict Composite algorithms with an active or retired key.

verify_token returns a VerificationResult with valid, failed_step, error_code, and algorithm_class fields. A policy rejection returns valid=False and error_code="ALGORITHM_NOT_ACCEPTED".

Record scope

HDP records delegation provenance. Verification reports record integrity; it does not authorize an operation or decide whether access is allowed. Applications make those decisions separately.

Metadata

Release files for hdp-core-py 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for hdp-core-py 0.1.0
File Size Uploaded Provenance Actions
hdp_core_py-0.1.0.tar.gz 9.2 kB With provenance Details for hdp_core_py-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for hdp-core-py 0.1.0
File Interpreter ABI Platform Actions
hdp_core_py-0.1.0-py3-none-any.whl Python 3 none any Details for hdp_core_py-0.1.0-py3-none-any.whl

Total release size: 21.2 kB

Release files / hdp_core_py-0.1.0.tar.gz

Download URL hdp_core_py-0.1.0.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
680f10adf3d1533a03bd9c864cc53c4625125ab5b73612eb4de0f66e890ab9a6
BLAKE2b-256 checksum
How to use checksums
e030ffd5b949e42eb12440f1362468897d4b1b65986c6698f7e3df667a3422de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Release files / hdp_core_py-0.1.0-py3-none-any.whl

Download URL hdp_core_py-0.1.0-py3-none-any.whl
Size 12.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5b320fd21b21c94b46744d78aaa1efbf9f12ca8eb729313864a3cc73f6b6ba4c
BLAKE2b-256 checksum
How to use checksums
3e2ad16d4fc5861765970ee0a28dc6de0bcab27617552a8634f555aaf7864443
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

Security for hdp-core-py 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for hdp_core_py-0.1.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Dec 4, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page