Skip to main content

Public research implementation of SABLE-HE, a post-quantum code/LPN-based leveled homomorphic-encryption toolkit for encrypted federated aggregation.

Project description

SABLE-HE (Post Quantum Homomorphic Encryption)

SABLE-HE is a Python research-preview package for code/LPN-based homomorphic arithmetic and federated-learning aggregation experiments.

The package includes:

  • C7 relation-resistant compaction APIs for SABLE-HE experiments;
  • arithmetic operations over the native prime-field message space;
  • encrypted FL aggregation helpers for sum, mean, weighted_sum, weighted_average, FedAvg, and FedSGD;
  • plaintext/decryptor-side robust FL aggregation helpers for coordinate min/max, median, trimmed mean, geometric median, norm-clipped mean, Krum, and Multi-Krum;
  • adapters for Python lists, NumPy arrays, TensorFlow tensors, Keras get_weights() lists/models, and Torch tensors when those optional libraries are installed;
  • CLI demos, estimators, tests, and documentation.

Security note: this package is a research-preview implementation. It does not ship externally certified security parameters. Use it for research, education, validation, and reproducible experiments unless and until your chosen parameter sets and implementation have been independently reviewed.

Install

From a local wheel:

python -m pip install dist/sable_he_research-0.2.0-py3-none-any.whl

From source:

python -m pip install .

With NumPy adapters:

python -m pip install .[numpy]

For local development:

python -m pip install -e .[dev,numpy]
python -m pytest -q

For pip:

python -m pip install sable-he-research

Quick encrypted FedAvg example

from sable import PRESETS, keygen_c7
from sable.fl import EncryptedFLAggregator, PlainFLAggregator

params = PRESETS["fl_demo_clean"]
kp = keygen_c7(params, seed=123, mode="coordinate")

agg = EncryptedFLAggregator(kp, scale=1000, seed=9000)

client_weights = [
    [0.12, -0.34, 1.20],
    [0.10, -0.30, 1.25],
    [0.20, -0.40, 1.10],
]
sample_counts = [80, 20, 100]

encrypted_clients = [
    agg.encrypt_model(weights, seed=1000 + i)
    for i, weights in enumerate(client_weights)
]

server_result = agg.fedavg(encrypted_clients, sample_counts)
final_weights = agg.decrypt_model(server_result)

print(final_weights)  # [0.158, -0.366, 1.155]

reference = PlainFLAggregator().fedavg(client_weights, sample_counts)
print(reference)

NumPy / Keras-style model weights

import numpy as np
from sable import PRESETS, keygen_c7
from sable.fl import EncryptedFLAggregator

params = PRESETS["fl_demo_clean"]
kp = keygen_c7(params, seed=123, mode="coordinate")
agg = EncryptedFLAggregator(kp, scale=1000)

client_a = [np.array([1.0, 2.0]), np.array([[3.0], [4.0]])]
client_b = [np.array([2.0, 4.0]), np.array([[6.0], [8.0]])]

enc_a = agg.encrypt_model(client_a, seed=11)
enc_b = agg.encrypt_model(client_b, seed=22)

enc_avg = agg.fedavg([enc_a, enc_b], [1, 3])
weights = agg.decrypt_model(enc_avg)

print(weights[0])  # [1.75, 3.50]
print(weights[1])  # [[5.25], [7.00]]

For a Keras model, pass either model.get_weights() or the model itself to encrypt_model. To put decrypted weights back into a model, call model.set_weights(weights) or use sable.fl.assign_model_weights(model, weights).

CLI

sable-he --version
sable-he fl-capabilities
sable-he fl-demo --json
sable-he demo --operation add --x 12 --y 20
sable-he estimate --preset fl_demo_clean --depth 1
sable-he readiness

FL method support

Encrypted-native methods:

  • sum
  • mean
  • weighted_sum
  • weighted_average
  • fedavg
  • fedsgd

Plain/decryptor-side methods:

  • coordinate_min
  • coordinate_max
  • coordinate_median
  • trimmed_mean
  • norm_clipped_mean
  • geometric_median
  • krum
  • multi_krum

Min/max/median/trimmed/Krum need comparison, sorting, norms, or pairwise distances. They are therefore available as plaintext tensor operations or after decryptor-side decryption, not as silent encrypted operations.

Documentation

Start here:

  • docs/FL_AGGREGATION.md — detailed encrypted FedAvg and FL aggregation guide.
  • docs/API_REFERENCE.md — API overview.
  • docs/CLI_REFERENCE.md — command-line usage.
  • docs/GITHUB_PYPI_RELEASE_GUIDE.md — how to publish to GitHub and PyPI.
  • SECURITY.md — security status and reporting policy.

Repository layout

src/sable/          package source
tests/              pytest suite
examples/           runnable examples
docs/               user and release documentation
benchmarks/         benchmark/proxy scripts

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

sable_he_research-0.3.1.tar.gz (4.5 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sable_he_research-0.3.1-py3-none-any.whl (136.0 kB view details)

Uploaded Python 3

File details

Details for the file sable_he_research-0.3.1.tar.gz.

File metadata

  • Download URL: sable_he_research-0.3.1.tar.gz
  • Upload date:
  • Size: 4.5 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for sable_he_research-0.3.1.tar.gz
Algorithm Hash digest
SHA256 6371958257742dd43e1c7bf4a36acc6231696740c35d897f40ab1892a7ac69dd
MD5 5f409e08a9c6be88c690cf6005a84c20
BLAKE2b-256 ba3f1e5d6468b80600e147c739026d1da17c78ec9a5db31dbb0408880d37ea47

See more details on using hashes here.

File details

Details for the file sable_he_research-0.3.1-py3-none-any.whl.

File metadata

File hashes

Hashes for sable_he_research-0.3.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1ffb9784dfd076519ede087967692645af86eaad5dcae3c9f28a450bd1f5d11c
MD5 1b6012dd88d50c1c4b893d5637c2794a
BLAKE2b-256 9a70fdb6a6be98a36ecb312a07785e168c67fca3ffbfbaa88563221993c15c78

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