jwk-thumbprint-pure
RFC 7638 JWK Thumbprint — zero-dependency, pure Python.
Compute the Base64URL(SHA-256(CanonJCS(JWK))) thumbprint of any JSON Web Key without touching
cryptography,PyJWT, orjsonschema.
Quick Start
pip install git+https://github.com/prasad-a-abhishek/jwk-thumbprint-pure.git
from jwk_thumbprint_pure import thumbprint, verify
# RFC 7638 §3.1 — canonical RSA test vector
jwk_rsa = {
"kty": "RSA",
"n": "0vx7agoebGcQSuuPiLJXZptN9nndrQmbXEps2aiAFbWhM78LhWx4cbbfAAtVT86zwu1RK7aPFFxuhDR1L6tSoc_BJECPebWKRXjBZCiFV4n3oknjhMstn64tZ_2W-5JsGY4Hc5n9yBXArwl93lqt7_RN5w6Cf0h4QyQ5v-65YGjQR0_FDW2QvzqY368QQMicAtaSqzs8KJZgnYb9c7d0zgdAZHzu6qMQvRL5hajrn1n91CbOpbISD08qNLyrdkt-bFTWhAI4vMQFh6WeZu0fM4lFd2NcRwr3XPksINHaQ-G_xBniIqbw0Ls1jF44-csFCur-kEgU8awapJzKnqDKgw",
"e": "AQAB"
}
# RFC 7638 §3.1 thumbprint literal
assert thumbprint(jwk_rsa) == "NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs"
# Verify
assert verify(jwk_rsa, "NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs") is True
assert verify(jwk_rsa, "wrong") is False
CLI
# Compute thumbprint from command line
jwk-thumbprint '{"kty":"RSA","n":"...","e":"AQAB"}'
# Pipe a JWK through stdin
echo '{"kty":"EC","crv":"P-256","x":"...","y":"..."}' | jwk-thumbprint
# Verify a known thumbprint
jwk-thumbprint --verify NzbLsXh8uDCcd-6MNwXF4W_7noWXFZAfHkxZsRGC9Xs '{"kty":"RSA","n":"...","e":"AQAB"}'
# exit 0 if match, exit 1 if mismatch
Why jwk-thumbprint-pure?
- Zero dependencies — only Python standard library (
hashlib,base64,json). - RFC 7638 compliant — uses RFC 8785 JSON Canonicalization Scheme for deterministic serialization.
- Serverless-ready — works on AWS Lambda, Cloudflare Workers, Pyodide, and air-gapped environments.
- Pure Python — no C extensions, no
cryptography, noPyJWT.
Key Features
thumbprint(jwk, alg="SHA-256")→str— RFC 7638 thumbprintverify(jwk, expected, alg="SHA-256")→bool— constant-time comparisoncanonical_json(obj)→str— RFC 8785 deterministic JSON- CLI with
--verifyflag and stdin support
API Reference
thumbprint(jwk, alg="SHA-256")
def thumbprint(jwk: dict, alg: str = "SHA-256") -> str:
"""
Compute the RFC 7638 JWK thumbprint.
Args:
jwk: A dict representation of a JSON Web Key.
alg: Hash algorithm (SHA-256 only, per RFC 7638).
Returns:
Base64URL-encoded thumbprint with no padding.
"""
verify(jwk, expected, alg="SHA-256")
def verify(jwk: dict, expected: str, alg: str = "SHA-256") -> bool:
"""
Verify a JWK thumbprint against an expected value.
Returns:
True if the computed thumbprint matches, False otherwise.
"""
canonical_json(obj)
def canonical_json(obj: Any) -> str:
"""
RFC 8785 deterministic JSON serialization.
Object keys are sorted lexicographically.
Arrays retain original order.
No unnecessary whitespace.
"""
Limitations
- Only SHA-256 is supported (per RFC 7638; future algorithms not in scope).
- This library computes and verifies thumbprints only — it does NOT perform JWK validation, signature verification, or key generation. JWK keys with missing required members will raise
ValueError; empty-string members are accepted and hashed as-is (use a JWK validator upstream if you need stricter checks).
License
MIT License — © 2026 Repo Factory
Metadata
Release files for jwk-thumbprint-pure 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| jwk_thumbprint_pure-0.1.1.tar.gz | 17.3 kB | Without provenance | Details for jwk_thumbprint_pure-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| jwk_thumbprint_pure-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for jwk_thumbprint_pure-0.1.1-py3-none-any.whl |
Total release size: 26.4 kB
Release files / jwk_thumbprint_pure-0.1.1.tar.gz
| Download URL | jwk_thumbprint_pure-0.1.1.tar.gz |
|---|---|
| Size | 17.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6461047856d92968425193f3f825f4a8db32443f59d32586ba529ed09f9c8c53
|
|
BLAKE2b-256 checksum How to use checksums |
cad19acb0a29995d550e35b72f754312aab95e4500a08cf6803b4fefef2622c7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Release files / jwk_thumbprint_pure-0.1.1-py3-none-any.whl
| Download URL | jwk_thumbprint_pure-0.1.1-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ae73b9165b488d8087071972614048db9f8dd8c87491fd8354920f2138b46fb
|
|
BLAKE2b-256 checksum How to use checksums |
c3b88f7017d8f4a02a01d02797710efe0d323e5de2245f7b3be0165e13962fb0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.12.3
|
Security for jwk-thumbprint-pure 0.1.1
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
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.