Skip to main content

libpep-py: Python bindings for libpep

Python bindings for libpep, a library for polymorphic encryption and pseudonymization implementing the n-PEP scheme: end-to-end encrypted, asynchronous, pseudonymized data sharing between users, where semi-trusted transcryptors (no single one can read data or link pseudonyms) blindly re-encrypt data and convert pseudonyms between pseudonymization domains, with distributed trust over n transcryptors.

Installation

pip install libpep-py

The module is importable as libpep. The API mirrors the Rust crate with its defaults, ristretto255 and SHA-512, so there are no group or ciphersuite type parameters. This round trip converts the pseudonym of one user, a sender, into the pseudonym of another user, a receiver, for the same subject:

from libpep.client import decrypt, encrypt
from libpep.contexts import EncryptionContext, PseudonymizationDomain
from libpep.data import Pseudonym
from libpep.factors import RekeyingSecret
from libpep.keys import make_global_keys, make_session_keys
from libpep.transcryptor import Transcryptor

# System setup: global keys and the secrets of the transcryptor.
global_public, global_secret = make_global_keys()
transcryptor = Transcryptor("pseudonymization secret", "rekeying secret")

# User A (a sender) and user B (a receiver) each work in their own pseudonymization domain and
# encryption context, with session keys for it.
domain_a, session_a = PseudonymizationDomain("hospital"), EncryptionContext("session-a")
domain_b, session_b = PseudonymizationDomain("research"), EncryptionContext("session-b")
keys_a = make_session_keys(global_secret, session_a, RekeyingSecret(b"rekeying secret"))
keys_b = make_session_keys(global_secret, session_b, RekeyingSecret(b"rekeying secret"))

# A encrypts one of its pseudonyms for its own encryption context.
pseudonym_a = Pseudonym.random()
encrypted = encrypt(pseudonym_a, keys_a.public())

# The transcryptor converts it to B's domain and encryption context, without decrypting it.
info = transcryptor.transcryption_info(domain_a, domain_b, session_a, session_b)
transcrypted = transcryptor.transcrypt(encrypted, info, keys_a.public())

# B decrypts its own pseudonym for the same subject, which is unlinkable to A's.
pseudonym_b = decrypt(transcrypted, keys_b)
assert pseudonym_a.to_hex() != pseudonym_b.to_hex()

# Transcryption is reversible.
back = transcryptor.transcrypt(transcrypted, info.reverse(), keys_b.public())
assert decrypt(back, keys_a).to_hex() == pseudonym_a.to_hex()

An operation takes either the one key it needs or a bundle: keys_a.public() for the session's public keys, keys_a itself where a secret key is needed. The type of the data selects the right half of the bundle.

See the repository README for the cryptographic background and the references.

Development

Build and test:

cd bindings/python
maturin develop
python -m unittest discover tests -v
python generate_stubs.py   # regenerate the type stubs after an API change

Metadata

Release files for libpep-py 0.14.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for libpep-py 0.14.0
File Size Uploaded Provenance Actions
libpep_py-0.14.0.tar.gz 373.4 kB With provenance Details for libpep_py-0.14.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for libpep-py 0.14.0
File Actions
libpep_py-0.14.0-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details for libpep_py-0.14.0-cp39-abi3-win_amd64.whl
libpep_py-0.14.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl CPython 3.9 abi3 Linux glibc 2.17+ x86-64 Details for libpep_py-0.14.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
libpep_py-0.14.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl CPython 3.9 abi3 Linux glibc 2.17+ ARM64 Details for libpep_py-0.14.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
libpep_py-0.14.0-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl CPython 3.9 abi3 macOS 10.12+ x86-64, macOS 11.0+ ARM64, macOS 10.12+ universal2 (ARM64, x86-64) Details for libpep_py-0.14.0-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Total release size: 6.4 MB

Release files / libpep_py-0.14.0.tar.gz

Download URL libpep_py-0.14.0.tar.gz
Size 373.4 kB
Tags Source
SHA-256 checksum
How to use checksums
0ee6d757a3e4bab320c4183e9041e50c3490c5305533a6461af840ad7d0bd8a2
BLAKE2b-256 checksum
How to use checksums
54d9182a4f0875ec64396353a8b823b15410e104501f8e84b508059b13f3bcae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / libpep_py-0.14.0-cp39-abi3-win_amd64.whl

Download URL libpep_py-0.14.0-cp39-abi3-win_amd64.whl
Size 1.1 MB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
39d598745a91385b48b12bde3161227b6cd36f5695ad3e8772cbc594eac3a765
BLAKE2b-256 checksum
How to use checksums
8797d045768df06ef648c680b224de9b7e120ebe5843b8edf65c2831dd30682b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / libpep_py-0.14.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl

Download URL libpep_py-0.14.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl
Size 1.3 MB
Tags CPython 3.9 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
138cc2bc63dfea81388bdec52e9c8cc1776b4e0a6f3adb102f350fb7f2863c92
BLAKE2b-256 checksum
How to use checksums
454842972ba7714f385b9a46fe1d5c12f4d63f8e00b9ceeb6a2ab4245c13e15c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / libpep_py-0.14.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl

Download URL libpep_py-0.14.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl
Size 1.3 MB
Tags CPython 3.9 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
3c5caa759088e0dcd44e53eb22525114767811314700f0748cde2d73af68866c
BLAKE2b-256 checksum
How to use checksums
4afb58472f451555a17e13cbdf723abaccfb15fb4a1b9d92b2e31536ba1d2607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Release files / libpep_py-0.14.0-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl

Download URL libpep_py-0.14.0-cp39-abi3-macosx_10_12_universal2.macosx_10_12_x86_64.macosx_11_0_arm64.whl
Size 2.3 MB
Tags CPython 3.9 abi3 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
feda7e32811ffef7c0bfbde879e78016adedc622d5644fa162a48220c6644e53
BLAKE2b-256 checksum
How to use checksums
d18136a47fade24c8711540b93edf26ff63585fe9ccfd0bffade349d46ded522
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

Security for libpep-py 0.14.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 5 files in this release have been uploaded with provenance metadata.

Select from 5 files

Attestation for libpep_py-0.14.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 2, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page