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.dev49.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.dev49-py3-none-any.whl (14.9 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarmauri_signing_jws-0.3.0.dev49.tar.gz
  • Upload date:
  • Size: 15.2 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

Hashes for swarmauri_signing_jws-0.3.0.dev49.tar.gz
Algorithm Hash digest
SHA256 bb64070b633e7161c8b2c2f238605777546d23a487727edfd4a5af10b22d6f50
MD5 0392ace87e5e8a5981f9fd6dd35f564d
BLAKE2b-256 1d46e7a6108c80c7ae402b3fbba31a0aaad3ba1be470965d6f18d04b98532bf7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_signing_jws-0.3.0.dev49-py3-none-any.whl
  • Upload date:
  • Size: 14.9 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

Hashes for swarmauri_signing_jws-0.3.0.dev49-py3-none-any.whl
Algorithm Hash digest
SHA256 40f076b5fb81d49aedbd7eae79c4c2d5dd75c1e7119389c4d7f19d6ff8d44387
MD5 59be25d6a62a5fbe45369bc0d7a08999
BLAKE2b-256 4f2ba2d3dd805e2b016548f52a89a412a6724d27b4acaca10249ef62c978c667

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