Skip to main content

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_keyprovider_local

Swarmauri Local Key Provider

Provides a pure in-memory implementation of the KeyProviderBase suitable for local development, unit testing, and rapid prototyping without any external infrastructure.

Capabilities

  • Generate symmetric AES-256-GCM keys and several asymmetric algorithms (Ed25519, X25519, RSA-OAEP/PSS-SHA256, and ECDSA P-256-SHA256).
  • Import existing key material and rotate to new versions on demand.
  • Retrieve stored keys (optionally including the secret material) and list available versions.
  • Export public material as individual JWKs or aggregate JWKS documents.
  • Produce cryptographically secure random bytes or derive material using HKDF.
  • Destroy keys when they are no longer needed to keep local environments tidy.

Installation

Choose the tool that best matches your workflow:

# pip
pip install swarmauri_keyprovider_local

# Poetry
poetry add swarmauri_keyprovider_local

# uv
uv add swarmauri_keyprovider_local

Quickstart

The example below mirrors swarmauri_keyprovider_local.examples.basic_usage and demonstrates how to create, store, and retrieve a symmetric key.

import asyncio
from swarmauri_keyprovider_local import LocalKeyProvider
from swarmauri_core.key_providers.types import (
    ExportPolicy,
    KeyAlg,
    KeyClass,
    KeySpec,
)
from swarmauri_core.crypto.types import KeyUse


async def run_example() -> str:
    """Create and retrieve a symmetric key using LocalKeyProvider."""

    provider = LocalKeyProvider()
    spec = KeySpec(
        klass=KeyClass.symmetric,
        alg=KeyAlg.AES256_GCM,
        uses=(KeyUse.ENCRYPT,),
        export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
    )
    created = await provider.create_key(spec)
    fetched = await provider.get_key(created.kid, include_secret=True)
    assert fetched.material is not None
    return fetched.kid


if __name__ == "__main__":
    print(asyncio.run(run_example()))

Rotate, export, and derive

Once you have a provider instance, additional asynchronous helpers are available to manage keys and metadata:

# Rotate the current key in-place (keeps the same KID with a new version)
rotated = await provider.rotate_key(created.kid)

# List available versions for auditing or debugging
versions = await provider.list_versions(created.kid)

# Export public material
jwk = await provider.get_public_jwk(created.kid)
jwks = await provider.jwks()

# Destroy keys when finished
await provider.destroy_key(created.kid)

# Generate bytes or derive new material locally
random_bytes = await provider.random_bytes(32)
derived = await provider.hkdf(b"ikm", salt=b"salt", info=b"context", length=32)

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_keyprovider_local 0.2.0

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_keyprovider_local 0.2.0
File Size Uploaded
swarmauri_keyprovider_local-0.2.0.tar.gz 9.7 kB Details

Built distribution (wheel)

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

Total release size: 21.9 kB

Release files / swarmauri_keyprovider_local-0.2.0.tar.gz

Download URL swarmauri_keyprovider_local-0.2.0.tar.gz
Size 9.7 kB
Tags Source
SHA-256 checksum
How to use checksums
80bc53e706d50d9b749b87c355777734a989d63977d663749239547ddd22d06c
BLAKE2b-256 checksum
How to use checksums
0c187933935b7a9dd1b352288de291389bd461d7de191d80ae172f7fa7fda452
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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_keyprovider_local-0.2.0-py3-none-any.whl

Download URL swarmauri_keyprovider_local-0.2.0-py3-none-any.whl
Size 12.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc84d62b61851468c71a80574c144e8b32121b615ea2ce4f93e9ade985f1abfc
BLAKE2b-256 checksum
How to use checksums
2b4cb65069b40ab9f886097277bd9a8adf52c5aad67f2b144be47accc79fbb22
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.9.27 {"installer":{"name":"uv","version":"0.9.27","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