Skip to main content

OpenPGP sealed-per-recipient MRE provider for Swarmauri

Project description

Swamauri Logo

PyPI - Downloads Hits PyPI - Python Version PyPI - License PyPI - swarmauri_mre_crypto_pgp


Swarmauri MRE Crypto PGP

OpenPGP-based multi-recipient encryption providers implementing the IMreCrypto contract. This package exposes three providers:

  • PGPSealMreCrypto – per-recipient sealed payloads (sealed_per_recipient mode).
  • PGPSealedCekMreCrypto – shared AEAD payload with per-recipient sealed CEK (sealed_cek+aead mode).
  • PGPMreCrypto – composite provider supporting both the enc_once+per_recipient_header and sealed_per_recipient modes.

All providers use OpenPGP public key encryption via PGPy.

Installation

pip install swarmauri_mre_crypto_pgp

Usage

import asyncio
from pgpy import PGPKey, PGPUID
from pgpy.constants import (
    CompressionAlgorithm,
    HashAlgorithm,
    KeyFlags,
    PubKeyAlgorithm,
    SymmetricKeyAlgorithm,
)
from swarmauri_mre_crypto_pgp import PGPMreCrypto


async def main():
    # Generate an OpenPGP key pair with pgpy
    key = PGPKey.new(PubKeyAlgorithm.RSAEncryptOrSign, 2048)
    uid = PGPUID.new("Test User", email="test@example.com")
    key.add_uid(
        uid,
        usage={KeyFlags.EncryptCommunications},
        hashes=[HashAlgorithm.SHA256],
        ciphers=[SymmetricKeyAlgorithm.AES256],
        compression=[CompressionAlgorithm.ZLIB],
    )

    # Create references understood by the provider
    pub_ref = {"kind": "pgpy_pub", "pub": key.pubkey}
    priv_ref = {"kind": "pgpy_priv", "priv": key}

    # Encrypt for many and open with the private key
    mre = PGPMreCrypto()
    pt = b"hello"
    env = await mre.encrypt_for_many([pub_ref], pt)
    rt = await mre.open_for(priv_ref, env)
    print(rt)


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

Entry point

Providers are registered under the swarmauri.mre_cryptos entry-point as PGPSealMreCrypto, PGPSealedCekMreCrypto and PGPMreCrypto.

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_pgp-0.3.0.dev4.tar.gz (13.4 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_pgp-0.3.0.dev4-py3-none-any.whl (16.7 kB view details)

Uploaded Python 3

File details

Details for the file swarmauri_mre_crypto_pgp-0.3.0.dev4.tar.gz.

File metadata

File hashes

Hashes for swarmauri_mre_crypto_pgp-0.3.0.dev4.tar.gz
Algorithm Hash digest
SHA256 acf88b62915263ab9f4d8e03e5b73a01779902f221d2a7b32f7034d2751e5c66
MD5 364ce951b89d87a3a57f9fefc12c2380
BLAKE2b-256 a8c723f4d12bd1b838e4a29a415ad37a53894d1da60e99d116c916e6831c7148

See more details on using hashes here.

File details

Details for the file swarmauri_mre_crypto_pgp-0.3.0.dev4-py3-none-any.whl.

File metadata

File hashes

Hashes for swarmauri_mre_crypto_pgp-0.3.0.dev4-py3-none-any.whl
Algorithm Hash digest
SHA256 7146e9332702be49e5d2ff16950c35e609f8920e54bc457a51ff9608618ddc90
MD5 c8ba368c55adce7654a535dd43f033c1
BLAKE2b-256 2e54dea5939fe2336050a0e67f45c241daadf8209192ab0999c5c8b4a5a9226b

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