Skip to main content

RSA-based signer for Swarmauri

Project description

Swarmauri Logo

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


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.

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_rsa-0.3.0.dev46.tar.gz (10.1 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_rsa-0.3.0.dev46-py3-none-any.whl (11.1 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_signing_rsa-0.3.0.dev46.tar.gz.

File metadata

  • Download URL: swarmauri_signing_rsa-0.3.0.dev46.tar.gz
  • Upload date:
  • Size: 10.1 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_rsa-0.3.0.dev46.tar.gz
Algorithm Hash digest
SHA256 009e0f2d57894da449d4010767246b58cecc9626aeba13df21a17dd0433720a3
MD5 d657cb2b27607e9076faa6543b56168f
BLAKE2b-256 ece09509ff5253bf1475275543ac622795c0d0e4e1ebb80a0313a5bb4f47ac92

See more details on using hashes here.

File details

Details for the file swarmauri_signing_rsa-0.3.0.dev46-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_signing_rsa-0.3.0.dev46-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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_rsa-0.3.0.dev46-py3-none-any.whl
Algorithm Hash digest
SHA256 74c27b0da49fde88dfd6ef20a5a8a7bdfa8df798e36f4bccfe009031daaa2b20
MD5 28b6794e6a480bc60babd65cf615a1fa
BLAKE2b-256 45785db192e6a1fc1460eda28e601c9cfeab9bd0069cd4edcb802ee65e4a8af7

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