Skip to main content

Receiver-side verifier for the KXCO hybrid HMAC + ML-DSA-65 webhook signature scheme

Project description

kxco-verify (Python)

Receiver-side verifier for the KXCO hybrid HMAC + ML-DSA-65 webhook signature scheme. 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-65 verification is lazy-loaded: it only requires a PQC backend when verify_pq is actually called.

Quick start (FastAPI)

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

PINNED_KID    = "aa29f37ab7f4b2cf"  # current KXCO production kid (refresh from /.well-known if rotated)
PINNED_PUBKEY = bytes.fromhex("...3904 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 6 vector tests passed.

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.

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

kxco_verify-1.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

kxco_verify-1.1.0-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file kxco_verify-1.1.0.tar.gz.

File metadata

  • Download URL: kxco_verify-1.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for kxco_verify-1.1.0.tar.gz
Algorithm Hash digest
SHA256 3437788c295797c59054b4c2f06ee9261f887ac446d8f058eead8d21f0844612
MD5 a7050c9c38b7d209834f9d297cbc574e
BLAKE2b-256 82400bbbb533e8b4417023f967a98cde02c7bd006d946f3cd50fe8e443e842a6

See more details on using hashes here.

Provenance

The following attestation bundles were made for kxco_verify-1.1.0.tar.gz:

Publisher: publish-python.yml on JackKXCO/kxco-post-quantum-verifiers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kxco_verify-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: kxco_verify-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.13

File hashes

Hashes for kxco_verify-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92cd7dce232997c97c5d77326071067e74b1e0e45ca3306d417b5a8e1ac05350
MD5 fddf5cff78c2d8e0cf2548f248fe13d2
BLAKE2b-256 133b63b926e5f51b9a613eb69024c37f3921d5f4cef46e3290435b79c14bc2c4

See more details on using hashes here.

Provenance

The following attestation bundles were made for kxco_verify-1.1.0-py3-none-any.whl:

Publisher: publish-python.yml on JackKXCO/kxco-post-quantum-verifiers

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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