Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_signing_rsa Discord

Swarmauri Signing RSA

An asynchronous RSA signer implementing the ISigning interface for detached signatures over raw bytes and canonicalized envelopes.

Capabilities

  • Detached signatures for byte payloads as well as canonicalized envelopes
  • JSON canonicalization is built in; CBOR canonicalization is available when cbor2 is installed
  • RSA-PSS-SHA256 (default) and RS256 signature algorithms powered by cryptography
  • Verification requires the expected RSA public keys to be provided through opts["pubkeys"], enabling multi-signer verification scenarios
  • Private and public keys can be supplied as PEM strings, filesystem paths, RFC 7517 JWKs, or raw cryptography key objects via Swarmauri KeyRef dictionaries

Installation

Pick the tool that matches your workflow:

# pip
pip install swarmauri_signing_rsa

# Poetry
poetry add swarmauri_signing_rsa

# uv
uv add swarmauri_signing_rsa

Quickstart

The example below generates an RSA key, signs a JSON envelope, and then verifies the detached signature using the corresponding public key. The same pattern applies to raw byte payloads via sign_bytes/verify_bytes.

import asyncio

from cryptography.hazmat.primitives.asymmetric import rsa

from swarmauri_signing_rsa import RSAEnvelopeSigner


def key_ref_from_private(private_key):
    return {"kind": "cryptography_obj", "obj": private_key}


def key_ref_from_public(public_key):
    return {"kind": "cryptography_obj", "obj": public_key}


async def main() -> None:
    signer = RSAEnvelopeSigner()
    private_key = rsa.generate_private_key(public_exponent=65537, key_size=2048)

    envelope = {"payload": {"msg": "hello"}, "headers": {"alg": "RSA-PSS-SHA256"}}

    signatures = await signer.sign_envelope(
        key_ref_from_private(private_key),
        envelope,
        canon="json",
        alg="RSA-PSS-SHA256",
    )

    is_valid = await signer.verify_envelope(
        envelope,
        signatures,
        opts={"pubkeys": [key_ref_from_public(private_key.public_key())]},
    )

    assert is_valid


asyncio.run(main())

Entry Point

The signer registers under the swarmauri.signings entry point as RSAEnvelopeSigner and exposes the same name for the Peagen plugin registry.

Want to help?

If you want to contribute to swarmauri-sdk, read up on our guidelines for contributing that will help you get started.

Metadata

Release files for swarmauri_signing_rsa 0.11.0.dev1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for swarmauri_signing_rsa 0.11.0.dev1
File Size Uploaded
swarmauri_signing_rsa-0.11.0.dev1.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for swarmauri_signing_rsa 0.11.0.dev1
File Interpreter ABI Platform
swarmauri_signing_rsa-0.11.0.dev1-py3-none-any.whl Python 3 none any Details

Total release size: 21.6 kB

Release files / swarmauri_signing_rsa-0.11.0.dev1.tar.gz

Download URL swarmauri_signing_rsa-0.11.0.dev1.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
b20aa1c54a332654d98b18d5002a8cc31623c0265d462e2f24e0f5516cdf060a
BLAKE2b-256 checksum
How to use checksums
3d9681fb177f2dcaad1f22fd0cddfb68be7435c545294f5b6c279cbfddbfbcc4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}

Release files / swarmauri_signing_rsa-0.11.0.dev1-py3-none-any.whl

Download URL swarmauri_signing_rsa-0.11.0.dev1-py3-none-any.whl
Size 11.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f6e446ab5a826ab79aa74fb27d697782bf2f65d67e5788dc581edb63cf7ccca9
BLAKE2b-256 checksum
How to use checksums
a02f7961345a6584a0f9f2a5066943af2a965a30927a761099ad24f324ec367d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}
Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page