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

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarmauri_signing_rsa-0.3.0.dev31.tar.gz
  • Upload date:
  • Size: 10.1 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_rsa-0.3.0.dev31.tar.gz
Algorithm Hash digest
SHA256 9b5bf16afe357c8589a2ca9bca26cca7be7337bd50dc395dc4d7c167c0bd15f5
MD5 7a0ecc0c58cf8f5b538450ce7f3dda3c
BLAKE2b-256 e462287abb4dfbbb9b82530c0a661963c801dcd190b2b3ff4f8c5547838d8b64

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_signing_rsa-0.3.0.dev31-py3-none-any.whl
  • Upload date:
  • Size: 11.1 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_rsa-0.3.0.dev31-py3-none-any.whl
Algorithm Hash digest
SHA256 bdd629c58e3900016da6b858ba63f0ceef785435207ab075202a7e5754b588d3
MD5 49ad0e792bbc3a42be5c780ccfd027dc
BLAKE2b-256 1ba4def3ffcc6da49dcd13f5857d5371a6e20e99053575b4cad434a782bfe937

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