DPoP signer/verifier for Swarmauri
Project description
Swarmauri Signing DPoP
DPoP proof signer/verifier implementing RFC 9449 for proof-of-possession over HTTP requests.
Features:
- Creates and validates
dpop+jwtproofs with embedded public JWK thumbprints. - Supports
ES256,RS256, andEdDSAalgorithms through theSigningBaseinterface. - Optional access-token hash binding (
ath), nonce enforcement, and replay-protection hooks.
Installation
The package is published on PyPI together with the dependencies required to sign and verify DPoP proofs.
pip
pip install swarmauri_signing_dpop
uv
uv add swarmauri_signing_dpop
Poetry
poetry add swarmauri_signing_dpop
Usage
DpopSigner implements the asynchronous SigningBase / ISigning interface. Signing requires the HTTP method and URL (opts['htm'] and opts['htu']), and verification requires the same data passed via require.
Signing and verifying a request
import asyncio
from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ed25519
from swarmauri_signing_dpop import DpopSigner
async def main() -> None:
signer = DpopSigner()
private_key = ed25519.Ed25519PrivateKey.generate()
priv_pem = private_key.private_bytes(
encoding=serialization.Encoding.PEM,
format=serialization.PrivateFormat.PKCS8,
encryption_algorithm=serialization.NoEncryption(),
)
key = {"kind": "pem", "priv": priv_pem, "alg": "EdDSA"}
signatures = await signer.sign_bytes(
key,
b"",
opts={"htm": "GET", "htu": "https://api.example/x"},
)
is_valid = await signer.verify_bytes(
b"",
signatures,
require={"htm": "GET", "htu": "https://api.example/x"},
)
assert is_valid
print("DPoP proof valid:", is_valid)
asyncio.run(main())
Signature format
sign_bytes and sign_envelope return a sequence with a single detached signature entry:
{
"alg": "EdDSA", # JWS algorithm used
"format": "dpop+jwt", # proof media type
"sig": "<compact JWT>", # DPoP proof token containing the claims
"jkt": "<thumbprint>", # SHA-256 JWK thumbprint for cnf.jkt binding
}
Use the jkt helper when comparing against cnf.jkt values embedded in access tokens.
Key references
Keys are provided using the KeyRef mapping expected by other Swarmauri signing packages:
{ "kind": "pem", "priv": <PEM bytes|str> }— RSA/EC keys and Ed25519 PKCS8 PEM.{ "kind": "jwk", "priv": <private JWK dict> }— accepts EC, RSA, or OKP keys with private fields.
For Ed25519 material, both formats are supported; the signer derives and embeds the public JWK automatically.
Options reference
opts['htm']/opts['htu']: HTTP method and URL that will be bound in the proof (required for signing).opts['nonce']: Optional server-issuedDPoP-Nonceto include in the proof.opts['access_token']: Optional access token to derive theathconfirmation hash.require['htm']/require['htu']: Expected method and URL (required for verification).require['max_skew_s']: IAT skew tolerance (defaults to 300 seconds).require['algs']: Allowed signing algorithms. Defaults to all supported values.require['nonce']: Expected nonce when enforcing a server challenge.require['access_token']: Expected bearer token when validatingath.require['replay']: Mapping withseen(jti) -> boolandmark(jti, ttl_s)callables for replay prevention.
sign_envelope and verify_envelope reuse the same logic after canonicalizing the envelope to bytes (raw or json). Payload bytes are otherwise unused because the DPoP proof binds request metadata instead of message content.
Entry Point
The signer registers under the swarmauri.signings entry point as DpopSigner.
Want to help?
If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_signing_dpop-0.1.2.dev24.tar.gz.
File metadata
- Download URL: swarmauri_signing_dpop-0.1.2.dev24.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ee05f66cbc0e67af47943809a64fc0a9044948ccaeafd249f43d97522feb3e55
|
|
| MD5 |
703d94cc759c908ce82999ba09884a5b
|
|
| BLAKE2b-256 |
fa3b5f097daa67a9b98991453abf4fbcb60f06ad6a3bab6b2850953411699a3e
|
File details
Details for the file swarmauri_signing_dpop-0.1.2.dev24-py3-none-any.whl.
File metadata
- Download URL: swarmauri_signing_dpop-0.1.2.dev24-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9e8c277fe9a773a0d5716e445a24ef27696fb22b299be27ebf66e1afe707a781
|
|
| MD5 |
d91168af60afeafe0f7a40bb6dc7e3c2
|
|
| BLAKE2b-256 |
d7aa7d9d03af3da81f4c2cd257fa194379ef4a26f76b27877b321d67ebb0982f
|