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

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarmauri_signing_rsa-0.3.0.dev49.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.dev49.tar.gz
Algorithm Hash digest
SHA256 aee90048be6f7ca7a1d97c1284591755db87fd9ba68f86e8347b454b05427ec5
MD5 93a2d19f7829f0a4e15e972514ba8cd1
BLAKE2b-256 7653b77a901ff0e26a33b260a1a70a67c3151c45d5200582fc41570cd7fb0e6b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_signing_rsa-0.3.0.dev49-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.dev49-py3-none-any.whl
Algorithm Hash digest
SHA256 d0e2d2687ed11bef4d603f29e0f53cdd237f047647f7b3a36b9a914a11ee023a
MD5 e44cac8b0b603587622b0e689cb90af1
BLAKE2b-256 e1ae02d5da7844f22baa0e0774224c61fd834489e924c2606add9da70228ee0b

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