Keyring-backed multi-recipient encryption provider for Swarmauri
Project description
Swarmauri MRE Crypto Keyring
Multi-recipient encryption provider using external keyrings/HSMs.
Installation
pip install swarmauri_mre_crypto_keyring
Usage
KeyringMreCrypto delegates CEK (content-encryption key) management to
user-provided keyring clients. Each client must implement id,
wrap_cek, and unwrap_cek. The example below shows how to register an
in-memory keyring and use it to encrypt and decrypt a payload.
import asyncio
import secrets
from swarmauri_mre_crypto_keyring import KeyringMreCrypto
class MemoryKeyring:
def __init__(self):
self._store = {}
def id(self) -> str:
return "memory"
async def wrap_cek(self, cek: bytes, *, context):
token = secrets.token_bytes(8)
self._store[token] = cek
return token
async def unwrap_cek(self, header: bytes, *, context):
return self._store[header]
async def main():
keyring = MemoryKeyring()
keyref = {"kind": "keyring_client", "client": keyring}
crypto = KeyringMreCrypto()
env = await crypto.encrypt_for_many([keyref], b"sensitive data")
recovered = await crypto.open_for(keyref, env)
assert recovered == b"sensitive data"
asyncio.run(main())
The snippet encrypts b"sensitive data" for the memory keyring and
recovers the original plaintext using the same keyring client.
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
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file swarmauri_mre_crypto_keyring-0.3.0.dev3.tar.gz.
File metadata
- Download URL: swarmauri_mre_crypto_keyring-0.3.0.dev3.tar.gz
- Upload date:
- Size: 9.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
154f6f089dea10811aac11ab7680728e079485172135af8b2b56910e587e004a
|
|
| MD5 |
54250d83ca2df9e17f0573f6ec374bdc
|
|
| BLAKE2b-256 |
a675f6cc32f6520b37aa455d9d810921a94fec163cb2c9da3c2d6a02ff1a24c2
|
File details
Details for the file swarmauri_mre_crypto_keyring-0.3.0.dev3-py3-none-any.whl.
File metadata
- Download URL: swarmauri_mre_crypto_keyring-0.3.0.dev3-py3-none-any.whl
- Upload date:
- Size: 10.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.16
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2c95936ffe5e4ac968de5f316d357bec8dfee582f0056d7ec6b9de073e1fa89b
|
|
| MD5 |
eaa949961a28881d3d2cad484ea4a19e
|
|
| BLAKE2b-256 |
eb673f71be9210a520a85e4e8b776449a66bb6bc3806ff0960eae5a4b1c8fde8
|