Name | x402-hpke JSON |
Version |
0.1.0a1
JSON |
| download |
home_page | https://scrypted.ai |
Summary | Provider-agnostic HPKE envelope for the x402 spec. A utility for confidential, verifiable payment requests and receipts across untrusted intermediaries, using canonical AAD, optional sidecar projection, and cross-language (Python/Node) interoperability. |
upload_time | 2025-08-09 13:30:11 |
maintainer | None |
docs_url | None |
author | Tim Cotten |
requires_python | >=3.12 |
license | MIT |
keywords |
hpke
aead
x25519
jwks
envelope
|
VCS |
 |
bugtrack_url |
|
requirements |
No requirements were recorded.
|
Travis-CI |
No Travis.
|
coveralls test coverage |
No coveralls.
|
# x402-hpke (Python)
Monorepo: https://github.com/scryptedai/x402-hpke (Python path: `packages/python`, Node path: `packages/node`).
Provider-agnostic HPKE envelope library for x402 (Python). Pinned ciphersuite for interop:
X25519 / HKDF-SHA256 / ChaCha20-Poly1305 (envelope); streaming helpers use XChaCha20-Poly1305.
## Install
Python >= 3.12
```bash
pip install x402-hpke
```
## Quickstart
```python
from x402_hpke import create_hpke, generate_keypair, build_x402_headers
hpke = create_hpke(namespace="myapp")
pub, priv = generate_keypair()
x402 = {
"invoiceId": "inv_1",
"chainId": 8453,
"tokenContract": "0x" + "a"*40,
"amount": "1000",
"recipient": "0x" + "b"*40,
"txHash": "0x" + "c"*64,
"expiry": 9999999999,
"priceHash": "0x" + "d"*64,
}
envelope, headers = hpke.seal(
kid="kid1",
recipient_public_jwk=pub,
plaintext=b"hello",
x402=x402,
public={"x402Headers": True},
)
pt, xnorm, app = hpke.open(
recipient_private_jwk=priv,
envelope=envelope,
expected_kid="kid1",
public_headers=headers,
)
```
## Streaming (Python)
Chunk encryption helpers using XChaCha20-Poly1305:
```python
from x402_hpke import seal_chunk_xchacha, open_chunk_xchacha
key = bytes(32) # derive via app contract; export API is planned
prefix16 = bytes(16)
seq = 0
ct = seal_chunk_xchacha(key, prefix16, seq, b"chunk")
pt = open_chunk_xchacha(key, prefix16, seq, ct)
```
## JWKS utilities
- `fetch_jwks(url, min_ttl=60, max_ttl=3600)`
- `set_jwks(url, jwks, ttl=300)`
- `select_jwk(kid, jwks=None, url=None)`
## Notes
- AEAD is pinned to ChaCha20-Poly1305 for v1 (envelope). AES-256-GCM may be offered as an optional profile in future versions for FIPS-oriented environments; suite pinning remains per-version.
Raw data
{
"_id": null,
"home_page": "https://scrypted.ai",
"name": "x402-hpke",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.12",
"maintainer_email": null,
"keywords": "hpke, aead, x25519, jwks, envelope",
"author": "Tim Cotten",
"author_email": "tcotten@scrypted.ai",
"download_url": "https://files.pythonhosted.org/packages/c9/b5/9c01f143789a54961dc98f6e67390a93fe33d052a48e6fe3d62b899ae594/x402_hpke-0.1.0a1.tar.gz",
"platform": null,
"description": "# x402-hpke (Python)\n\nMonorepo: https://github.com/scryptedai/x402-hpke (Python path: `packages/python`, Node path: `packages/node`).\n\nProvider-agnostic HPKE envelope library for x402 (Python). Pinned ciphersuite for interop:\nX25519 / HKDF-SHA256 / ChaCha20-Poly1305 (envelope); streaming helpers use XChaCha20-Poly1305.\n\n## Install\n\nPython >= 3.12\n\n```bash\npip install x402-hpke\n```\n\n## Quickstart\n\n```python\nfrom x402_hpke import create_hpke, generate_keypair, build_x402_headers\n\nhpke = create_hpke(namespace=\"myapp\")\npub, priv = generate_keypair()\n\nx402 = {\n \"invoiceId\": \"inv_1\",\n \"chainId\": 8453,\n \"tokenContract\": \"0x\" + \"a\"*40,\n \"amount\": \"1000\",\n \"recipient\": \"0x\" + \"b\"*40,\n \"txHash\": \"0x\" + \"c\"*64,\n \"expiry\": 9999999999,\n \"priceHash\": \"0x\" + \"d\"*64,\n}\n\nenvelope, headers = hpke.seal(\n kid=\"kid1\",\n recipient_public_jwk=pub,\n plaintext=b\"hello\",\n x402=x402,\n public={\"x402Headers\": True},\n)\n\npt, xnorm, app = hpke.open(\n recipient_private_jwk=priv,\n envelope=envelope,\n expected_kid=\"kid1\",\n public_headers=headers,\n)\n```\n\n## Streaming (Python)\n\nChunk encryption helpers using XChaCha20-Poly1305:\n\n```python\nfrom x402_hpke import seal_chunk_xchacha, open_chunk_xchacha\n\nkey = bytes(32) # derive via app contract; export API is planned\nprefix16 = bytes(16)\nseq = 0\nct = seal_chunk_xchacha(key, prefix16, seq, b\"chunk\")\npt = open_chunk_xchacha(key, prefix16, seq, ct)\n```\n\n## JWKS utilities\n\n- `fetch_jwks(url, min_ttl=60, max_ttl=3600)`\n- `set_jwks(url, jwks, ttl=300)`\n- `select_jwk(kid, jwks=None, url=None)`\n\n## Notes\n\n - AEAD is pinned to ChaCha20-Poly1305 for v1 (envelope). AES-256-GCM may be offered as an optional profile in future versions for FIPS-oriented environments; suite pinning remains per-version.",
"bugtrack_url": null,
"license": "MIT",
"summary": "Provider-agnostic HPKE envelope for the x402 spec. A utility for confidential, verifiable payment requests and receipts across untrusted intermediaries, using canonical AAD, optional sidecar projection, and cross-language (Python/Node) interoperability.",
"version": "0.1.0a1",
"project_urls": {
"Documentation": "https://github.com/scryptedai/x402-hpke/tree/main/docs",
"Homepage": "https://scrypted.ai",
"Repository": "https://github.com/scryptedai/x402-hpke"
},
"split_keywords": [
"hpke",
" aead",
" x25519",
" jwks",
" envelope"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "23d67505d4ec7f720e63fc36200f82152cabfa105f3794eeb7614aa913e72f0d",
"md5": "11ef275f5efdbcc1a8e18879a563c2fe",
"sha256": "929428c12cbe1832da5e5e6e0651bf60741632bb92a6ea887206278e72cace39"
},
"downloads": -1,
"filename": "x402_hpke-0.1.0a1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "11ef275f5efdbcc1a8e18879a563c2fe",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.12",
"size": 9315,
"upload_time": "2025-08-09T13:30:10",
"upload_time_iso_8601": "2025-08-09T13:30:10.093219Z",
"url": "https://files.pythonhosted.org/packages/23/d6/7505d4ec7f720e63fc36200f82152cabfa105f3794eeb7614aa913e72f0d/x402_hpke-0.1.0a1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "c9b59c01f143789a54961dc98f6e67390a93fe33d052a48e6fe3d62b899ae594",
"md5": "c2a3e7d629f8d52bf70341f8a4224525",
"sha256": "209412330a2a68238afa35a9cc0a30543da144df8289fb31255ab607a32c7ee7"
},
"downloads": -1,
"filename": "x402_hpke-0.1.0a1.tar.gz",
"has_sig": false,
"md5_digest": "c2a3e7d629f8d52bf70341f8a4224525",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.12",
"size": 8191,
"upload_time": "2025-08-09T13:30:11",
"upload_time_iso_8601": "2025-08-09T13:30:11.408209Z",
"url": "https://files.pythonhosted.org/packages/c9/b5/9c01f143789a54961dc98f6e67390a93fe33d052a48e6fe3d62b899ae594/x402_hpke-0.1.0a1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-09 13:30:11",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "scryptedai",
"github_project": "x402-hpke",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "x402-hpke"
}