Skip to main content

Certificate authority style signer for Swarmauri envelopes

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_signing_ca


Swarmauri Signing CA

swarmauri_signing_ca exposes a certificate-authority-capable implementation of ISigning that focuses on detached signatures over raw bytes and canonicalized Swarmauri envelopes. The signer understands common public key algorithms and ships with utilities for issuing and validating X.509 material.

Highlights

  • Deterministic JSON canonicalization for envelopes (JSON is the supported canon).
  • Detached signature support for Ed25519, ECDSA (P-256 and compatible curves), and RSA-PSS/RS256.
  • Accepts PEM-encoded private keys or pre-instantiated cryptography objects via KeyRef.
  • X.509 helpers for issuing self-signed certificates, signing CSRs, and verifying simple chains.
  • Advertises the multi, detached_only, and x509 features under the swarmauri.signings entry point as CASigner.

Installation

Choose the tool that fits your workflow:

# pip
pip install swarmauri_signing_ca

# Poetry
poetry add swarmauri_signing_ca

# uv
uv add swarmauri_signing_ca

Quickstart

The example below generates an Ed25519 key, signs a message, and verifies the signature using the same public key. It mirrors what CASigner performs in production environments.

import asyncio

from cryptography.hazmat.primitives import serialization
from cryptography.hazmat.primitives.asymmetric import ed25519

from swarmauri_core.crypto.types import ExportPolicy, KeyRef, KeyType, KeyUse
from swarmauri_signing_ca import CASigner


async def main() -> None:
    signer = CASigner()

    private_key = ed25519.Ed25519PrivateKey.generate()
    key_ref = KeyRef(
        kid="demo-ed25519",
        version=1,
        type=KeyType.ED25519,
        uses=(KeyUse.SIGN,),
        export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
        material=private_key.private_bytes(
            encoding=serialization.Encoding.PEM,
            format=serialization.PrivateFormat.PKCS8,
            encryption_algorithm=serialization.NoEncryption(),
        ),
    )

    message = b"trust but verify"
    signatures = await signer.sign_bytes(key_ref, message)
    signature = signatures[0]

    verified = await signer.verify_bytes(
        message,
        signatures,
        opts={"pubkeys": [private_key.public_key()]},
    )

    print("Signature algorithm:", signature["alg"])
    print("Key fingerprint:", key_ref.fingerprint)
    print("Signature valid:", verified)

    assert verified is True


if __name__ == "__main__":
    asyncio.run(main())

Notes on verification

CASigner.verify_bytes expects the caller to provide one or more verification keys via opts={"pubkeys": [...]}. Entries may be cryptography public-key objects or PEM-encoded bytes. The signer reports success as soon as the required number of signatures validates against the supplied key material.

X.509 utilities

Beyond detached signatures, CASigner assists with certificate authority tasks:

  • issue_self_signed – build a CA or leaf certificate directly from a KeyRef and subject mapping.
  • create_csr – generate a certificate signing request complete with SAN and key-usage extensions.
  • sign_csr – issue certificates from CSRs using an existing CA key and certificate chain.
  • verify_chain – validate a leaf against an intermediate chain and optional trust anchors with basic time and CA checks.

These helpers rely on the same key-loading logic demonstrated in the quickstart, so PEM-encoded keys or KeyRef.tags["crypto_obj"] objects both work seamlessly.

Entry Point

The signer registers under the swarmauri.signings entry point as CASigner and can be resolved through the Swarmauri plugin manager alongside other signing implementations.

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_ca-0.3.0.dev45.tar.gz (14.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_ca-0.3.0.dev45-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_signing_ca-0.3.0.dev45.tar.gz.

File metadata

  • Download URL: swarmauri_signing_ca-0.3.0.dev45.tar.gz
  • Upload date:
  • Size: 14.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_ca-0.3.0.dev45.tar.gz
Algorithm Hash digest
SHA256 9e30b9ce736aafc8e4369e1f7a2547fc9d067b86a7bc159e6df9af4ef3f6daae
MD5 488765874a27b97ad8c378e48d7b1634
BLAKE2b-256 6bbad8d4fd7ff552f7197073ae8ec0c594a303bc0e12f324002ea6eaab06ac00

See more details on using hashes here.

File details

Details for the file swarmauri_signing_ca-0.3.0.dev45-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_signing_ca-0.3.0.dev45-py3-none-any.whl
  • Upload date:
  • Size: 13.4 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_ca-0.3.0.dev45-py3-none-any.whl
Algorithm Hash digest
SHA256 8ad781ee5f76d834362aefba19beb1f135254ff01781c9951d18883f3bde3afe
MD5 8d8bb07e34a98630c0c558eb07a64509
BLAKE2b-256 7d5682111ed07fbf18d1ad3ae90cbf26bf6c82e2f90f4831163860a5e4d31095

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