This release is a pre-release and may not be stable for production use.
swarmauri_mre_crypto_shamir
Shamir Secret Sharing based multi-recipient encryption (MRE) provider for the Swarmauri framework. The provider splits an AES-256-GCM content encryption key using Shamir's threshold scheme and distributes shares to recipients.
Features
- AES-256-GCM payload encryption
- Threshold k-of-n key sharing via Shamir secret sharing
- Envelope rewrapping with optional payload rotation
- Optional authenticated data (AAD) handling
Extras
The plugin supports optional canonicalization extras:
cbor? enables CBOR canonicalization viacbor2
Installation
Choose the tool that matches your workflow:
# pip
pip install swarmauri_mre_crypto_shamir
# Poetry
poetry add swarmauri_mre_crypto_shamir
# uv (project dependency)
uv add swarmauri_mre_crypto_shamir
# uv (one-off virtual environment)
uv pip install swarmauri_mre_crypto_shamir
Install extras, such as CBOR canonicalization support, with swarmauri_mre_crypto_shamir[cbor].
Quickstart
ShamirMreCrypto encrypts a payload with a fresh AES-256-GCM content encryption key, splits the key into Shamir shares, and stores the encrypted payload and shares in a multi-recipient envelope. Provide a threshold with opts["threshold_k"] (defaults to a simple majority) to control how many shares are required to decrypt.
import asyncio
from swarmauri_mre_crypto_shamir import ShamirMreCrypto
async def main() -> None:
provider = ShamirMreCrypto()
recipients = [
{"kid": "alice"},
{"kid": "bob"},
{"kid": "carol"},
]
plaintext = b"Secret launch codes"
envelope = await provider.encrypt_for_many(
recipients,
plaintext,
opts={"threshold_k": 2},
)
print("Mode:", envelope["mode"])
print("Recipients:", [entry["id"] for entry in envelope["recipients"]])
print(
"Threshold:",
int.from_bytes(envelope["shared"]["threshold_k"], "big"),
)
recovered = await provider.open_for_many(
[{"kid": "alice"}, {"kid": "carol"}],
envelope,
)
assert recovered == plaintext
print("Recovered plaintext:", recovered.decode("utf-8"))
if __name__ == "__main__":
asyncio.run(main())
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_mre_crypto_shamir 0.11.0.dev1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| swarmauri_mre_crypto_shamir-0.11.0.dev1.tar.gz | 11.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| swarmauri_mre_crypto_shamir-0.11.0.dev1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.4 kB
Release files / swarmauri_mre_crypto_shamir-0.11.0.dev1.tar.gz
| Download URL | swarmauri_mre_crypto_shamir-0.11.0.dev1.tar.gz |
|---|---|
| Size | 11.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0e1d74547f810035cf62da20bed38d06ab81576053f962b65b4799485a3a607b
|
|
BLAKE2b-256 checksum How to use checksums |
07f45bdc8992468955cde02a68bc930138c89a24b4f0c90d4c45fbba3ad10972
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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_mre_crypto_shamir-0.11.0.dev1-py3-none-any.whl
| Download URL | swarmauri_mre_crypto_shamir-0.11.0.dev1-py3-none-any.whl |
|---|---|
| Size | 12.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7ad4fbe29e6a39f2a79ce00be18096c5c5a92f2218fe5eb4650ae99b889a0bb6
|
|
BLAKE2b-256 checksum How to use checksums |
378c96612ada4382d15a44b536252d17e6db5f60fb803580f304ebcf5b83e74d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.11.26 {"installer":{"name":"uv","version":"0.11.26","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}
|