Skip to main content

ECDH-ES+A128KW based multi-recipient encryption provider for Swarmauri

Project description

Swarmauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_mre_crypto_ecdh_es_kw


Swarmauri MRE Crypto ECDH-ES+A128KW

ECDH-ES+A128KW based multi-recipient encryption provider implementing the IMreCrypto contract.

Capabilities

  • Per-recipient ECDH-ES key agreement over secp256r1
  • AES-128 Key Wrap (KW) of the derived content-encryption key
  • AES-128-GCM payload encryption with optional additional authenticated data (AAD)
  • Supported payload algorithm: A128GCM
  • Supported recipient algorithm: ECDH-ES+A128KW
  • Supported MRE mode: MreMode.ENC_ONCE_HEADERS
  • Re-wrapping existing envelopes is not supported

Installation

pip

pip install swarmauri_mre_crypto_ecdh_es_kw

Poetry

poetry add swarmauri_mre_crypto_ecdh_es_kw

uv

  1. Install uv if it is not already available:

    curl -LsSf https://astral.sh/uv/install.sh | sh
    
  2. Add the package to your environment:

    uv pip install swarmauri_mre_crypto_ecdh_es_kw
    

Usage

The provider operates asynchronously. The example below demonstrates encrypting and decrypting a payload for a single recipient whose key is provided as a cryptography object reference. The same aad (if provided) must be used for both encryption and decryption.

import asyncio

from cryptography.hazmat.primitives.asymmetric import ec

from swarmauri_mre_crypto_ecdh_es_kw import EcdhEsA128KwMreCrypto


async def main() -> None:
    crypto = EcdhEsA128KwMreCrypto()

    sk = ec.generate_private_key(ec.SECP256R1())
    pk = sk.public_key()
    recipient = {"kid": "1", "version": 1, "kind": "cryptography_obj", "obj": pk}

    envelope = await crypto.encrypt_for_many([recipient], b"secret", aad=b"metadata")
    plaintext = await crypto.open_for(
        {"kind": "cryptography_obj", "obj": sk}, envelope, aad=b"metadata"
    )

    assert plaintext == b"secret"


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

Entry point

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

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

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file swarmauri_mre_crypto_ecdh_es_kw-0.2.0.dev47.tar.gz.

File metadata

  • Download URL: swarmauri_mre_crypto_ecdh_es_kw-0.2.0.dev47.tar.gz
  • Upload date:
  • Size: 8.4 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_mre_crypto_ecdh_es_kw-0.2.0.dev47.tar.gz
Algorithm Hash digest
SHA256 f6e16e7efdbdadb83a1a0f9ea37c6ab16cbac3534fe8706b4dbb01d9cac521bb
MD5 fb6ba97069d0670072f24ec30f7ee8d7
BLAKE2b-256 11ea87481b488a14d98075efedbefe7156f9dd9517891faa53007de23dcc3b00

See more details on using hashes here.

File details

Details for the file swarmauri_mre_crypto_ecdh_es_kw-0.2.0.dev47-py3-none-any.whl.

File metadata

  • Download URL: swarmauri_mre_crypto_ecdh_es_kw-0.2.0.dev47-py3-none-any.whl
  • Upload date:
  • Size: 9.6 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_mre_crypto_ecdh_es_kw-0.2.0.dev47-py3-none-any.whl
Algorithm Hash digest
SHA256 b34b3c56604510110af925dfc45b7e68af5d9dd0b9ba8aaa14a5a1370d595f8d
MD5 f4fa855d70e42dcd16ac107908d6dc99
BLAKE2b-256 ed32e0610db11aaad4114902f1fef9e5edee4a3d844e4f03021deb9ca88042a7

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