Skip to main content

Age-style X25519 sealed-per-recipient MRE provider for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_mre_crypto_age


Swarmauri MRE Crypto Age

Age-based multi-recipient encryption provider implementing the IMreCrypto contract.

  • Sealed-per-recipient X25519 stanzas (mode="sealed_per_recipient" and recipient_alg="X25519-SEAL")
  • ChaCha20-Poly1305 payload encryption for each recipient header
  • Deterministic recipient identifiers via SHA-256 public key fingerprints
  • Rewrapping support for adding or removing recipients when provided the original plaintext or an opening identity

Installation

Choose the installer that matches your project workflow:

# pip
pip install swarmauri_mre_crypto_age

# Poetry
poetry add swarmauri_mre_crypto_age

# uv
uv add swarmauri_mre_crypto_age

Usage

The provider exposes asynchronous helpers for encrypting data to many recipients and decrypting it for a specific private key. The example below walks through a complete round trip.

  1. Create the crypto provider.
  2. Generate key pairs for two recipients.
  3. Encrypt a payload for both recipients.
  4. Decrypt the payload for one recipient.
from swarmauri_mre_crypto_age import AgeMreCrypto
from cryptography.hazmat.primitives.asymmetric.x25519 import X25519PrivateKey

crypto = AgeMreCrypto()

# generate key pairs for each participant
sk1 = X25519PrivateKey.generate()
pk1 = sk1.public_key()
sk2 = X25519PrivateKey.generate()
pk2 = sk2.public_key()

recipients = [
    {"kind": "cryptography_obj", "obj": pk1},
    {"kind": "cryptography_obj", "obj": pk2},
]

env = await crypto.encrypt_for_many(recipients, b"secret")
pt = await crypto.open_for({"kind": "cryptography_obj", "obj": sk1}, env)
assert pt == b"secret"

The helper accepts multiple KeyRef formats, including dictionaries with kind="cryptography_obj" (for X25519PublicKey / X25519PrivateKey objects) and raw byte references such as kind="raw_x25519_pk" or kind="age_x25519_pk". When rewrapping an existing envelope to add recipients, pass the plaintext via opts["pt"] or provide an identity through opts["open_with"] so the payload can be resealed for the new recipients.

Entry point

The provider is registered under the swarmauri.mre_cryptos entry-point as AgeMreCrypto.

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_mre_crypto_age-0.3.0.dev31.tar.gz (9.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_mre_crypto_age-0.3.0.dev31-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: swarmauri_mre_crypto_age-0.3.0.dev31.tar.gz
  • Upload date:
  • Size: 9.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_mre_crypto_age-0.3.0.dev31.tar.gz
Algorithm Hash digest
SHA256 d154944c7bc9dbef358876e0b646e0716a36a6af5edb60c14a8eb4092f2cbb83
MD5 51235fa703c26a5c2b6d1ba62c165869
BLAKE2b-256 a38ee89e1932786dbf3767ffa09e7945e1ff1937edb33093482bffc9aed9acf0

See more details on using hashes here.

File details

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

File metadata

  • Download URL: swarmauri_mre_crypto_age-0.3.0.dev31-py3-none-any.whl
  • Upload date:
  • Size: 10.3 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_mre_crypto_age-0.3.0.dev31-py3-none-any.whl
Algorithm Hash digest
SHA256 5bdc049f02676dce9ff5768455b1c21980d65de42a3d5b412ac18bf79a3c9c02
MD5 9ff8d9d4baa8e917947aefa5c53c5a91
BLAKE2b-256 806e83c9b3a51db0e9f9cc30b9e5ef4eecce9efb34e72ba6c349953384a97ae3

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