OpenPGP (GnuPG) + AES-GCM crypto provider for Swarmauri
Project description
Swarmauri Crypto PGP
PGPCrypto is an OpenPGP (GnuPG-backed) crypto provider that implements the
ICrypto contract from swarmauri_core. It combines modern AEAD primitives
with OpenPGP public-key operations so that the same component can handle
symmetrical encryption, public-key key wrapping, and hybrid envelopes.
Features at a glance
- Symmetric AEAD – AES-256-GCM powers
encryptanddecrypt. - Key wrapping –
wrapandunwrapdelegate to GnuPG to protect random or supplied key material with a recipient's public/private key pair. - Hybrid envelopes –
encrypt_for_manysupports both traditional KEM+AEAD (shared ciphertext + wrapped session key) and OpenPGP sealed mode for per-recipient ciphertexts. - Sealing convenience –
sealandunsealprovide single-recipient OpenPGP public-key encryption without managing the envelope structure.
System requirements
- Python 3.10 – 3.13.
- GnuPG available on the
PATH(required bypython-gnupg).
Key material expectations
encrypt/decrypt:KeyRef.materialmust be 16/24/32 bytes for AES-GCM.wrap/encrypt_for_many:KeyRef.publicmust be ASCII-armored OpenPGP public key bytes.unwrap/unseal:KeyRef.materialmust be ASCII-armored OpenPGP private key bytes. Supply a passphrase viaKeyRef.tags["passphrase"]when needed.
Installation
Choose the tool that matches your workflow:
# pip
pip install swarmauri_crypto_pgp
# Poetry
poetry add swarmauri_crypto_pgp
# uv
uv add swarmauri_crypto_pgp
Quickstart
The snippet below mirrors the asynchronous usage exercised in the tests. It
creates a symmetric KeyRef, encrypts plaintext, and decrypts the resulting
AEADCiphertext back to bytes.
import asyncio
from swarmauri_crypto_pgp import PGPCrypto
from swarmauri_core.crypto.types import ExportPolicy, KeyRef, KeyType, KeyUse
async def main() -> None:
crypto = PGPCrypto()
# Symmetric key for AES-256-GCM
sym = KeyRef(
kid="sym1",
version=1,
type=KeyType.SYMMETRIC,
uses=(KeyUse.ENCRYPT, KeyUse.DECRYPT),
export_policy=ExportPolicy.SECRET_WHEN_ALLOWED,
material=b"\x00" * 32,
)
ct = await crypto.encrypt(sym, b"hello OpenPGP")
pt = await crypto.decrypt(sym, ct)
print(pt)
if __name__ == "__main__":
asyncio.run(main())
Working with recipients
- Call
encrypt_for_manywith recipient public keys to either produce an AES-GCM ciphertext with OpenPGP-wrapped session keys (default) or per-recipient sealed blobs by passingenc_alg="OpenPGP-SEAL". - Use
seal/unsealfor single-recipient OpenPGP public-key encryption. wrapandunwrapoffer direct access to OpenPGP-based key encapsulation.
Entry point
The provider is registered under the swarmauri.cryptos entry-point as
PGPCrypto.
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_crypto_pgp-0.3.0.dev5.tar.gz.
File metadata
- Download URL: swarmauri_crypto_pgp-0.3.0.dev5.tar.gz
- Upload date:
- Size: 9.6 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f12fe6d6c7c4c152c1b943cabf15306187745f7d8179b606e1d5ee410d8651ce
|
|
| MD5 |
10ca6364f633c76a89c27322e7da8215
|
|
| BLAKE2b-256 |
dccec4809a66d7f3bbedd491cf553d2642e0b9257a5402fca64f149af4628918
|
File details
Details for the file swarmauri_crypto_pgp-0.3.0.dev5-py3-none-any.whl.
File metadata
- Download URL: swarmauri_crypto_pgp-0.3.0.dev5-py3-none-any.whl
- Upload date:
- Size: 10.7 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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5979f3963f517c00ad45b61aefef8068cd25bce43b797d4ec94554b38c06bd04
|
|
| MD5 |
684cea5c90a4e0d0850e00e9e52136d9
|
|
| BLAKE2b-256 |
133130d404bbcede3d279bb4310d6906ad797ca80398e65324355705975b6c3b
|