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.dev3.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.dev3-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.dev3.tar.gz.

File metadata

File hashes

Hashes for swarmauri_mre_crypto_pgp-0.3.0.dev3.tar.gz
Algorithm Hash digest
SHA256 504deed6b970e0eddeb1a4c9cccbb0847e5ec96d34c9ae74e0335e61171aaad5
MD5 a482e2d9568b37f3596ce9da59d8fa4e
BLAKE2b-256 7a4a75ca848254460b598396eed92780eb35c35fdd82d6d7fc40459bb7781bf0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for swarmauri_mre_crypto_pgp-0.3.0.dev3-py3-none-any.whl
Algorithm Hash digest
SHA256 edfe3e958df3ed1b481c5876103389ec06c3ad2406d88ad79b5bd2e1fe1a0019
MD5 a248f44e47b97506f421b4a5527af6e8
BLAKE2b-256 1e79798ecba16789500e20858b4711b74057ad649273848c2ec72e77399f11d6

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