Skip to main content

pylotte

Secure Pickle Serialization with RSA Signatures

pylotte is a lightweight Python utility that allows you to securely serialize Python objects with RSA digital signatures. It ensures the integrity and authenticity of your data by cryptographically signing serialized files and verifying them before loading.


✨ Features

  • 🔐 Sign serialized files using an RSA private key
  • ✅ Verify signatures with the corresponding public key
  • 🛡️ Prevents tampering and ensures data authenticity
  • 📦 Simple and minimal interface
  • 🔄 Pluggable serializer: use pickle, dill, cloudpickle, or any dump/load API

📦 Installation

Install directly from PyPI:

# Basic installation with pickle support
pip install pylotte

# With dill support for advanced serialization
pip install pylotte[dill]

🛠 Usage

Basic Usage with Pickle

from pylotte.signed_pickle import SignedPickle

# Initialize with RSA key paths
signer = SignedPickle(public_key_path="public.pem", private_key_path="private.pem")

# Data to serialize
data = {"user": "alice", "role": "admin"}

# Securely dump and sign the pickle file
signer.dump_and_sign(data, "data.pkl", "data.sig")

# Load and verify the signed pickle file
loader = SignedPickle(public_key_path="public.pem")
data_loaded = loader.safe_load("data.pkl", "data.sig")

Advanced Usage with a Custom Serializer

from pylotte.signed_pickle import SignedPickle
import cloudpickle  # or dill, or any module with dump/load

signer = SignedPickle(
    public_key_path="public.pem",
    private_key_path="private.pem",
    serializer=cloudpickle,
)

data = {
    "name": "bob",
    "process": lambda x: x * 2,
    "nested": {"func": lambda y: y + 1},
}

signer.dump_and_sign(data, "data.pkl", "data.sig")

loader = SignedPickle(public_key_path="public.pem", serializer=cloudpickle)
data_loaded = loader.safe_load("data.pkl", "data.sig")

result = data_loaded["process"](5)  # Returns 10

Using a Custom Serializer (e.g., cloudpickle)

from pylotte.signed_pickle import SignedPickle
import cloudpickle

# Pass any object that provides dump/load
signer = SignedPickle(
    public_key_path="public.pem",
    private_key_path="private.pem",
    serializer=cloudpickle,
)

data = {"callable": lambda x: x + 3}
signer.dump_and_sign(data, "data.pkl", "data.sig")

loader = SignedPickle(public_key_path="public.pem", serializer=cloudpickle)
loaded = loader.safe_load("data.pkl", "data.sig")

🔐 How It Works

  • dump_and_sign():

    • Serializes your data using the provided serializer (defaults to pickle) and saves it to a file.
    • Signs the file contents using an RSA private key.
    • Stores the signature in a separate .sig file.
  • safe_load():

    • Reads the serialized file and its signature.
    • Verifies the signature using the RSA public key.
    • If valid, loads and returns the original data.

🔧 Requirements


📄 License

This project is licensed under the MIT License.



👤 Author

Developed by Alpamayo Solutions

Release files for pylotte 0.3

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

Source distribution (sdist)

Source distribution for pylotte 0.3
File Size Uploaded
pylotte-0.3.tar.gz 11.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pylotte 0.3
File Interpreter ABI Platform
pylotte-0.3-py3-none-any.whl Python 3 none any Details

Total release size: 16.6 kB

Release files / pylotte-0.3.tar.gz

Download URL pylotte-0.3.tar.gz
Size 11.4 kB
Tags Source
SHA-256 checksum
How to use checksums
f123fdd23cd7df0845a1df43e6a92357d3d070c08d619b69651b532f18f8beb1
BLAKE2b-256 checksum
How to use checksums
3b2d1de404f980c9089a804cd075ffac16a39c1a68ea0f1d8f3a16a788d637c2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release files / pylotte-0.3-py3-none-any.whl

Download URL pylotte-0.3-py3-none-any.whl
Size 5.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5884bf2b9846eb87e646ae35233587e32c1cc8513a90d54702f427469e2392fa
BLAKE2b-256 checksum
How to use checksums
628049ceb6b362fecab0027e160040d6e551504f5ceab6191a19cc85bae3ad8d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.13

Release history Release notifications | RSS feed

This release

0.3 This release

2 release files

0.2

2 release files

0.1

2 release files

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