Skip to main content

kxco-verify (Python)

Receiver-side verifier for the KXCO hybrid HMAC and ML-DSA webhook signature scheme, ML-DSA-87 and ML-DSA-65 (FIPS 204). Wire-format compatible with kxco-post-quantum (npm), the Go verifier, and the Rust verifier.

Install

pip install kxco-verify           # core (HMAC, envelope, fingerprint)
pip install kxco-verify[oqs]      # adds liboqs-python for ML-DSA
pip install kxco-verify[pqcrypto] # adds pqcrypto for ML-DSA

The HMAC, envelope, fingerprint, and timestamp paths use only the Python standard library. ML-DSA verification is lazy-loaded: it only requires a PQC backend when verify_pq is actually called. The pinned public key decides the parameter set: 2592 bytes is ML-DSA-87 and 1952 bytes is ML-DSA-65.

Quick start (FastAPI)

from fastapi import FastAPI, Request, HTTPException
import os
import kxco_verify as kx

PINNED_KID    = "1fd9ed3b769c28fc"  # current KXCO production kid, ML-DSA-87 (refresh from /.well-known if rotated)
PINNED_PUBKEY = bytes.fromhex("...5184 hex chars...")
HMAC_SECRET   = os.environ["KXCO_WEBHOOK_SECRET"].encode()

app = FastAPI()

@app.post("/webhooks/kxco")
async def webhook(request: Request):
    raw_body = await request.body()
    headers = {k.lower(): v for k, v in request.headers.items()}

    result = kx.verify_delivery(
        headers=headers,
        raw_body=raw_body,
        hmac_secret=HMAC_SECRET,
        pq_public_key=PINNED_PUBKEY,
        pinned_kid=PINNED_KID,
    )
    if not result.ok:
        raise HTTPException(401, "invalid signature")

    return {"ok": True}

Running tests

cd python
python test_kxco_verify.py

Expected: All 11 vector tests passed. Without an ML-DSA backend installed, the cryptographic ML-DSA cases are reported as SKIP; set KXCO_REQUIRE_PQ_BACKEND=1 to make a missing backend fail instead.

This verifies that the Python implementation produces identical outputs to vectors.json — the same file used by the JavaScript, Go, and Rust verifiers.

License

MIT.

Metadata

Release files for kxco-verify 1.2.2

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

Source distribution (sdist)

Source distribution for kxco-verify 1.2.2
File Size Uploaded
kxco_verify-1.2.2.tar.gz 6.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kxco-verify 1.2.2
File Interpreter ABI Platform
kxco_verify-1.2.2-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 kB

Release files / kxco_verify-1.2.2.tar.gz

Download URL kxco_verify-1.2.2.tar.gz
Size 6.1 kB
Tags Source
SHA-256 checksum
How to use checksums
a7b02cb8a99c0b68f2edb52735965d2f1e6e11105162a7cb9e3b568bffc1e2d3
BLAKE2b-256 checksum
How to use checksums
e30850a2ba746e84b8f3c9c9898b809b5f62bda30fdfba4e1f41f28e585a2b25
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

Release files / kxco_verify-1.2.2-py3-none-any.whl

Download URL kxco_verify-1.2.2-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
55a1c381aa92dac6f1b64bd821d9069ebeba7a350dab53e5e3e334445a2be5b3
BLAKE2b-256 checksum
How to use checksums
aecec32ca7db7ddfe1c0ee1af264ec7928435973c377a9b6295324539284de8b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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 Oct 9, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.2 This release

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.0

2 release files

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