Skip to main content

Composite JWS signer/verifier for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_signing_jws


Swarmauri Signing JWS

Composite JSON Web Signature (JWS) signer and verifier that orchestrates multiple Swarmauri signing providers behind a single asynchronous API.

Features

  • Async helpers for both compact and general JSON JWS serialization
  • Algorithm routing across HMAC (HS256/384/512), RSA (RS*/PS*), ECDSA (ES256/384/512), Ed25519 (EdDSA), and optional secp256k1 (ES256K when the secp256k1 extra is installed)
  • Works with direct key material, Swarmauri signer objects, or a JWKS resolver while returning the protected header and payload via JwsResult

Installation

pip

pip install swarmauri_signing_jws

Poetry

poetry add swarmauri_signing_jws

uv

To add the dependency to a pyproject.toml managed by uv:

uv add swarmauri_signing_jws

Or install it into the active environment:

uv pip install swarmauri_signing_jws

Optional extras:

  • secp256k1 enables ES256K support through swarmauri_signing_secp256k1

Usage

import asyncio
from swarmauri_signing_jws import JwsSignerVerifier


async def main() -> None:
    signer = JwsSignerVerifier()
    key = {"kind": "raw", "key": "0" * 32}

    compact = await signer.sign_compact(
        payload={"msg": "hi"},
        alg="HS256",
        key=key,
    )

    result = await signer.verify_compact(
        compact,
        hmac_keys=[key],
    )

    print(result.payload.decode("utf-8"))


if __name__ == "__main__":
    asyncio.run(main())

The public methods accept either raw strings or JWAAlg enum values for the alg parameter. Compact verification returns a JwsResult dataclass containing the parsed header and payload bytes so applications can safely forward or decode the authenticated message.

API highlights

  • sign_compact(...) / verify_compact(...) wrap the standard compact serialization, including optional allowlists and JWKS resolvers.
  • sign_general_json(...) / verify_general_json(...) operate on the general JSON serialization and support multi-signer verification with min_signers thresholds.
  • Each algorithm family accepts dedicated key collections (hmac_keys, rsa_pubkeys, ec_pubkeys, ed_pubkeys, k1_pubkeys) or a jwks_resolver callback for dynamic key retrieval.

HMAC key requirements

All HMAC-based operations require a secret of at least 32 bytes (256 bits).
Shorter keys are rejected to avoid truncation mistakes and to keep forgery probabilities negligible even after many verification attempts.

Rationale:

  • Forgery success scales with tag length; a 256-bit tag keeps the chance negligible even after many tries (NIST SP 800‑107 Rev.1).
  • RFC 7518 already mandates HS256 keys ≥ 256 bits; using the full HMAC-SHA-256 output avoids inadvertent strength reduction.
  • A full 32-byte tag preserves ≈128-bit security even under generic quantum search speedups (NIST IR 8547).
  • Fixed-length tags simplify constant-time verification and prevent configuration mismatches.

Entry Point

The signer registers under the swarmauri.signings entry point as JwsSignerVerifier.

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

swarmauri_signing_jws-0.3.0.dev30.tar.gz (15.2 kB view details)

Uploaded Source

Built Distribution

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

swarmauri_signing_jws-0.3.0.dev30-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_signing_jws-0.3.0.dev30.tar.gz.

File metadata

  • Download URL: swarmauri_signing_jws-0.3.0.dev30.tar.gz
  • Upload date:
  • Size: 15.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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

Hashes for swarmauri_signing_jws-0.3.0.dev30.tar.gz
Algorithm Hash digest
SHA256 020ac703c9c7d25c900291b34be6c7d9c61278889dda1f0425f65dbcb89b47ea
MD5 cd1e8b767bd03f40058e922fdbb21a57
BLAKE2b-256 228f9ee36af44f69d30e1b9830c5d8f279670f03f1982c8832a7add9945a93c7

See more details on using hashes here.

File details

Details for the file swarmauri_signing_jws-0.3.0.dev30-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_signing_jws-0.3.0.dev30-py3-none-any.whl
  • Upload date:
  • Size: 14.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.3 {"installer":{"name":"uv","version":"0.10.3","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

Hashes for swarmauri_signing_jws-0.3.0.dev30-py3-none-any.whl
Algorithm Hash digest
SHA256 3bdb383b4a5941bd4c56156411d9476463db25777c0f3a108d02d364d34348a7
MD5 453fae779944386e831949b31407cfb1
BLAKE2b-256 fdd241cf9ec70c8ec661a5a5901251751b46cbfb4e3684d07567b6266aa9c76c

See more details on using hashes here.

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